unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: isearch highlighting with zero-length match
@ 2004-09-02  9:00 YAMAMOTO Mitsuharu
  2004-09-03 21:53 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: YAMAMOTO Mitsuharu @ 2004-09-02  9:00 UTC (permalink / raw)


Could someone please take care of the following issue that I posted to
emacs-pretest-bug in January?  Carbon Emacs no longer hangs with this,
but waste of CPU time would occur in any platform.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

[From http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-01/msg00052.html]

> A problem is found in isearch lazy highlighting when zero-length match
> occurs (including the case `isearch-string' is "").

> For example, typing `C-u C-s a ?' in the middle of a window highlights
> the area after the cursor, but not for the area before the cursor.
> For backward isearch, the starting point of the search for
> highlighting go beyond the visible part of the window (and waste CPU
> time).

> In Carbon Emacs for Mac OS X, this behavior of backward isearch
> sometimes causes long hang (but escapable with `C-g') if backward
> isearch is invoked at the head of a large buffer.  (I'm not certain,
> but maybe the idle timer is taking precedence of keyboard input?)

> The attached patch solves the problem by taking account of the case of
> zero-length match at the search bound.

[This is a re-generated patch]

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.236
diff -c -r1.236 isearch.el
*** lisp/isearch.el	1 Sep 2004 20:32:13 -0000	1.236
--- lisp/isearch.el	2 Sep 2004 08:55:48 -0000
***************
*** 2395,2401 ****
                  (let ((mb (match-beginning 0))
                        (me (match-end 0)))
                    (if (= mb me)      ;zero-length match
!                       (forward-char 1)
  
                      ;; non-zero-length match
                      (let ((ov (make-overlay mb me)))
--- 2395,2411 ----
                  (let ((mb (match-beginning 0))
                        (me (match-end 0)))
                    (if (= mb me)      ;zero-length match
! 		      (if isearch-forward
! 			  (if (= mb (if isearch-lazy-highlight-wrapped
! 					isearch-lazy-highlight-start
! 				      (window-end)))
! 			      (setq found nil)
! 			    (forward-char 1))
! 			(if (= mb (if isearch-lazy-highlight-wrapped
! 				      isearch-lazy-highlight-end
! 				    (window-start)))
! 			    (setq found nil)
! 			  (forward-char -1)))
  
                      ;; non-zero-length match
                      (let ((ov (make-overlay mb me)))
***************
*** 2405,2423 ****
                        (push ov isearch-lazy-highlight-overlays)))
                    (if isearch-forward
                        (setq isearch-lazy-highlight-end (point))
!                     (setq isearch-lazy-highlight-start (point))))
  
!               ;; not found
!               (if isearch-lazy-highlight-wrapped
!                   (setq looping nil
!                         nomore  t)
!                 (setq isearch-lazy-highlight-wrapped t)
!                 (if isearch-forward
!                     (progn
!                       (setq isearch-lazy-highlight-end (window-start))
!                       (goto-char (window-start)))
!                   (setq isearch-lazy-highlight-start (window-end))
!                   (goto-char (window-end)))))))
          (unless nomore
            (setq isearch-lazy-highlight-timer
                  (run-at-time isearch-lazy-highlight-interval nil
--- 2415,2434 ----
                        (push ov isearch-lazy-highlight-overlays)))
                    (if isearch-forward
                        (setq isearch-lazy-highlight-end (point))
!                     (setq isearch-lazy-highlight-start (point)))))
  
! 	    ;; not found or zero-length match at the search bound
! 	    (if (not found)
! 		(if isearch-lazy-highlight-wrapped
! 		    (setq looping nil
! 			  nomore  t)
! 		  (setq isearch-lazy-highlight-wrapped t)
! 		  (if isearch-forward
! 		      (progn
! 			(setq isearch-lazy-highlight-end (window-start))
! 			(goto-char (window-start)))
! 		    (setq isearch-lazy-highlight-start (window-end))
! 		    (goto-char (window-end)))))))
          (unless nomore
            (setq isearch-lazy-highlight-timer
                  (run-at-time isearch-lazy-highlight-interval nil

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

* Re: isearch highlighting with zero-length match
  2004-09-02  9:00 isearch highlighting with zero-length match YAMAMOTO Mitsuharu
@ 2004-09-03 21:53 ` Juri Linkov
  2004-09-04 22:12   ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2004-09-03 21:53 UTC (permalink / raw)
  Cc: emacs-devel

YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> writes:
> Could someone please take care of the following issue that I posted to
> emacs-pretest-bug in January?  Carbon Emacs no longer hangs with this,
> but waste of CPU time would occur in any platform.

I looked at this patch.  It really fixes all mentioned problems and I think
it should be installed.

I was surprised that `isearch-lazy-highlight-update' is called even
for empty search strings.  This means that every time users type C-s
it iterates over all characters in the window.  This may be not noticeable
on fast machines, but still is useless.  If the search string is "",
it is guaranteed that nothing is going to be highlighted.  I think
`isearch-lazy-highlight-new-loop' should prevent lazy highlighting for
empty search strings (I mean if isearch-string is "", not other cases
with zero-length matches where there is no such guarantee).

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

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

* Re: isearch highlighting with zero-length match
  2004-09-03 21:53 ` Juri Linkov
@ 2004-09-04 22:12   ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2004-09-04 22:12 UTC (permalink / raw)
  Cc: mituharu, emacs-devel

    I was surprised that `isearch-lazy-highlight-update' is called even
    for empty search strings.  This means that every time users type C-s
    it iterates over all characters in the window.  This may be not noticeable
    on fast machines, but still is useless.

Thanks.  I fixed that.

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

end of thread, other threads:[~2004-09-04 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-02  9:00 isearch highlighting with zero-length match YAMAMOTO Mitsuharu
2004-09-03 21:53 ` Juri Linkov
2004-09-04 22:12   ` Richard Stallman

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