all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Mark Karpov <markkarpov@openmailbox.org>
Cc: 21329@debbugs.gnu.org
Subject: bug#21329: 25.0.50; Flyspell minor mode produces weird effects on keyboard macros
Date: Mon, 24 Aug 2015 17:39:09 +0300	[thread overview]
Message-ID: <83io84hhte.fsf@gnu.org> (raw)
In-Reply-To: <877fom5i9z.fsf@openmailbox.org>

> From: Mark Karpov <markkarpov@openmailbox.org>
> Date: Sun, 23 Aug 2015 17:57:44 +0600
> 
> This is really strange. Here is how to reproduce it in development
> version of Emacs:
> 
> 1. Start Emacs with ‘-Q’ flag.
> 
> 2. Enable ‘flyspell-mode’ (M-x flyspell-mode RET).
> 
> 3. Start recording keyboard macro with F3.
> 
> 4. Type (pick one of these, they all produce different effects):
> 
>    * abc
>    * prop_
> 
> 5. Finish recording of the keyboard macro with F4.
> 
> 6. Hit F4 again to run the macro.
> 
> If you chose “abc”, you will get:
> 
> abcabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbccabbcca
> 
> And in ‘*Messages*’:
> 
> For information about GNU Emacs and the GNU system, type C-h C-a.
> completing-read-default: Command attempted to use minibuffer while in minibuffer
> Quit

This is a very old problem, I see it in Emacs 22.

Here's a simple recipe to demonstrate what happens:

  emacs -Q

  Evaluate in *scratch*:

    (defun my-hook ()
      ""
      (sit-for 1))
    (add-hook 'post-command-hook 'my-hook t t)

  Now type "F3 abc F4 F4", and you will get the same problem as in the
  original report.  Type "C-x C-k n foo RET" followed by "M-x
  insert-kbd-macro RET", and you will see that the macro is defined as
  a vector that includes F4 at its end, which is the cause of the
  unexpected recursive invocation of the macro by F4.

The problem is that 'sit-for' calls 'read-event', and then "undoes"
that by pushing the events it read onto unread-command-events.  This
evidently messes up keyboard macro recording.  (It also runs afoul of
the recent changes in keyboard.c related to recording events, which
causes the characters to be duplicated in the macro.)

The following band-aid fixes the problem, but I will wait for The
Powers That Be to comment on this before pushing.  Or maybe we should
introduce an "unrecord-key" facility for use by code such as we have
in sit-for?

--- lisp/subr.el~	2015-08-05 12:26:16.000000000 +0300
+++ lisp/subr.el	2015-08-24 13:53:09.858014100 +0300
@@ -2276,7 +2276,8 @@
     t)
    ((input-pending-p t)
     nil)
-   ((<= seconds 0)
+   ((or (<= seconds 0)
+        defining-kbd-macro)
     (or nodisp (redisplay)))
    (t
     (or nodisp (redisplay))





  reply	other threads:[~2015-08-24 14:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23 11:57 bug#21329: 25.0.50; Flyspell minor mode produces weird effects on keyboard macros Mark Karpov
2015-08-24 14:39 ` Eli Zaretskii [this message]
2015-08-25 13:15   ` Stefan Monnier
2015-08-25 15:26     ` Eli Zaretskii
2015-08-25 16:31       ` Eli Zaretskii
2015-08-25 22:23         ` Stefan Monnier
2015-08-26  2:44           ` Eli Zaretskii
2015-08-28  1:33             ` Stefan Monnier
2015-08-28 13:28               ` Eli Zaretskii
2015-08-29 15:31                 ` Stefan Monnier
2015-08-29 16:22                   ` Eli Zaretskii
2015-08-30  2:06                     ` Stefan Monnier
2015-08-30  2:08                     ` 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

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

  git send-email \
    --in-reply-to=83io84hhte.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=21329@debbugs.gnu.org \
    --cc=markkarpov@openmailbox.org \
    /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.