unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Functionality of overriding-local-map
@ 2022-01-06  9:49 xenodasein--- via Emacs development discussions.
  2022-01-06 19:16 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: xenodasein--- via Emacs development discussions. @ 2022-01-06  9:49 UTC (permalink / raw)
  To: emacs-devel

At first I thought I made a mistake and asked about this on help list.

https://lists.gnu.org/archive/html/help-gnu-emacs/2022-01/msg00014.html
https://lists.gnu.org/archive/html/help-gnu-emacs/2022-01/msg00018.html
https://lists.gnu.org/archive/html/help-gnu-emacs/2022-01/msg00019.html
https://lists.gnu.org/archive/html/help-gnu-emacs/2022-01/msg00022.html

What happened was I had the wrong assumption on how keymaps work,
caused by dated documentation.

According to "(elisp) Searching Keymaps":

(or (if overriding-terminal-local-map
             (FIND-IN overriding-terminal-local-map))
    (if overriding-local-map
             (FIND-IN overriding-local-map)
           (or (FIND-IN (get-char-property (point) 'keymap))
               (FIND-IN-ANY emulation-mode-map-alists)
               (FIND-IN-ANY minor-mode-overriding-map-alist)
               (FIND-IN-ANY minor-mode-map-alist)
               (if (get-text-property (point) 'local-map)
                   (FIND-IN (get-char-property (point) 'local-map))
                 (FIND-IN (current-local-map)))))
    (FIND-IN (current-global-map)))

When both overriding-terminal-local-map and overriding-local-map
are active, key lookup should be done in these three maps:
o-t-l-m   ->   o-l-m   ->   global-map

But this is wrong, the correct behavior is what
"(elisp) Controlling Active Maps" explains, by contradicting the former:

-- Variable: overriding-terminal-local-map
     If non-‘nil’, this variable holds a keymap to use instead of
     ‘overriding-local-map’, the buffer’s local keymap, text property or
     overlay keymaps, and all the minor mode keymaps.

If o-t-l-m is active, o-l-m is out of the equation.

Stefan M:
> The code says:
>
>  if (!NILP (olp)
>      /* The doc said that overriding-terminal-local-map should
>         override overriding-local-map.  The code used them both,
>         but it seems clearer to use just one.  rms, jan 2005.  */
>      && NILP (KVAR (current_kboard, Voverriding_terminal_local_map))
>      && !NILP (Voverriding_local_map))
>    keymaps = Fcons (Voverriding_local_map, keymaps);
>
> It seems the doc isn't clear cut and there's not much more info to
> accompany this commit d64cdc59724b7caca47913d5beb2b4a54f7b7c91.
> I you want to change this behavior (or fix/improve the doc)
> I recommend you `M-x report-emacs-bug`.

I encountered this while using o-l-m as a buffer local map that
overrides other buffer local maps, as it is intended.  o-t-l-m
does not do this; the latter (current) behavior results in a
loss of functionality.

In my case, it prevented the use of universal-argument with commands
in overriding-local-map.  As universal-argument uses set-transient-map,
if next command isn't bound in universal-argument-map, it is looked up
in next active keymap (current-global-map).  IMO, what should happen is
that the next active keymap be overriding-local-map, as per
"(elisp) Searching Keymaps."




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

* Re: Functionality of overriding-local-map
@ 2022-01-06 10:19 xenodasein--- via Emacs development discussions.
  0 siblings, 0 replies; 3+ messages in thread
From: xenodasein--- via Emacs development discussions. @ 2022-01-06 10:19 UTC (permalink / raw)
  To: xenodasein; +Cc: emacs-devel

Correction:
As universal-argument uses set-transient-map, if next command isn't
bound in universal-argument-map, it is looked up in next active keymap
(a next buffer local map, not current-global-map.  Otherwise,  commands
in local major mode maps couldn't use universal-argument too).




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

* Re: Functionality of overriding-local-map
  2022-01-06  9:49 xenodasein--- via Emacs development discussions.
@ 2022-01-06 19:16 ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2022-01-06 19:16 UTC (permalink / raw)
  To: xenodasein; +Cc: emacs-devel

>>  if (!NILP (olp)
>>      /* The doc said that overriding-terminal-local-map should
>>         override overriding-local-map.  The code used them both,
>>         but it seems clearer to use just one.  rms, jan 2005.  */
>>      && NILP (KVAR (current_kboard, Voverriding_terminal_local_map))
>>      && !NILP (Voverriding_local_map))
>>    keymaps = Fcons (Voverriding_local_map, keymaps);
>>
>> It seems the doc isn't clear cut and there's not much more info to
>> accompany this commit d64cdc59724b7caca47913d5beb2b4a54f7b7c91.
>> I you want to change this behavior (or fix/improve the doc)
>> I recommend you `M-x report-emacs-bug`.
>
> I encountered this while using o-l-m as a buffer local map that
> overrides other buffer local maps, as it is intended.  o-t-l-m
> does not do this; the latter (current) behavior results in a
> loss of functionality.
>
> In my case, it prevented the use of universal-argument with commands
> in overriding-local-map.  As universal-argument uses set-transient-map,
> if next command isn't bound in universal-argument-map, it is looked up
> in next active keymap (current-global-map).  IMO, what should happen is
> that the next active keymap be overriding-local-map, as per
> "(elisp) Searching Keymaps."

This bites us in other places too.  Please see a possible solution in
https://lists.gnu.org/archive/html/emacs-devel/2021-05/msg00490.html



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

end of thread, other threads:[~2022-01-06 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 10:19 Functionality of overriding-local-map xenodasein--- via Emacs development discussions.
  -- strict thread matches above, loose matches on Subject: below --
2022-01-06  9:49 xenodasein--- via Emacs development discussions.
2022-01-06 19:16 ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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