emacs-devel
[Top][All Lists]
Advanced

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

isearch highlighting


From: Juri Linkov
Subject: isearch highlighting
Date: Fri, 10 Dec 2004 04:06:04 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

I'd like to fix the following 3 problems in isearch highlighting:

1. When Emacs hangs while searching with isearch for a regexp with
nested repetitions, it can be interrupted with C-g.  Fine.  But when
it hangs while highlighting other occurrences of the search string with
isearch-lazy-highlight invoked by a timer, it can't be interrupted.
I think it is safe to put the body of `isearch-lazy-highlight-update'
in the `with-local-quit' block, because quit in this function can't
lead to a corrupted state.  It seems this change is unrelated to the
proposed solution of a new form of really hard C-g (which is useful to
interrupt the code which can put the process in a corrupted state).
Also there is no urgent need to detect infinite loops in regex.c,
because most regexp in Emacs packages are well tested and contains no
nested repetitions.  The only weak point is isearch (and query-replace)
where regexps are typed manually.  It should be possible to interrupt
isearch lazy highlighting with normal C-g.

2.  There is one problem in fontification of the minibuffer in isearch
mode.  When a sequence of a multi-character input method is unfinished
and the minibuffer is active, then the search string is highlighted by
isearch lazy highlighting in the minibuffer instead of the source
buffer.  To reproduce this bug, type:

C-x RET C-\ latin-1-postfix RET C-s a a

This could be fixed in `isearch-lazy-highlight-update' by selecting
the window where isearch was activated.

3. While typing a sequence of a multi-character input method in the
isearch minibuffer, the first part of the isearch string is
highlighted in `minibuffer-prompt' face, because it is used as the
part of the prompt.  Instead, it could be inserted into the minibuffer
as initial-contents.

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.244
diff -u -w -b -r1.244 isearch.el
--- lisp/isearch.el     6 Dec 2004 15:12:08 -0000       1.244
+++ lisp/isearch.el     9 Dec 2004 23:09:07 -0000
@@ -2385,6 +2386,11 @@
   (let ((max isearch-lazy-highlight-max-at-a-time)
         (looping t)
         nomore)
+    (with-local-quit
+      (save-selected-window
+       (if (and (window-live-p isearch-lazy-highlight-window)
+                (not (eq (selected-window) isearch-lazy-highlight-window)))
+           (select-window isearch-lazy-highlight-window))
     (save-excursion
       (save-match-data
         (goto-char (if isearch-forward
@@ -2437,7 +2443,7 @@
         (unless nomore
           (setq isearch-lazy-highlight-timer
                 (run-at-time isearch-lazy-highlight-interval nil
-                             'isearch-lazy-highlight-update)))))))
+                                'isearch-lazy-highlight-update)))))))))
 
 (defun isearch-resume (search regexp word forward message case-fold)
   "Resume an incremental search.

Index: lisp/international/isearch-x.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/isearch-x.el,v
retrieving revision 1.17
diff -u -r1.17 isearch-x.el
--- lisp/international/isearch-x.el     1 Sep 2003 15:45:28 -0000       1.17
+++ lisp/international/isearch-x.el     9 Dec 2004 23:16:02 -0000
@@ -97,7 +97,7 @@
 (defun isearch-process-search-multibyte-characters (last-char)
   (if (eq this-command 'isearch-printing-char)
       (let ((overriding-terminal-local-map nil)
-           (prompt (concat (isearch-message-prefix) isearch-message))
+           (prompt (concat (isearch-message-prefix)))
            (minibuffer-local-map isearch-minibuffer-local-map)
            str)
        (if isearch-input-method-function
@@ -107,11 +107,12 @@
                    (cons 'with-input-method
                          (cons last-char unread-command-events))
                    ;; Inherit current-input-method in a minibuffer.
-                   str (read-string prompt nil nil nil t))
+                   str (read-string prompt isearch-message nil nil t))
              (if (not str)
                  ;; All inputs were deleted while the input method
                  ;; was working.
                  (setq str "")
+               (setq str (substring str (length isearch-message)))
                (if (and (= (length str) 1)
                         (= (aref str 0) last-char)
                         (>= last-char 128))

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





reply via email to

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