unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Drew Adams <drew.adams@oracle.com>
Cc: 29399@debbugs.gnu.org
Subject: bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
Date: Sun, 26 Nov 2017 19:55:11 -0500	[thread overview]
Message-ID: <87efoko80g.fsf@users.sourceforge.net> (raw)
In-Reply-To: <cdd4aa51-648c-404a-9aea-88e8bffa95c0@default> (Drew Adams's message of "Wed, 22 Nov 2017 17:15:53 -0800 (PST)")

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

tags 29399 + patch
quit

Drew Adams <drew.adams@oracle.com> writes:

> UNLESS the user (or `smex-mode' or whatever) actually
> substitutes `smex' for `execute-extended-command' keys,
> using remapping or using `substitute-key-definition'.

Ah, I didn't realize before, but if you do

    (define-key global [remape execute-extended-command] 'smex)

then substitute-command-keys still shows M-x for
\\[execute-extended-command].  The following patch updates the prompt,
and also the checks non-remapped key bindings for the key sequence
entered.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 3156 bytes --]

From dec6f0ccf57ea590c199b6cdf39c6fe93d67d06b Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 26 Nov 2017 19:16:16 -0500
Subject: [PATCH] Improve edit-kbd-macro prompting in case of remapped keys
 (Bug#29399)

* lisp/edmacro.el (edit-kbd-macro): Use substitute-command-keys to
present the current bindings in the prompt.  Check the the
non-remapped binding of the entered key sequence as well.
---
 lisp/edmacro.el | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index b050f4d64c..dc840ef1f1 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -88,20 +88,26 @@ edmacro-original-buffer
 (defun edit-kbd-macro (keys &optional prefix finish-hook store-hook)
   "Edit a keyboard macro.
 At the prompt, type any key sequence which is bound to a keyboard macro.
-Or, type `C-x e' or RET to edit the last keyboard macro, `C-h l' to edit
-the last 300 keystrokes as a keyboard macro, or `\\[execute-extended-command]' to edit a macro by
-its command name.
+Or, type `\\[kmacro-end-and-call-macro]' or RET to edit the last
+keyboard macro, `\\[view-lossage]' to edit the last 300
+keystrokes as a keyboard macro, or `\\[execute-extended-command]'
+to edit a macro by its command name.
 With a prefix argument, format the macro in a more concise way."
-  (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP")
+  (interactive
+   (list (read-key-sequence (substitute-command-keys "Keyboard macro to edit \
+\(\\[kmacro-end-and-call-macro], \\[execute-extended-command], \\[view-lossage],\
+ or keys): "))
+         current-prefix-arg))
   (when keys
     (let ((cmd (if (arrayp keys) (key-binding keys) keys))
+          (cmd-noremap (when (arrayp keys) (key-binding keys nil t)))
 	  (mac nil) (mac-counter nil) (mac-format nil)
 	  kmacro)
       (cond (store-hook
 	     (setq mac keys)
 	     (setq cmd nil))
-	    ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro
-			     kmacro-end-or-call-macro kmacro-end-and-call-macro))
+	    ((or (memq cmd '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro))
+                 (memq cmd-noremap '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro))
 		 (member keys '("\r" [return])))
 	     (or last-kbd-macro
 		 (y-or-n-p "No keyboard macro defined.  Create one? ")
@@ -109,13 +115,14 @@ edit-kbd-macro
 	     (setq mac (or last-kbd-macro ""))
 	     (setq keys nil)
 	     (setq cmd 'last-kbd-macro))
-	    ((eq cmd 'execute-extended-command)
+	    ((memq 'execute-extended-command (list cmd cmd-noremap))
 	     (setq cmd (read-command "Name of keyboard macro to edit: "))
 	     (if (string-equal cmd "")
 		 (error "No command name given"))
 	     (setq keys nil)
 	     (setq mac (symbol-function cmd)))
-	    ((memq cmd '(view-lossage electric-view-lossage))
+	    ((or (memq cmd '(view-lossage electric-view-lossage))
+                 (memq cmd-noremap '(view-lossage electric-view-lossage)))
 	     (setq mac (recent-keys))
 	     (setq keys nil)
 	     (setq cmd 'last-kbd-macro))
-- 
2.11.0


  reply	other threads:[~2017-11-27  0:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 16:27 bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt Drew Adams
2017-11-23  0:13 ` Noam Postavsky
2017-11-23  1:15   ` Drew Adams
2017-11-27  0:55     ` Noam Postavsky [this message]
2017-12-02 14:54       ` Noam Postavsky

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87efoko80g.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=29399@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /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 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).