From: Alex Kost <alezost@gmail.com>
To: Alexander Shukaev <haroogan@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Redefine the `special-mode-map'
Date: Fri, 09 Jan 2015 17:46:13 +0300 [thread overview]
Message-ID: <87a91sau6i.fsf@gmail.com> (raw)
In-Reply-To: <CAKu-7WxXDOUXDAOzDJh0H1BtQ7tXg7OG6Xxi_WdNTtSAKJHwRQ@mail.gmail.com> (Alexander Shukaev's message of "Fri, 9 Jan 2015 05:26:41 +0100")
Alexander Shukaev (2015-01-09 07:26 +0300) wrote:
> Hello everyone,
>
> I'd like to redefine the `special-mode-map'. Accordingly, in the very
> beginning of my Emacs configuration I've added the following code:
>
> (let ((keymap (make-sparse-keymap)))
> (suppress-keymap keymap)
> (define-key keymap (kbd "q") #'quit-window)
> (define-key keymap (kbd "r") #'revert-buffer)
> (setq special-mode-map keymap))
>
> I assume that all the modes which are either derived from `special-mode' or
> have `special-mode-map' as a parent to their respective maps should indeed
> inherit the above key bindings.
>
> However, this is not the case. [C-h][b] shows that the above code had no
> effect and that the default value of `special-mode-map' was still used as a
> parent to construct child maps. In contrast, to complicate things,
> [C-h][v]special-mode-map shows that `special-mode-map' contains all the
> above changes. So what is going on? How to solve this problem?
The problem is you set the whole map variable to a new value. If you
really need to "kill" all the bindings there, you may do it like this:
(setcdr special-mode-map nil)
And then use your:
(define-key special-mode-map (kbd "q") #'quit-window)
...
But do not set `special-mode-map' to another value.
--
Alex
next prev parent reply other threads:[~2015-01-09 14:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-09 4:26 Redefine the `special-mode-map' Alexander Shukaev
2015-01-09 14:46 ` Alex Kost [this message]
2015-01-09 14:53 ` Alexander Shukaev
2015-01-09 15:02 ` Alexander Shukaev
2015-01-09 15:05 ` Dmitry Gutov
2015-01-09 15:09 ` Alexander Shukaev
2015-01-09 18:48 ` Michael Heerdegen
2015-01-09 18:54 ` Alexander Shukaev
2015-01-09 18:58 ` Dmitry Gutov
2015-01-09 19:22 ` Alexander Shukaev
2015-01-09 19:29 ` Michael Heerdegen
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=87a91sau6i.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=haroogan@gmail.com \
--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.