GNU bug report logs - #15126
24.3; kmacro-end-and-call-macro repeats macro multiple times following isearch-forward

Previous Next

Package: emacs;

Reported by: Simon Katz <nomiskatz <at> gmail.com>

Date: Sun, 18 Aug 2013 22:33:01 UTC

Severity: normal

Found in version 24.3

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15126 in the body.
You can then email your comments to 15126 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15126; Package emacs. (Sun, 18 Aug 2013 22:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon Katz <nomiskatz <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 18 Aug 2013 22:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Katz <nomiskatz <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3; kmacro-end-and-call-macro repeats macro multiple times
 following isearch-forward
Date: Sun, 18 Aug 2013 22:39:41 +0100
[Message part 1 (text/plain, inline)]
If I have a buffer with some text that is repeated several times and
do the following:
  - C-s <some text>  (isearch-forward)   to search for the repeated text
  - C-x (   (kmacro-start-macro)
  - Enter some new text
  - C-s C-s   to search again
  - C-x e  (kmacro-end-and-call-macro)
I get different behaviour in my old and new versions of Emacs.

In Emacs 24.2.1 and all previous versions I've used,
kmacro-end-and-call-macro calls the macro once more, and I can go
through the file making changes one at a time, and I can stop when I
want.

In Emacs 24.3.1, kmacro-end-and-call-macro calls the macro repeatedly
making changes to all the repeated text up to the end of the file.

Interestingly, if I define a similar keyboard macro that uses
next-error rather than isearch-forward I get my changes one at a time.

Is this some bizarre new behaviour for isearch-forward? Can I get the
old behaviour back?

Here's a precise recipe:

  /Applications/Emacs-24-3-1.app/Contents/MacOS/Emacs -Q

  Then at the start of the *scratch* buffer:

  C-s   e r   C-x (   x x x x   C-s C-s   C-x e

  Emacs makes multiple changes for the  C-x e.





In GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-13 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1138
Configured using:
 `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
 '--with-ns' 'build_alias=i686-apple-darwin'
 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.7
 -isystem
 /Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/
 -F/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks''

Important settings:
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
s-x M-x r e p <tab> o r t <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
kill-region: The mark is not set now, so there is no region
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-mode easymenu time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15126; Package emacs. (Mon, 19 Aug 2013 02:27:01 GMT) Full text and rfc822 format available.

Message #8 received at 15126 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Simon Katz <nomiskatz <at> gmail.com>, 15126 <at> debbugs.gnu.org
Subject: RE: bug#15126: 24.3; kmacro-end-and-call-macro repeats macro multiple
 times following isearch-forward
Date: Sun, 18 Aug 2013 19:26:03 -0700 (PDT)
> Here's a precise recipe:
>   /Applications/Emacs-24-3-1.app/Contents/MacOS/Emacs -Q
>   Then at the start of the *scratch* buffer:
>   C-s   e r   C-x (   x x x x   C-s C-s   C-x e
>   Emacs makes multiple changes for the  C-x e.

Confirmed in MS Windows builds.
Emacs 23.4 through Emacs 24.2 were OK.
Emacs 24.3 introduced the regression.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15126; Package emacs. (Mon, 19 Aug 2013 15:39:01 GMT) Full text and rfc822 format available.

Message #11 received at 15126 <at> debbugs.gnu.org (full text, mbox):

From: Simon Katz <sk <at> nomistech.com>
To: 15126 <at> debbugs.gnu.org
Subject: Re: bug#15126: 24.3; kmacro-end-and-call-macro repeats macro multiple
 times following isearch-forward
Date: Mon, 19 Aug 2013 09:04:38 +0100
Some more detail:

    /Applications/Emacs-24-3-1.app/Contents/MacOS/Emacs -Q
    Then at the start of the *scratch* buffer:
    C-s   e r   C-x (   x x x x   C-s C-s   C-x )  F4  F4
    This is as it should be -- one at a time.

But:
    /Applications/Emacs-24-3-1.app/Contents/MacOS/Emacs -Q
    Then at the start of the *scratch* buffer:
    C-s   e r   C-x (   x x x x   C-s C-s   C-x e
    (The original report -- multiple changes for the line above.)
    Return to the start of the buffer.
    F4
    Multiple changes are made.

So F4 is ok in the first case but not in the second.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15126; Package emacs. (Mon, 19 Aug 2013 23:57:02 GMT) Full text and rfc822 format available.

Message #14 received at 15126 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Simon Katz <nomiskatz <at> gmail.com>
Cc: 15126 <at> debbugs.gnu.org
Subject: Re: bug#15126: 24.3;
 kmacro-end-and-call-macro repeats macro multiple times following
 isearch-forward
Date: Tue, 20 Aug 2013 02:50:56 +0300
> In Emacs 24.2.1 and all previous versions I've used,
> kmacro-end-and-call-macro calls the macro once more, and I can go
> through the file making changes one at a time, and I can stop when I
> want.
>
> In Emacs 24.3.1, kmacro-end-and-call-macro calls the macro repeatedly
> making changes to all the repeated text up to the end of the file.

I can't find a change that caused this regression.
At least, I see that it is not caused by the fix for bug#4894
that added `store-kbd-macro-event' to `isearch-other-meta-char'.
But removing `store-kbd-macro-event' from `isearch-unread'
that is called from `isearch-other-meta-char' fixes this bug.
Perhaps this is a wrong fix and I don't know how to fix this properly.
`isearch-other-meta-char' currently is full of crap that should be
rewritten and reduced to a more manageable size.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15126; Package emacs. (Sat, 24 Aug 2013 09:49:01 GMT) Full text and rfc822 format available.

Message #17 received at 15126 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Simon Katz <nomiskatz <at> gmail.com>
Cc: 15126 <at> debbugs.gnu.org
Subject: Re: bug#15126: 24.3;
 kmacro-end-and-call-macro repeats macro multiple times following
 isearch-forward
Date: Sat, 24 Aug 2013 12:45:01 +0300
> In Emacs 24.2.1 and all previous versions I've used,
> kmacro-end-and-call-macro calls the macro once more, and I can go
> through the file making changes one at a time, and I can stop when I
> want.
>
> In Emacs 24.3.1, kmacro-end-and-call-macro calls the macro repeatedly
> making changes to all the repeated text up to the end of the file.

Actually this is an old bug uncovered by another unrelated change.
Emacs 24.2.1 stored the key `C-x' in the keyboard macro.
Emacs 24.3.1 now stores the whole key sequence `C-x e'.

Storing `C-x' had no effect, but also made no sense.
It's clear that neither `C-x' nor `C-x e' should be stored.
So not storing `C-x e' will not execute the same macro repeatedly.

Currently I see only one way to fix this properly:

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-08-08 23:59:14 +0000
+++ lisp/isearch.el	2013-08-24 09:27:30 +0000
@@ -2386,6 +2386,13 @@ (defun isearch-other-meta-char (&optiona
              (isearch-unread-key-sequence keylist)
              (setq main-event (car unread-command-events))
 
+	     ;; Don't store special commands in the keyboard macro.
+	     (let (overriding-terminal-local-map)
+	       (when (memq (key-binding key)
+			   '(kmacro-start-macro
+			     kmacro-end-macro kmacro-end-and-call-macro))
+		 (cancel-kbd-macro-events)))
+
 	     ;; If we got a mouse click event, that event contains the
 	     ;; window clicked on. maybe it was read with the buffer
 	     ;; it was clicked on.  If so, that buffer, not the current one,





Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Tue, 27 Aug 2013 16:09:02 GMT) Full text and rfc822 format available.

Notification sent to Simon Katz <nomiskatz <at> gmail.com>:
bug acknowledged by developer. (Tue, 27 Aug 2013 16:09:03 GMT) Full text and rfc822 format available.

Message #22 received at 15126-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Simon Katz <nomiskatz <at> gmail.com>
Cc: 15126-done <at> debbugs.gnu.org
Subject: Re: bug#15126: 24.3;
 kmacro-end-and-call-macro repeats macro multiple times following
 isearch-forward
Date: Tue, 27 Aug 2013 19:06:58 +0300
>> In Emacs 24.3.1, kmacro-end-and-call-macro calls the macro repeatedly
>> making changes to all the repeated text up to the end of the file.
>
> It's clear that neither `C-x' nor `C-x e' should be stored.
> So not storing `C-x e' will not execute the same macro repeatedly.

This case is fixed now.  Thanks for the bug report.

There is another case where instead of `C-x e'
typing more verbosely `M-x kmacro-end-and-call-macro RET'
will store this sequence in the macro.

But it's not a isearch specific problem as it can be reproduced
without isearch by the test case:

  M-x kmacro-start-macro RET x x x x
  M-x kmacro-end-and-call-macro RET

It doesn't stop after the first macro execution
because it stores M-x and the command in the macro:

Macro:
4*x			;; self-insert-command
M-x			;; execute-extended-command
kmacro-end-and-call-macro	;; self-insert-command * 25

This is a minor problem since nobody reported it
because there are more convenient keys to do the same
with `C-x ( x x x x C-x e' (or F3/F4).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#15126; Package emacs. (Sun, 01 Sep 2013 13:11:02 GMT) Full text and rfc822 format available.

Message #25 received at 15126-done <at> debbugs.gnu.org (full text, mbox):

From: Simon Katz <sk <at> nomistech.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: Simon Katz <nomiskatz <at> gmail.com>, 15126-done <at> debbugs.gnu.org
Subject: Re: bug#15126: 24.3; kmacro-end-and-call-macro repeats macro multiple
 times following isearch-forward
Date: Sun, 01 Sep 2013 14:10:40 +0100
Juri Linkov wrote on 2013-08-27 17:06:
>>> In Emacs 24.3.1, kmacro-end-and-call-macro calls the macro repeatedly
>>> making changes to all the repeated text up to the end of the file.
>> It's clear that neither `C-x' nor `C-x e' should be stored.
>> So not storing `C-x e' will not execute the same macro repeatedly.
> This case is fixed now.  Thanks for the bug report.
>
> There is another case where instead of `C-x e'
> typing more verbosely `M-x kmacro-end-and-call-macro RET'
> will store this sequence in the macro.
>
> But it's not a isearch specific problem as it can be reproduced
> without isearch by the test case:
>
>    M-x kmacro-start-macro RET x x x x
>    M-x kmacro-end-and-call-macro RET
>
> It doesn't stop after the first macro execution
> because it stores M-x and the command in the macro:
>
> Macro:
> 4*x			;; self-insert-command
> M-x			;; execute-extended-command
> kmacro-end-and-call-macro	;; self-insert-command * 25
>
> This is a minor problem since nobody reported it
> because there are more convenient keys to do the same
> with `C-x ( x x x x C-x e' (or F3/F4).

Great, and thanks for the additional info.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 30 Sep 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 218 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.