unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
@ 2009-11-09 17:54 Petr Machata
  2009-11-11 10:42 ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Machata @ 2009-11-09 17:54 UTC (permalink / raw)
  To: bug-gnu-emacs


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...






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
  2009-11-09 17:54 bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros Petr Machata
@ 2009-11-11 10:42 ` Juri Linkov
  2009-11-11 14:23   ` Petr Machata
  2009-11-11 18:32   ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Juri Linkov @ 2009-11-11 10:42 UTC (permalink / raw)
  To: Petr Machata; +Cc: 4894

> 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/





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
  2009-11-11 10:42 ` Juri Linkov
@ 2009-11-11 14:23   ` Petr Machata
  2009-11-11 18:32   ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Machata @ 2009-11-11 14:23 UTC (permalink / raw)
  To: 4894

On Wed, Nov 11, 2009 at 11:42 AM, Juri Linkov <juri@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
  2009-11-11 10:42 ` Juri Linkov
  2009-11-11 14:23   ` Petr Machata
@ 2009-11-11 18:32   ` Stefan Monnier
  2010-08-26 21:36     ` Leo
  2012-10-29 23:21     ` Chong Yidong
  1 sibling, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2009-11-11 18:32 UTC (permalink / raw)
  To: Kenichi Handa; +Cc: Petr Machata, 4894

>> 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.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
  2009-11-11 18:32   ` Stefan Monnier
@ 2010-08-26 21:36     ` Leo
  2012-10-29 23:21     ` Chong Yidong
  1 sibling, 0 replies; 6+ messages in thread
From: Leo @ 2010-08-26 21:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 4894, Petr Machata

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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros
  2009-11-11 18:32   ` Stefan Monnier
  2010-08-26 21:36     ` Leo
@ 2012-10-29 23:21     ` Chong Yidong
  1 sibling, 0 replies; 6+ messages in thread
From: Chong Yidong @ 2012-10-29 23:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Petr Machata, 4894, Kenichi Handa

Stefan Monnier <monnier@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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-29 23:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-09 17:54 bug#4894: 23.1; emacs ignores number characters in incremental search in keyboard macros Petr Machata
2009-11-11 10:42 ` Juri Linkov
2009-11-11 14:23   ` Petr Machata
2009-11-11 18:32   ` Stefan Monnier
2010-08-26 21:36     ` Leo
2012-10-29 23:21     ` Chong Yidong

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).