From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21329: 25.0.50; Flyspell minor mode produces weird effects on keyboard macros Date: Mon, 24 Aug 2015 17:39:09 +0300 Message-ID: <83io84hhte.fsf@gnu.org> References: <877fom5i9z.fsf@openmailbox.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Trace: ger.gmane.org 1440431808 19782 80.91.229.3 (24 Aug 2015 15:56:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Aug 2015 15:56:48 +0000 (UTC) Cc: 21329@debbugs.gnu.org To: Mark Karpov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 24 17:56:39 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZTu6w-0000rv-Fn for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Aug 2015 17:56:38 +0200 Original-Received: from localhost ([::1]:54126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTu6v-0003k4-Tt for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Aug 2015 11:56:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTsuu-0006SR-Dp for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2015 10:40:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTsup-00079w-Dm for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2015 10:40:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTsup-00079q-B9 for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2015 10:40:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZTsup-0008GS-3E for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2015 10:40:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Aug 2015 14:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21329 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21329-submit@debbugs.gnu.org id=B21329.144042716431719 (code B ref 21329); Mon, 24 Aug 2015 14:40:02 +0000 Original-Received: (at 21329) by debbugs.gnu.org; 24 Aug 2015 14:39:24 +0000 Original-Received: from localhost ([127.0.0.1]:37058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZTsuC-0008FW-1Y for submit@debbugs.gnu.org; Mon, 24 Aug 2015 10:39:24 -0400 Original-Received: from mtaout24.012.net.il ([80.179.55.180]:59384) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZTsuA-0008FO-21 for 21329@debbugs.gnu.org; Mon, 24 Aug 2015 10:39:23 -0400 Original-Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0NTL00L00BYXWB00@mtaout24.012.net.il> for 21329@debbugs.gnu.org; Mon, 24 Aug 2015 17:31:23 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NTL00GMICCBP670@mtaout24.012.net.il>; Mon, 24 Aug 2015 17:31:23 +0300 (IDT) In-reply-to: <877fom5i9z.fsf@openmailbox.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:105768 Archived-At: > From: Mark Karpov > 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))