emacs-devel
[Top][All Lists]
Advanced

[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: Mon, 25 Oct 2021 21:59:06 +0200

>>>>> On Mon, 25 Oct 2021 14:08:42 -0400, Stefan Monnier 
>>>>> <monnier@iro.umontreal.ca> said:

    Stefan> Juri Linkov [2021-10-25 20:54:03] wrote:
    >>>>> BTW, I tried using 'substitute-command-keys' to do this, since itʼs
    >>>>> more elegant, but it gave an unusual result for undo:
    >>>>> 
    >>>>> (substitute-command-keys "\\<undo-repeat-map>\\[undo]")
    >>>>> =>#("C-x u" 0 5
    >>>>> (font-lock-face help-key-binding face help-key-binding))
    >>>> 
    >>>> That looks like a bug to me.
    >>> 
    >>> This is due to :advertised-binding.
    >> 
    >> Maybe 'where-is-internal' should check if the map contains
    >> the advertised binding, only then return it?

    Stefan> The \\<...> doesn't override all other maps, so the `undo` command 
is
    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> But I agree that maybe `where-is-internal` could be told here to 
give
    Stefan> precedence to bindings found in the \\<...> 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?

diff --git a/lisp/help.el b/lisp/help.el
index 7e2e492a36..38ecde7f8f 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 (list global-map) 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 (list global-map) 
t)))))
                   (if (not key)
                       ;; Function is not on any key.
                       (let ((op (point)))


Otherwise, extending 'substitute-command-keys' to allow '\(map)' to
mean "look only in map" is fairly trivial as well, but I donʼt see why
weʼd want to add more syntax when we could fix the existing one.

Robert
-- 



reply via email to

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