help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How not to share `local-set-key' with all other buffers in the same majo


From: Jean Louis
Subject: How not to share `local-set-key' with all other buffers in the same major mode?
Date: Fri, 02 Apr 2021 11:32:42 +0300

I would like to use editing modes as temporary view modes where I
would like to set a key like "q" or "i" temporarily, like this for
example:

(local-set-key "q" 'quit-window)

And I use it in read only mode. The binding goes in the current
buffer’s local map, which in most cases is shared with all other
buffers in the same major mode.

If the mode is Markdown then next time I enter in writeable buffer the
same key "q" remains and I need to unset it. So it is not convenient.

Would a solution for that be to make a new mode map and then invoke
new mode map when I wish to view it with special keys? All invoking I
do through functions, not manually.

Another matter is that I do dynamic `local-set-key' like following:

  (local-set-key "i" `(lambda ()
                                (interactive)
                                (hyperscope-view-with-mode ,id
                                 ,(cond ((string= column "hlinks_description") 
"hlinks_text")
                                        ((string= column "hlinks_text") 
"hlinks_description")
                                        (t (error "Cannot find column"))))))

So then if I wish to see some database entry in the buffer, I press
"i" and I see first "hlinks_description", but if I press "i" again I
will see "hlinks_text". This is very handy.

Is it possible to invoke mode dynamically, like to define a function
that defines mode, and that I call that function which would then call
the mode with specified parameters which in turn change the key
bindings as how I wish?

Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]