* bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
@ 2017-11-22 16:27 Drew Adams
2017-11-23 0:13 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2017-11-22 16:27 UTC (permalink / raw)
To: 29399
emacs -Q
C-x ( C-f C-f C-f C-x )
M-: (global-set-key (kbd "C-o") 'execute-extended-command)
M-: (global-set-key (kbd "M-x") 'forward-char)
C-o edit-kbd-macro RET
The prompt says:
"Keyboard macro to edit (C-x e, M-x, C-h l, or keys):"
It should use \\[execute-extended-command] and thus say:
"Keyboard macro to edit (C-x e, C-o, C-h l, or keys):"
This prompt is anyway not clear. The command should instead accept
a key sequence that shows more complete info/help, and the prompt should
just mention that key sequence.
In GNU Emacs 26.0.90 (build 3, x86_64-w64-mingw32)
of 2017-10-13 built on LAPHROAIG
Repository revision: 906224eba147bdfc0514090064e8e8f53160f1d4
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Defining kbd macro...
Keyboard macro defined
Quit [2 times]
execute-extended-command
forward-char
Quit
Configured using:
'configure --without-dbus --host=x86_64-w64-mingw32
--without-compress-install 'CFLAGS=-O2 -static -g3''
Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS
Important settings:
value of $LANG: ENU
locale-coding-system: cp1252
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
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
0 siblings, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2017-11-23 0:13 UTC (permalink / raw)
To: Drew Adams; +Cc: 29399
Drew Adams <drew.adams@oracle.com> writes:
> emacs -Q
>
> C-x ( C-f C-f C-f C-x )
>
> M-: (global-set-key (kbd "C-o") 'execute-extended-command)
> M-: (global-set-key (kbd "M-x") 'forward-char)
>
> C-o edit-kbd-macro RET
>
> The prompt says:
>
> "Keyboard macro to edit (C-x e, M-x, C-h l, or keys):"
>
> It should use \\[execute-extended-command] and thus say:
>
> "Keyboard macro to edit (C-x e, C-o, C-h l, or keys):"
>
> This prompt is anyway not clear. The command should instead accept
> a key sequence that shows more complete info/help, and the prompt should
> just mention that key sequence.
I'm not sure if this would help so much for the OP's case [1], which is
more like:
(defun my/execute-extended-command () ; actually `smex'[2] in OP's case
(interactive)
(call-interactively 'execute-extended-command))
(global-set-key (kbd "M-x") 'my/execute-extended-command)
With that kind of config, I get
Keyboard macro to edit (C-x e, <execute>, C-h l, or keys):
I have no idea how to produce <execute> on my keyboard. If also do
(define-key global-map [execute] 'ignore)
I get
Keyboard macro to edit (C-x e, <menu>, C-h l, or keys):
which I know is the "Menu key" [3]. But personally, I disable the <menu>
key also, because otherwise I sometimes accidentally lean on it,
producing deeply nested minibuffer prompt which is annoying.
(define-key global-map [menu] 'ignore)
Which ends up with this:
"Keyboard macro to edit (C-x e, M-x execute-extended-command, C-h l, or keys):"
[1]: https://emacs.stackexchange.com/questions/37017/unable-to-supply-macro-name-to-edit-kbd-macro-when-m-x-is-bound-to-smex
[2]: https://github.com/nonsequitur/smex
[3]: https://en.wikipedia.org/wiki/Menu_key
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
2017-11-23 0:13 ` Noam Postavsky
@ 2017-11-23 1:15 ` Drew Adams
2017-11-27 0:55 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2017-11-23 1:15 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 29399
> > It should use \\[execute-extended-command] and thus say:
> > "Keyboard macro to edit (C-x e, C-o, C-h l, or keys):"
>
> I'm not sure if this would help so much for the OP's case [1], which is
> more like:
>
> (defun my/execute-extended-command () ; actually `smex'[2] in OP's
> case
> (interactive)
> (call-interactively 'execute-extended-command))
> (global-set-key (kbd "M-x") 'my/execute-extended-command)
>
> With that kind of config, I get
> Keyboard macro to edit (C-x e, <execute>, C-h l, or keys):
Well, that's at least correct. ;-) The problem is that
there is no way to tell Emacs which binding to show.
I suppose you could use `set-advertised-calling-convention',
but a user shouldn't need to bother (or know about)
that, here.
This is a general Emacs gotcha/problem. It's not the
problem of this bug report.
Except for this, which I also said:
>> This prompt is anyway not clear. The command should
>> instead accept a key sequence that shows more complete
>> info/help, and the prompt should just mention that key
>> sequence.
That's the right thing to do. The prompt shouldn't
try to mention lots of keys. That's only good when
the command itself will actually read keys - it then
knows just which keys to mention: those it uses.
This command should mention only (at most) a help key
that it provides (would provide). Using that help key
(at that time - while prompted) would show whatever
help we want to show, including mentioning any keys
or commands, if appropriate.
Of course that help could itself fall into the problem
of showing a key such as `<execute>' or `<menu>'. But
as I said, that's a general problem.
It could choose to mention only command names, i.e.,
not use \\[...].
> I have no idea how to produce <execute> on my keyboard.
You probably cannot.
> Which ends up with this:
>
> "Keyboard macro to edit (C-x e, M-x execute-extended-command, C-h l,
> or keys):"
And that's as good as it could get. The command can
reasonably assume that you can use `execute-extended-command'
(which you can, I think, regardless of whether `M-x' is
bound to `smex'). The command cannot know that a user
always wants to use `smex' instead of `M-x'.
UNLESS the user (or `smex-mode' or whatever) actually
substitutes `smex' for `execute-extended-command' keys,
using remapping or using `substitute-key-definition'.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
2017-11-23 1:15 ` Drew Adams
@ 2017-11-27 0:55 ` Noam Postavsky
2017-12-02 14:54 ` Noam Postavsky
0 siblings, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2017-11-27 0:55 UTC (permalink / raw)
To: Drew Adams; +Cc: 29399
[-- 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#29399: 26.0.90; `edit-kbd-macro' has bad prompt
2017-11-27 0:55 ` Noam Postavsky
@ 2017-12-02 14:54 ` Noam Postavsky
0 siblings, 0 replies; 5+ messages in thread
From: Noam Postavsky @ 2017-12-02 14:54 UTC (permalink / raw)
To: Drew Adams; +Cc: 29399
tags 29399 fixed
close 29399 26.1
quit
Noam Postavsky <npostavs@users.sourceforge.net> writes:
> The following patch updates the prompt, and also the checks
> non-remapped key bindings for the key sequence entered.
Pushed to emacs-26.
[1: 98ca7d5f26]: 2017-12-02 09:35:44 -0500
Improve edit-kbd-macro prompting in case of remapped keys (Bug#29399)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=98ca7d5f26f5bdde44864c7f24dafb6725fca09f
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-12-02 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-12-02 14:54 ` Noam Postavsky
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.