all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Ergus <spacibba@aol.com>, Stefan Kangas <stefan@marxist.se>,
	emacs-devel <emacs-devel@gnu.org>,
	Andreas Schwab <schwab@linux-m68k.org>,
	Juri Linkov <juri@linkov.net>, Drew Adams <drew.adams@oracle.com>
Subject: Re: bug#49265: [External] : bug#49265: 28.0.50; repeat mode feature request
Date: Mon, 25 Oct 2021 21:59:06 +0200	[thread overview]
Message-ID: <87tuh4ri45.fsf@gmail.com> (raw)
In-Reply-To: <jwvwnm1x9ly.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 25 Oct 2021 14:08:42 -0400")

>>>>> 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	other threads:[~2021-10-25 19:59 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87czs53aei.fsf.ref@aol.com>
2021-06-28 22:13 ` bug#49265: 28.0.50; repeat mode feature request Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-29  8:38   ` Juri Linkov
2021-06-29 15:25     ` bug#49265: [External] : " Drew Adams
2021-06-29 20:37       ` Juri Linkov
2021-06-29 21:28         ` Drew Adams
2021-06-30  9:50           ` Robert Pluim
2021-06-30 15:10             ` Drew Adams
2021-06-29 20:36     ` Juri Linkov
2021-06-29 21:33       ` bug#49265: [External] : " Drew Adams
2021-06-30  9:59         ` Robert Pluim
2021-06-30 15:11           ` Drew Adams
2021-06-30 19:56             ` Juri Linkov
2021-06-30 21:15               ` Drew Adams
2021-07-04 20:31                 ` Juri Linkov
2021-07-04 21:09                   ` Drew Adams
2021-07-05  9:48                     ` Robert Pluim
2021-07-05 14:53                       ` Drew Adams
2021-07-05 21:04                       ` Juri Linkov
2021-07-06  1:31                         ` Drew Adams
2021-07-06 17:54                           ` Juri Linkov
2021-07-06 18:25                             ` Drew Adams
2021-06-30 19:55           ` Juri Linkov
     [not found]             ` <87r1cdz72i.fsf@gmail.com>
     [not found]               ` <875ytn8ufp.fsf@mail.linkov.net>
2021-10-24 14:20                 ` Robert Pluim
2021-10-24 19:12                   ` Juri Linkov
2021-10-24 20:02                     ` Robert Pluim
2021-10-25  7:41                       ` Juri Linkov
2021-10-25  8:55                         ` Robert Pluim
2021-10-25  9:21                           ` Stefan Kangas
2021-10-25  9:59                             ` Robert Pluim
2021-10-25 10:14                             ` Andreas Schwab
2021-10-25 17:54                               ` Juri Linkov
2021-10-25 18:08                                 ` Stefan Monnier
2021-10-25 19:59                                   ` Robert Pluim [this message]
2021-10-25 20:57                                     ` Stefan Monnier
2021-10-26 10:06                                       ` Robert Pluim
2021-10-26 10:25                                         ` Robert Pluim
2021-10-26 12:39                                         ` Stefan Monnier
2021-10-26 12:46                                           ` Robert Pluim
2021-10-25 17:58                           ` Juri Linkov
2021-11-15 17:51             ` Juri Linkov
2021-11-15 18:21               ` Juri Linkov
2021-11-17 17:01                 ` Juri Linkov
2021-11-18 10:16                   ` Robert Pluim
2021-11-18 17:44                     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuh4ri45.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --cc=monnier@iro.umontreal.ca \
    --cc=schwab@linux-m68k.org \
    --cc=spacibba@aol.com \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.