From: Jean Louis <bugs@gnu.support>
To: Help GNU Emacs <help-gnu-emacs@gnu.org>
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 [thread overview]
Message-ID: <courier.000000006066D6B2.00001C01@stw1.rcdrun.com> (raw)
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/
next reply other threads:[~2021-04-02 8:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 8:32 Jean Louis [this message]
2021-04-02 12:44 ` How not to share `local-set-key' with all other buffers in the same major mode? Skip Montanaro
2021-04-02 12:55 ` Stefan Monnier
2021-04-02 16:16 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=courier.000000006066D6B2.00001C01@stw1.rcdrun.com \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.