unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 27470@debbugs.gnu.org
Subject: bug#27470: 26.0.50; this-command-keys and interactive input
Date: Sat, 24 Jun 2017 10:01:17 +0300	[thread overview]
Message-ID: <831sq9vphe.fsf@gnu.org> (raw)
In-Reply-To: <87y3siapuw.fsf@drachen> (message from Michael Heerdegen on Sat,  24 Jun 2017 07:58:47 +0200)

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Sat, 24 Jun 2017 07:58:47 +0200
> 
> (defun test (arg)
>   (interactive (list (read-from-minibuffer "Input: ")))
>   (message "%S" (cons this-command (this-command-keys)))
>   arg)
> 
> (global-set-key [f12] #'test)
> 
> where f12 stands for some random key sequence.
> 
> Hit f12 and give any input.  I get the following message:
> 
> (test . "^M")
> 
> I would expect (test . f12).

This happens because read-from-minibuffer enters recursive-edit, and
we don't preserve this-command-keys across recursive-edit invocations.

This has been Emacs behavior since forever.

The patch below seems to fix this, but I have no idea what it could
break, given how old this behavior is.  So if we are to accept this,
I'd like to have a few people step forward and run with the change for
a month or so, to see there are no adverse effects.  We've been burnt
several times lately by changes in keyboard-input stuff that broke
subtle but very useful features.

Thanks.

diff --git a/src/minibuf.c b/src/minibuf.c
index 1bbe276..5617941 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -497,6 +497,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
 				  Fcons (Vminibuffer_history_position,
 					 Fcons (Vminibuffer_history_variable,
 						minibuf_save_list))))));
+  minibuf_save_list
+    = Fcons (Fthis_command_keys_vector (), minibuf_save_list);
 
   record_unwind_protect_void (read_minibuf_unwind);
   minibuf_level++;
@@ -836,6 +838,11 @@ read_minibuf_unwind (void)
   Fset_buffer (XWINDOW (window)->contents);
 
   /* Restore prompt, etc, from outer minibuffer level.  */
+  Lisp_Object key_vec = Fcar (minibuf_save_list);
+  eassert (VECTORP (key_vec));
+  this_command_key_count = XFASTINT (Flength (key_vec));
+  this_command_keys = key_vec;
+  minibuf_save_list = Fcdr (minibuf_save_list);
   minibuf_prompt = Fcar (minibuf_save_list);
   minibuf_save_list = Fcdr (minibuf_save_list);
   minibuf_prompt_width = XFASTINT (Fcar (minibuf_save_list));





  reply	other threads:[~2017-06-24  7:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-24  5:58 bug#27470: 26.0.50; this-command-keys and interactive input Michael Heerdegen
2017-06-24  7:01 ` Eli Zaretskii [this message]
2017-06-25  5:53   ` Michael Heerdegen
2017-07-22  8:16   ` Eli Zaretskii
2017-07-23 15:44     ` Michael Heerdegen
2017-07-28 12:41       ` Eli Zaretskii
2017-06-24 13:15 ` 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=831sq9vphe.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=27470@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /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).