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

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

Re: unexpected result with keymap inheritance


From: Stefan Monnier
Subject: Re: unexpected result with keymap inheritance
Date: Wed, 23 Nov 2016 08:42:42 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> Now what I want is just to remove "o" and "u" from
> 'very-special-mode-map', so that my keys from 'special-mode-map' will
> take precedence, but I can't do it, as with this:

I see, yes, that makes sense.  I suggest you `M-x report-emacs-bug` and
ask for this feature.

> I will get "<key> is undefined", so I have to bind my keys to the same
> commands in this new map again:
>
>   (define-key very-special-mode-map (kbd "o") 'backward-char)
>   (define-key very-special-mode-map (kbd "u") 'forward-char)

That's the obvious workaround, yes.  It's not that terrible, but I agree
it's less satisfactory.

Another approach if you want these `o` and `u` bindings to apply in
every special-mode buffer, is to do

    (defvar my-special-mode-bindings-map
        (let ((map (make-sparse-keymap)))
          (define-key map (kbd "o") 'backward-char)
          (define-key map (kbd "u") 'forward-char)
          map))

    (define-minor-mode my-special-mode-bindings "Docstring")

    (add-hook 'special-mode-hook #'my-special-mode-bindings)

so you don't have to go through every derivative of special-mode which
rebinds those keys and unbind them in their map.


        Stefan



reply via email to

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