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

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

Re: Redefine the `special-mode-map'


From: Alex Kost
Subject: Re: Redefine the `special-mode-map'
Date: Fri, 09 Jan 2015 17:46:13 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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



reply via email to

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