emacs-pretest-bug
[Top][All Lists]
Advanced

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

isearch highlighting with zero-length match (and Carbon Emacs hang)


From: YAMAMOTO Mitsuharu
Subject: isearch highlighting with zero-length match (and Carbon Emacs hang)
Date: Thu, 08 Jan 2004 17:25:32 +0900 (JST)

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.

                                     YAMAMOTO Mitsuharu
                                address@hidden

In GNU Emacs 21.3.50.1 (powerpc-apple-darwin7.2.0)
 of 2004-01-08 on yamamotomitsuharunokonpyuta.local
configured using `configure '--without-x' 'CFLAGS=-g -Os''

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: ja
  locale-coding-system: japanese-iso-8bit
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  auto-compression-mode: t
  encoded-kbd-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  line-number-mode: t

Recent input:
<menu-bar> <help-menu> <report-emacs-bug>

Recent messages:
Loading term/keyswap (source)...done
Loading subst-ksc...done
Loading subst-gb2312...done
Loading subst-big5...done
Loading subst-jis...done
Loading encoded-kb...done
Loading jka-compr...done
Loading image...done
For information about the GNU Project and its goals, type C-h C-p.
Loading emacsbug...done
*** lisp/isearch.el.~1.223.~    Sun Nov  2 15:10:04 2003
--- lisp/isearch.el     Thu Jan  8 15:34:49 2004
***************
*** 2250,2256 ****
                  (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)))
--- 2250,2266 ----
                  (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)))
***************
*** 2260,2278 ****
                        (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
--- 2270,2289 ----
                        (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]