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: Emanuel Berg
Subject: Re: diff-goto-source hi-jacks my M-o
Date: Sun, 27 Dec 2020 18:29:48 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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
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".

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.

[1] https://dataswamp.org/~incal/emacs-init/window-new.el line 31

[2] https://dataswamp.org/~incal/emacs-init/super.el

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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