GNU bug report logs - #4894
23.1; emacs ignores number characters in incremental search in keyboard macros

Previous Next

Package: emacs;

Reported by: Petr Machata <pmachata <at> gmail.com>

Date: Mon, 9 Nov 2009 18:00:07 UTC

Severity: normal

Done: Chong Yidong <cyd <at> gnu.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 4894 in the body.
You can then email your comments to 4894 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-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4894; Package emacs. (Mon, 09 Nov 2009 18:00:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Petr Machata <pmachata <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 09 Nov 2009 18:00:08 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Petr Machata <pmachata <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; emacs ignores number characters in incremental search in keyboard macros
Date: Mon, 09 Nov 2009 18:54:12 +0100
Do the following to record a macro involving an incremental search
looking for a string "x00x":

 M-x kmacro-start-macro C-s x 0 0 x M-x kmacro-end-macro

Observe that the macro doesn't include the 0 characters at all:

 M-x kmacro-view-macro

On my machine, the above shows:

 Last macro: C-s xx M-x kmacro-en TAB ma TAB [2 times]

(i.e. the macro system seems to ignore the zeroes, and take more
keystrokes from the queue or whatever the underlying implementation
is.)


In GNU Emacs 23.1.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.16.6)
 of 2009-09-29 on x86-6.fedora.phx.redhat.com
Windowing system distributor `The X.Org Foundation', version 11.0.10603901
configured using `configure  '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ru_RU.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: C++/l

Minor modes in effect:
  flyspell-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  iswitchb-mode: t
  global-hl-line-mode: t
  desktop-save-mode: t
  delete-selection-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
<down> <down> C-x e C-z C-z M-x k e y <tab> <tab> <tab> 
<C-backspace> a <backspace> m a <tab> <backspace> <backspace> 
k b <tab> <tab> <tab> <tab> <return> M-x m a c <tab> 
<tab> <backspace> <backspace> <backspace> - m a c <tab> 
<tab> <tab> C-a C-k k m <tab> v i <tab> <tab> m <tab> 
<return> M-e M-r M-r M-e C-z C-z <up> C-z C-z <home> 
C-x ( <end> C-SPC <left> <left> <left> <left> <left> 
<S-delete> C-r <kp-0> x <right> <right> <right> <right> 
<right> <S-insert> <home> <down> C-x ) C-x e C-z <up> 
<down> M-x <up> <return> <home> C-x ( C-g C-z C-z C-z 
<home> C-x ( C-s <kp-0> x C-x ) C-x e e e e <up> <up> 
<up> <up> <up> <up> <up> <up> C-x ( C-s <kp-0> C-x 
) M-x <up> <return> <down> <up> C-x e e e e e e <up> 
<down> <up> <kp-0> <kp-0> <kp-0> <kp-0> <kp-0> <kp-0> 
<kp-0> <kp-0> <kp-0> <left> <left> <left> <left> <left> 
<left> <left> <left> <left> SPC <up> C-x <C-up> C-x 
<C-up> C-x <C-up> C-x ( C-s <kp-0> <kp-0> <kp-0> <kp-0> 
<kp-0> C-x ) C-x e e e <up> C-x e M-x <up> <up> <down> 
<return> C-g <down> <end> <C-backspace> <backspace> 
C-x C-s M-x r e p o <tab> r <tab> <return> E m a c 
s SPC i g n o r e s SPC C-g SPC SPC SPC x <insert> 
<insert> <kp-0> <kp-0> <kp-0> <kp-0> <kp-0> <kp-0> 
x <C-left> <C-left> C-x ( C-s x <kp-0> <kp-0> C-x ) 
<up> C-x e M-x <up> <up> <return> <right> <right> <delete> 
<delete> <delete> <delete> <kp-0> <up> C-x ( x <kp-0> 
<kp-0> <kp-0> C-z C-x ( C-x C-g C-g C-x ( C-s x <kp-0> 
<kp-0> <kp-0> x <left> C-x ) <home> C-x e C-x <up> 
C-x <down> M-x <up> <return> M-x <up> <up> <return
>

Recent messages:
Undo!
Already defining keyboard macro.
Quit
Defining kbd macro...
Mark saved where search started
Keyboard macro defined
Mark saved where search started
After 0 kbd macro iterations: isearch-search: Keyboard macro terminated by a command ringing the bell
Last macro: C-s xx <left>
Auto-saving...




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4894; Package emacs. (Wed, 11 Nov 2009 11:05:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 11:05:07 GMT) Full text and rfc822 format available.

Message #10 received at 4894 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Petr Machata <pmachata <at> gmail.com>
Cc: 4894 <at> debbugs.gnu.org
Subject: Re: bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
Date: Wed, 11 Nov 2009 12:42:57 +0200
> Do the following to record a macro involving an incremental search
> looking for a string "x00x":
>
>  M-x kmacro-start-macro C-s x 0 0 x M-x kmacro-end-macro
>
> Observe that the macro doesn't include the 0 characters at all:
>
>  M-x kmacro-view-macro
>
> On my machine, the above shows:
>
>  Last macro: C-s xx M-x kmacro-en TAB ma TAB [2 times]
>
> (i.e. the macro system seems to ignore the zeroes, and take more
> keystrokes from the queue or whatever the underlying implementation
> is.)

Do you type these zeroes with a numpad?  I can reproduce this bug when
zeroes are typed with <kp-0>, so the last macro doesn't contain zeroes.

The reason is an intentional call to `cancel-kbd-macro-events' in the
first branch of `cond' in `isearch-other-meta-char'.  I don't know why
this is needed.  CVS logs show that this line was added at 1995-08-10.

Also I noticed a related bug: when zeroes are typed with <S-kp-0> then
<S-kp-0> terminates Isearch instead of adding zeroes to the search string.
That's because <S-kp-0> is processed in the 6-th branch of `cond'
in `isearch-other-meta-char' (with `search-exit-option') where
unprocessed control characters terminate Isearch.

-- 
Juri Linkov
http://www.jurta.org/emacs/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4894; Package emacs. (Wed, 11 Nov 2009 14:30:11 GMT) Full text and rfc822 format available.

Acknowledgement sent to Petr Machata <pmachata <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 14:30:12 GMT) Full text and rfc822 format available.

Message #15 received at 4894 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Petr Machata <pmachata <at> gmail.com>
To: 4894 <at> debbugs.gnu.org
Subject: Re: bug#4894: 23.1; emacs ignores number characters in incremental 
	search in keyboard macros
Date: Wed, 11 Nov 2009 15:23:42 +0100
On Wed, Nov 11, 2009 at 11:42 AM, Juri Linkov <juri <at> jurta.org> wrote:
> Do you type these zeroes with a numpad?  I can reproduce this bug when
> zeroes are typed with <kp-0>, so the last macro doesn't contain zeroes.

Indeed I do.  Other characters entered using a numeric keypad are
ignored too, just as you say.

> The reason is an intentional call to `cancel-kbd-macro-events'

I thought it might be intentional, but couldn't google anything
relevant.  I would still consider it very unintuitive, if not a bug.

PM



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4894; Package emacs. (Wed, 11 Nov 2009 18:40:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 18:40:08 GMT) Full text and rfc822 format available.

Message #20 received at 4894 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Kenichi Handa <handa <at> m17n.org>
Cc: 4894 <at> debbugs.gnu.org, Petr Machata <pmachata <at> gmail.com>
Subject: Re: bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
Date: Wed, 11 Nov 2009 13:32:05 -0500
>> Do the following to record a macro involving an incremental search
>> looking for a string "x00x":
>> 
>> M-x kmacro-start-macro C-s x 0 0 x M-x kmacro-end-macro
>> 
>> Observe that the macro doesn't include the 0 characters at all:

> Do you type these zeroes with a numpad?  I can reproduce this bug when
> zeroes are typed with <kp-0>, so the last macro doesn't contain zeroes.

> The reason is an intentional call to `cancel-kbd-macro-events' in the
> first branch of `cond' in `isearch-other-meta-char'.  I don't know why
> this is needed.  CVS logs show that this line was added at 1995-08-10.

Actually, the need for cancel-kbd-macro-events is explained in
the comment.  The problem is that after cancelling the <kp-0> we should
add the ?0 replacement.  That should normally be done by isearch-unread,
but for printing char, we don't call that function any more.

I.e. the problem was introduced by the change below.  Handa, can you
explain why we need this?  Maybe it was needed at the time but not
any more?


        Stefan


committer: handa
branch nick: HEAD
timestamp: Thu 2000-06-01 12:22:31 +0000
message:
  (isearch-update): Set disable-point-adjustment to t
  to prevent the point moving to the end of a composition when a
  part of a composition is searched.
  (isearch-other-meta-char): If the key invoking this command can be
  mapped by function-key-map to a printing char, call
  isearch-process-search-char directly.
------------------------------------------------------------


=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2000-05-31 09:49:22 +0000
+++ lisp/isearch.el	2000-06-01 12:22:31 +0000
@@ -619,7 +619,10 @@
   (setq ;; quit-flag nil  not for isearch-mode
    isearch-adjusted nil
    isearch-yank-flag nil)
-  (isearch-lazy-highlight-new-loop))
+  (isearch-lazy-highlight-new-loop)
+  ;; We must prevent the point moving to the end of composition when a
+  ;; part of the composition has just been searched.
+  (setq disable-point-adjustment t))
 
 (defun isearch-done (&optional nopush edit)
   (remove-hook 'mouse-leave-buffer-hook 'isearch-done)
@@ -1150,8 +1153,22 @@
 	       (progn 
 		 (isearch-done)
 		 (apply 'isearch-unread keylist))
-	     (apply 'isearch-unread
-		    (listify-key-sequence (lookup-key function-key-map key)))))
+	     (setq keylist
+		   (listify-key-sequence (lookup-key function-key-map key)))
+	     (while keylist
+	       (setq key (car keylist))
+	       ;; If KEY is a printing char, we handle it here
+	       ;; directly to avoid the input method and keyboard
+	       ;; coding system translating it.
+	       (if (and (integerp key)
+			(>= key ?\ ) (< key 256))
+		   (progn
+		     (isearch-process-search-char key)
+		     (setq keylist (cdr keylist)))
+		 ;; As the remaining keys in KEYLIST can't be handled
+		 ;; here, we must reread them.
+		 (apply 'isearch-unread keylist)
+		 (setq keylist nil)))))
 	  (
 	   ;; Handle an undefined shifted control character
 	   ;; by downshifting it if that makes it defined.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#4894; Package emacs. (Thu, 26 Aug 2010 21:36:02 GMT) Full text and rfc822 format available.

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

From: Leo <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Kenichi Handa <handa <at> m17n.org>, Petr Machata <pmachata <at> gmail.com>,
	4894 <at> debbugs.gnu.org
Subject: Re: bug#4894: 23.1;
	emacs ignores number characters in incremental search in keyboard
	macros
Date: Thu, 26 Aug 2010 22:36:54 +0100
On 2009-11-11 18:32 +0000, Stefan Monnier wrote:
> Actually, the need for cancel-kbd-macro-events is explained in
> the comment.  The problem is that after cancelling the <kp-0> we should
> add the ?0 replacement.  That should normally be done by isearch-unread,
> but for printing char, we don't call that function any more.
>
> I.e. the problem was introduced by the change below.  Handa, can you
> explain why we need this?  Maybe it was needed at the time but not
> any more?
>
>

I run into an error 

  After 0 kbd macro iterations: isearch-search: Keyboard macro
  terminated by a command ringing the bell

almost every time isearch-forward-regexp is used in a macro, for
example:

  C-x ( ESC C-s [ - + ] ? [ 0 - 9 ] + C-x )

I wonder if someone can take a look at the problem. Thanks.

Leo

>
>         Stefan
>
>
> committer: handa
> branch nick: HEAD
> timestamp: Thu 2000-06-01 12:22:31 +0000
> message:
>   (isearch-update): Set disable-point-adjustment to t
>   to prevent the point moving to the end of a composition when a
>   part of a composition is searched.
>   (isearch-other-meta-char): If the key invoking this command can be
>   mapped by function-key-map to a printing char, call
>   isearch-process-search-char directly.
> ------------------------------------------------------------
>
>
> === modified file 'lisp/isearch.el'
> --- lisp/isearch.el	2000-05-31 09:49:22 +0000
> +++ lisp/isearch.el	2000-06-01 12:22:31 +0000
> @@ -619,7 +619,10 @@
>    (setq ;; quit-flag nil  not for isearch-mode
>     isearch-adjusted nil
>     isearch-yank-flag nil)
> -  (isearch-lazy-highlight-new-loop))
> +  (isearch-lazy-highlight-new-loop)
> +  ;; We must prevent the point moving to the end of composition when a
> +  ;; part of the composition has just been searched.
> +  (setq disable-point-adjustment t))
>  
>  (defun isearch-done (&optional nopush edit)
>    (remove-hook 'mouse-leave-buffer-hook 'isearch-done)
> @@ -1150,8 +1153,22 @@
>  	       (progn 
>  		 (isearch-done)
>  		 (apply 'isearch-unread keylist))
> -	     (apply 'isearch-unread
> -		    (listify-key-sequence (lookup-key function-key-map key)))))
> +	     (setq keylist
> +		   (listify-key-sequence (lookup-key function-key-map key)))
> +	     (while keylist
> +	       (setq key (car keylist))
> +	       ;; If KEY is a printing char, we handle it here
> +	       ;; directly to avoid the input method and keyboard
> +	       ;; coding system translating it.
> +	       (if (and (integerp key)
> +			(>= key ?\ ) (< key 256))
> +		   (progn
> +		     (isearch-process-search-char key)
> +		     (setq keylist (cdr keylist)))
> +		 ;; As the remaining keys in KEYLIST can't be handled
> +		 ;; here, we must reread them.
> +		 (apply 'isearch-unread keylist)
> +		 (setq keylist nil)))))
>  	  (
>  	   ;; Handle an undefined shifted control character
>  	   ;; by downshifting it if that makes it defined.

-- 
Any Emacs contains an ad hoc, informally-specified, bug-ridden, slow
implementation of half of Common Lisp.




bug closed, send any further explanations to 4894 <at> debbugs.gnu.org and Petr Machata <pmachata <at> gmail.com> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 29 Oct 2012 23:09:01 GMT) Full text and rfc822 format available.

Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 29 Oct 2012 23:10:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#4894; Package emacs. (Mon, 29 Oct 2012 23:25:02 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Petr Machata <pmachata <at> gmail.com>, 4894 <at> debbugs.gnu.org,
	Kenichi Handa <handa <at> m17n.org>
Subject: Re: bug#4894: 23.1;
	emacs ignores number characters in incremental search in keyboard
	macros
Date: Tue, 30 Oct 2012 07:21:58 +0800
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> Actually, the need for cancel-kbd-macro-events is explained in
> the comment.  The problem is that after cancelling the <kp-0> we should
> add the ?0 replacement.  That should normally be done by isearch-unread,
> but for printing char, we don't call that function any more.
>
> I.e. the problem was introduced by the change below.  Handa, can you
> explain why we need this?  Maybe it was needed at the time but not
> any more?

Since there has been no follow up in a long time, I went ahead and
committed a fix that involves calling store-kbd-macro-event in the
affected function.




bug closed, send any further explanations to 4894 <at> debbugs.gnu.org and Petr Machata <pmachata <at> gmail.com> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 29 Oct 2012 23:25:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 27 Nov 2012 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 178 days ago.

Previous Next


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