unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* diff-goto-source hi-jacks my M-o
@ 2020-07-05 15:55 Tomas Nordin
  2020-07-05 20:39 ` Tomas Nordin
  2020-07-06  2:20 ` Dmitry Alexandrov
  0 siblings, 2 replies; 10+ messages in thread
From: Tomas Nordin @ 2020-07-05 15:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hello

I just tried vc-diff, C-x v D, or maybe vc-root-diff. Anyway, I
discovered that one of my favorite custom key-bindings, M-o, which I use
for other-window, was hi-jacked. It was hi-jacked to run the command
`diff-goto-source'. I checked to see if some other key-bindings that I
would probably guess do so, also run `diff-goto-source', namely RET and
`o'. And they did. So I could count to three diff-goto-source bindings
from the vd-diff buffer.

Checking mode help (C-h m), we can find some more;

C-c C-c		    diff-goto-source
M-RET		    diff-goto-source
M-o		        diff-goto-source (my precious)
ESC <mouse-2>	diff-goto-source

Seems to be a very important command to find. But for me it would be
enough with RET. And if one is to be voted away, I vote for my precious
M-o to be left alone.

PS: Whenever I fiddle with elisp I am completely in the hands of the
package paredit. And it, too, hi-jacks my M-o!

Happy fiddling
--
Tomas



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-05 15:55 diff-goto-source hi-jacks my M-o Tomas Nordin
@ 2020-07-05 20:39 ` Tomas Nordin
  2020-07-06  2:20 ` Dmitry Alexandrov
  1 sibling, 0 replies; 10+ messages in thread
From: Tomas Nordin @ 2020-07-05 20:39 UTC (permalink / raw)
  To: help-gnu-emacs

Tomas Nordin <tomasn@posteo.net> writes:

> PS: Whenever I fiddle with elisp I am completely in the hands of the
> package paredit. And it, too, hi-jacks my M-o!

Sorry, this is not true. I was thinking of M-s o (for occur) being taken
by M-s (paredit-splice-sexp).



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-05 15:55 diff-goto-source hi-jacks my M-o Tomas Nordin
  2020-07-05 20:39 ` Tomas Nordin
@ 2020-07-06  2:20 ` Dmitry Alexandrov
  2020-07-06 10:27   ` Tomas Nordin
  1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Alexandrov @ 2020-07-06  2:20 UTC (permalink / raw)
  To: Tomas Nordin; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 584 bytes --]

Tomas Nordin <tomasn@posteo.net> wrote:
> Anyway, I discovered that one of my favorite custom key-bindings, M-o, which I use for other-window, was hi-jacked. It was hi-jacked to run the command `diff-goto-source'.

> And if one is to be voted away, I vote for my precious M-o to be left alone.

	(define-minor-mode my-precious-keys-mode "" t)
	
	(defvar my-precious-keys-map (make-sparse-keymap))
	
	(add-to-list 'emulation-mode-map-alists
	             (list (cons 'my-precious-keys-mode my-precious-keys-map)))
	
        (define-key my-precious-keys-map (kbd "M-o") #'other-window)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-06  2:20 ` Dmitry Alexandrov
@ 2020-07-06 10:27   ` Tomas Nordin
  2020-07-06 19:37     ` Dmitry Alexandrov
  0 siblings, 1 reply; 10+ messages in thread
From: Tomas Nordin @ 2020-07-06 10:27 UTC (permalink / raw)
  To: Dmitry Alexandrov; +Cc: help-gnu-emacs

Dmitry Alexandrov <dag@gnui.org> writes:

> Tomas Nordin <tomasn@posteo.net> wrote:
>> Anyway, I discovered that one of my favorite custom key-bindings, M-o, which I use for other-window, was hi-jacked. It was hi-jacked to run the command `diff-goto-source'.
>
>> And if one is to be voted away, I vote for my precious M-o to be left alone.
>
> 	(define-minor-mode my-precious-keys-mode "" t)
> 	
> 	(defvar my-precious-keys-map (make-sparse-keymap))
> 	
> 	(add-to-list 'emulation-mode-map-alists
> 	             (list (cons 'my-precious-keys-mode my-precious-keys-map)))
> 	
>         (define-key my-precious-keys-map (kbd "M-o") #'other-window)

OK, tried it and it works, thanks. I tag it for possible use. The good
ol'

define-dummy-mode-and-dummy-key-map-and-add-them-to-emulation-mode-map-alists-and-finally-add-precious-binding-to-dummy-map

technique :)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-06 10:27   ` Tomas Nordin
@ 2020-07-06 19:37     ` Dmitry Alexandrov
  2020-07-06 20:07       ` Tomas Nordin
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Alexandrov @ 2020-07-06 19:37 UTC (permalink / raw)
  To: Tomas Nordin; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

Tomas Nordin <tomasn@posteo.net> wrote:
> Dmitry Alexandrov <dag@gnui.org> writes:
>> Tomas Nordin <tomasn@posteo.net> wrote:
>>> And if one is to be voted away, I vote for my precious M-o to be left alone.
>>
>> 	(define-minor-mode my-precious-keys-mode "" t)
>> 	(defvar my-precious-keys-map (make-sparse-keymap))
>> 	(add-to-list 'emulation-mode-map-alists
>> 	             (list (cons 'my-precious-keys-mode my-precious-keys-map)))
>>         (define-key my-precious-keys-map (kbd "M-o") #'other-window)

> define-dummy-mode-and-dummy-key-map-…

I am not sure, what ‘dummy’ is supposed to mean here?  Minor mode is fully functional, that is you are free to disable and reenable it at will:

        (define-key global-map (kbd "<C-pause>") #'my-precious-keys-mode)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-06 19:37     ` Dmitry Alexandrov
@ 2020-07-06 20:07       ` Tomas Nordin
  2020-07-06 21:46         ` Dmitry Alexandrov
  0 siblings, 1 reply; 10+ messages in thread
From: Tomas Nordin @ 2020-07-06 20:07 UTC (permalink / raw)
  To: Dmitry Alexandrov; +Cc: help-gnu-emacs

Dmitry Alexandrov <dag@gnui.org> writes:

> Tomas Nordin <tomasn@posteo.net> wrote:
>> Dmitry Alexandrov <dag@gnui.org> writes:
>>> Tomas Nordin <tomasn@posteo.net> wrote:
>>>> And if one is to be voted away, I vote for my precious M-o to be left alone.
>>>
>>> 	(define-minor-mode my-precious-keys-mode "" t)
>>> 	(defvar my-precious-keys-map (make-sparse-keymap))
>>> 	(add-to-list 'emulation-mode-map-alists
>>> 	             (list (cons 'my-precious-keys-mode my-precious-keys-map)))
>>>         (define-key my-precious-keys-map (kbd "M-o") #'other-window)
>
>> define-dummy-mode-and-dummy-key-map-…
>
> I am not sure, what ‘dummy’ is supposed to mean here?  Minor mode is fully functional, that is you are free to disable and reenable it at will:

I think I sort of tried to be funny, based on that the mode was made up
just to keep a key binding available in all situations. And that the
trickery with the key-maps is hard to follow for me.

I got the impression that it sufficed to evaluate the forms, I mean, I
didn't say, M-x my-precious-keys-mode .



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-06 20:07       ` Tomas Nordin
@ 2020-07-06 21:46         ` Dmitry Alexandrov
  2020-12-27 15:09           ` Tomas Nordin
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Alexandrov @ 2020-07-06 21:46 UTC (permalink / raw)
  To: Tomas Nordin; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

Tomas Nordin <tomasn@posteo.net> wrote:
> Dmitry Alexandrov <dag@gnui.org> writes:
>> I am not sure, what ‘dummy’ is supposed to mean here?  Minor mode is fully functional, that is you are free to disable and reenable it at will:
>
> I think I sort of tried to be funny, based on that the mode was made up just to keep a key binding available in all situations.

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.

> 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

> I got the impression that it sufficed to evaluate the forms, I mean, I didn't say, M-x my-precious-keys-mode .

>>>> 	(define-minor-mode my-precious-keys-mode "" t)

| (define-minor-mode MODE DOC &optional INIT-VALUE LIGHTER KEYMAP &rest BODY)
|
| ‹…›
|
| Optional INIT-VALUE is the initial value of the mode’s variable.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-07-06 21:46         ` Dmitry Alexandrov
@ 2020-12-27 15:09           ` Tomas Nordin
  2020-12-27 17:29             ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Tomas Nordin @ 2020-12-27 15:09 UTC (permalink / raw)
  To: Dmitry Alexandrov; +Cc: help-gnu-emacs

Dmitry Alexandrov <dag@gnui.org> writes:

> Tomas Nordin <tomasn@posteo.net> wrote:
>> Dmitry Alexandrov <dag@gnui.org> writes:
>>> I am not sure, what ‘dummy’ is supposed to mean here?  Minor mode is fully functional, that is you are free to disable and reenable it at will:
>>
>> I think I sort of tried to be funny, based on that the mode was made up just to keep a key binding available in all situations.
>
> 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)

Thanks
--
Tomas



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-12-27 15:09           ` Tomas Nordin
@ 2020-12-27 17:29             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-12-28 16:41               ` Tomas Nordin
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-12-27 17:29 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: diff-goto-source hi-jacks my M-o
  2020-12-27 17:29             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-12-28 16:41               ` Tomas Nordin
  0 siblings, 0 replies; 10+ messages in thread
From: Tomas Nordin @ 2020-12-28 16:41 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-12-28 16:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-05 15:55 diff-goto-source hi-jacks my M-o Tomas Nordin
2020-07-05 20:39 ` Tomas Nordin
2020-07-06  2:20 ` Dmitry Alexandrov
2020-07-06 10:27   ` Tomas Nordin
2020-07-06 19:37     ` Dmitry Alexandrov
2020-07-06 20:07       ` Tomas Nordin
2020-07-06 21:46         ` Dmitry Alexandrov
2020-12-27 15:09           ` Tomas Nordin
2020-12-27 17:29             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-28 16:41               ` Tomas Nordin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).