[Top][All Lists]

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

Re: bug#49265: [External] : bug#49265: 28.0.50; repeat mode feature requ

From: Robert Pluim
Subject: Re: bug#49265: [External] : bug#49265: 28.0.50; repeat mode feature request
Date: Tue, 26 Oct 2021 12:06:28 +0200

>>>>> On Mon, 25 Oct 2021 16:57:19 -0400, Stefan Monnier 
>>>>> <monnier@iro.umontreal.ca> said:

    Stefan> The \\<...> doesn't override all other maps, so the `undo` command 
    Stefan> still found to be bound to `C-x u` in the global map.
    >> Right. I think it should look *only* in the specified map, otherwise
    >> what's the point of specifying it?

    Stefan> The common case is to specify the keymap that will likely be active 
    Stefan> the command is used.

OK, so I guess that pleads for a fallback to the current behaviour.

    Stefan> Maybe you're right that we shouldn't look elsewhere, but I'd be
    Stefan> surprised if there aren't docstrings that rely on the current 

That may be true, and I canʼt think of an easy way of finding them.

    Stefan> But I agree that maybe `where-is-internal` could be told
    Stefan> here to give precedence to bindings found in the
    Stefan> \\<...> map.
    >> `where-is-internal' is not the issue. If you pass it (list keymap) it
    >> will look only in 'keymap'. But substitute-command-keys passes it
    >> 'keymap', which allows it to look in the global map as well.
    >> Perhaps something like this?

    Stefan> Sounds about right, tho it disregards other keymaps than `keymap` 
    Stefan> `global-map`.  Maybe we should do

    Stefan>     (or (where-is-internal fun (list keymap) t)
    Stefan>         (where-is-internal fun nil t))

    Stefan> instead to avoid this problem.

I think the minimal change from the current behaviour would be this,
since 'keymap' starts out as 'overriding-local-map', but then can get
set to 'nil' or a specific keymap based on the contents of the string.

Or we could add an optional argument to 'substitute-command-keys' to
mean 'only look in MAPVAR'.

diff --git a/lisp/help.el b/lisp/help.el
index 9666ef9805..55e58e20e5 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1124,7 +1124,9 @@ substitute-command-keys
                 (delete-char 2)
                 (let* ((fun (intern (buffer-substring (point) (1- end-point))))
                        (key (with-current-buffer orig-buf
-                              (where-is-internal fun keymap t))))
+                              (or
+                               (where-is-internal fun (list keymap) t)
+                               (where-is-internal fun keymap t)))))
                   ;; If this a command remap, we need to follow it.
                   (when (and (vectorp key)
                              (> (length key) 1)
@@ -1132,7 +1134,9 @@ substitute-command-keys
                              (symbolp (aref key 1)))
                     (setq fun (aref key 1))
                     (setq key (with-current-buffer orig-buf
-                                (where-is-internal fun keymap t))))
+                                (or
+                                 (where-is-internal fun (list keymap) t)
+                                 (where-is-internal fun keymap t)))))
                   (if (not key)
                       ;; Function is not on any key.
                       (let ((op (point)))


reply via email to

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