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

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

Re: diff-goto-source hi-jacks my M-o


From: Tomas Nordin
Subject: Re: diff-goto-source hi-jacks my M-o
Date: Mon, 28 Dec 2020 17:41:38 +0100

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> Tomas Nordin wrote:
>
>>> No, it's not required there, you are free to enable
>>> ‘my-precious-keys-map’ unconditionally as well:
>>>
>>>     (add-to-list 'emulation-mode-map-alists
>>>                  (list (cons t my-precious-keys-map)))
>>>
>>> if you feel that you will never need to suspend it.
>>
>> Alright, then we know the way to go if we have a set of
>> bindings that must never be "hi-jacked"
>>
>>>> And that the trickery with the key-maps is hard to follow
>>>> for me.
>>>
>>> There is no any trickery, just a hardcoded priority order
>>> in Emacs itself: global map is overridden by major mode
>>> map, which in turn is overridden by minor mode maps, which
>>> can be overridden by emulation mode maps.
>>>
>>> That is, using a minor mode map would suffice in your
>>> specific case — about M-o in diff-mode. But so would
>>> a mere:
>>>
>>>     (with-eval-after-load 'diff-mode
>>>       (define-key diff-mode-map
>>>         (kbd "M-o") nil)) ; also on RET, o, C-c C-c, which is more than 
>>> enough
>>
>> That's the way I go about it. It is rare enough this binding
>> is used anywhere (apart from the original binding about
>> setting face of course)
>
> Don't know what this discussion is about but I use M-o all the
> time! It is so comfortable, and requires minimal finger

Indispensable!

> movement from "asdf/jkl;" - I have it "other-window-or-split" [1]
> which is like pretty much the foundation of my ways with windows, not
> unlike a bunch of Isaac Asimov novels I keep under one table leg, to
> prevent it from wobbling...
>
> The way I solved it with M-o (this was ages ago, I set this
> up) I put that and other untouchable keys in
> "super-global-keys" and then for every mode that dares
> infringe, which is evident instantly, I call
> "disable-super-global-keys"
>
> (defun disable-super-global-keys (&optional map)
>   "Disable the super global keys so they can be assigned.
> Use the current map unless MAP is provided."
>   (dolist (k super-global-keys)
>     (define-key (or map (current-local-map)) k nil) )) ; [2]
>
> In all my Emacs I have called it 22 times, so maybe that is an
> approximation of the number of modes that had to be told "step
> back son, there is nothing to see".

See the suggestion from Dmitry upthread, it was a way to let a binding
be available always as I understand, by one code block using
`emulation-mode-map-alists'.

I wonder what all those 22 situations are where you need to nil the
binding out. So far it happened only in diff-mode for me. I set my
precious binding like this

(global-set-key (kbd "M-o") 'other-window)

but diff-mode took it.

Ahh, but now I understand. You have all sorts of bindings you enforce
around Emacs? The suggestion upthread seem to be good for that.

>
> No idea if this solution is even close to canonical, probably
> not, but it seems bulletproof enough, so I thought I'd tell
> you about it.

Thanks
--
Tomas



reply via email to

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