From: Eli Zaretskii <eliz@gnu.org>
To: Leo <used_to_be_leo@yahoo.com>
Cc: 20454@debbugs.gnu.org
Subject: bug#20454: 24.4; Emacs keyboard macros not working correctly
Date: Wed, 29 Apr 2015 19:51:07 +0300 [thread overview]
Message-ID: <83ioceubd0.fsf@gnu.org> (raw)
In-Reply-To: <982083367.276894.1430282967819.JavaMail.yahoo@mail.yahoo.com>
> Date: Wed, 29 Apr 2015 04:49:27 +0000 (UTC)
> From: Leo <used_to_be_leo@yahoo.com>
>
> (progn
> (setq f5-key-map (make-sparse-keymap "F5-Key-prefix"))
> (define-key global-map [f5] f5-key-map)
>
> (define-key f5-key-map [(g)] 'forward-word)
> (define-key f5-key-map [f6] 'forward-word)
> (define-key f5-key-map [kp-4] 'forward-word)
> (define-key f5-key-map [right] 'forward-word)
> )
>
> Case This key
> # sequence Produces this result
> ---- -------- --------------------
> 1 <f5> <g> moves cursor forward by 1 word
> 2 <f5> <f6> moves cursor forward by 1 word
> 3 <f5> <kp-4> moves cursor forward by 1 word
> 4 <f5> <right> moves cursor forward by 1 word
>
> Case Define macro by using Result when pressing
> # this key sequence: <f4> again:
> ---- --------------------- --------------------
> 11 <f3> <f5> <g> <f4> moves cursor forward by 1 word
> 12 <f3> <f5> <f6> <f4> nothing
> 13 <f3> <f5> <kp-4> <f4> nothing
> 14 <f3> <f5> <right> <f4> nothing
> 15 <f3> <f5> <f6> <right> <f4> moves cursor forward by 1 word
>
> Cases #12, #13, and #14 do not work at all. Nothing happens, and
> there is no error message.
If you display the macro after defining it, e.g. with
kmacro-view-macro, or even simply evaluate kmacro-ring, you will see
that only f5 gets recorded there, the following function keys don't.
Only in the "f5 g" case will you see the 'g' in the macro. That's why
the macro cannot be executed: there's only a prefix key there.
This happens because of the following trick we play in
read_char_minibuf_menu_prompt, which is a function we call whenever a
key we read is a prefix key:
/* Make believe it's not a keyboard macro in case the help char
is pressed. Help characters are not recorded because menu prompting
is not used on replay. */
orig_defn_macro = KVAR (current_kboard, defining_kbd_macro);
kset_defining_kbd_macro (current_kboard, Qnil);
do
obj = read_char (commandflag, Qnil, Qt, 0, NULL);
while (BUFFERP (obj));
kset_defining_kbd_macro (current_kboard, orig_defn_macro);
if (!INTEGERP (obj) || XINT (obj) == -2)
return obj;
If 'obj' that we read is not a character (as is the case with f6 and
any other function key -- they are symbols), we return here without
recording the key in the macro, as we disabled that recording by
temporarily setting defining_kbd_macro to nil.
The trivial patch below fixes this, but before pushing it, I'd like
Stefan and others to eyeball this, in case there be dragons.
Btw, this has been broken "forever": I see it in Emacs 21.4.
--- src/keyboard.c~0 2015-04-26 07:42:05 +0300
+++ src/keyboard.c 2015-04-29 16:27:42 +0300
@@ -8708,7 +8708,11 @@ read_char_minibuf_menu_prompt (int comma
kset_defining_kbd_macro (current_kboard, orig_defn_macro);
if (!INTEGERP (obj) || XINT (obj) == -2)
- return obj;
+ {
+ if (!NILP (KVAR (current_kboard, defining_kbd_macro)))
+ store_kbd_macro_char (obj);
+ return obj;
+ }
if (! EQ (obj, menu_prompt_more_char)
&& (!INTEGERP (menu_prompt_more_char)
next prev parent reply other threads:[~2015-04-29 16:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 4:49 bug#20454: 24.4; Emacs keyboard macros not working correctly Leo
2015-04-29 16:51 ` Eli Zaretskii [this message]
2015-05-08 9:16 ` Eli Zaretskii
2015-05-08 17:44 ` Stefan Monnier
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=83ioceubd0.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=20454@debbugs.gnu.org \
--cc=used_to_be_leo@yahoo.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).