emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: isearch highlighting with zero-length match


From: YAMAMOTO Mitsuharu
Subject: Re: isearch highlighting with zero-length match
Date: Thu, 02 Sep 2004 18:00:43 +0900
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

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
                                address@hidden

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]