emacs-devel
[Top][All Lists]
Advanced

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

Re: highlight failed part of isearch input


From: Juri Linkov
Subject: Re: highlight failed part of isearch input
Date: Sun, 15 Jul 2007 02:07:19 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

>     I think we should try to find a proper place in low-level isearch
>     functions to fix such behavior, because for users it is confusing.
>
> I agree.  Can you work on it?

The patch below fixes `isearch-edit-string' to work correctly in all
reported cases.  After editing the search string in the minibuffer it uses
the old value of `isearch-other-end' as a new search starting point, so it
can find the same string again.  It does this only in the case when the
user didn't change point in the buffer during editing the search string in
the minibuffer (by switching buffers and moving point).

Index: lisp/isearch.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.298
diff -c -r1.298 isearch.el
*** lisp/isearch.el     9 Jul 2007 14:45:01 -0000       1.298
--- lisp/isearch.el     14 Jul 2007 22:59:45 -0000
***************
*** 992,998 ****
               isearch-original-minibuffer-message-timeout)
              (isearch-original-minibuffer-message-timeout
               isearch-original-minibuffer-message-timeout)
!             )
  
          ;; Actually terminate isearching until editing is done.
          ;; This is so that the user can do anything without failure,
--- 1004,1010 ----
               isearch-original-minibuffer-message-timeout)
              (isearch-original-minibuffer-message-timeout
               isearch-original-minibuffer-message-timeout)
!             old-point old-other-end)
  
          ;; Actually terminate isearching until editing is done.
          ;; This is so that the user can do anything without failure,
***************
*** 1001,1006 ****
--- 1013,1022 ----
              (isearch-done t t)
            (exit nil))                 ; was recursive editing
  
+         ;; Save old point and isearch-other-end before reading from minibuffer
+         ;; that can change their values.
+         (setq old-point (point) old-other-end isearch-other-end)
+ 
          (isearch-message) ;; for read-char
          (unwind-protect
              (let* (;; Why does following read-char echo?
***************
*** 1036,1041 ****
--- 1052,1065 ----
                      isearch-new-message
                      (mapconcat 'isearch-text-char-description
                                 isearch-new-string "")))
+ 
+           ;; Set the point at the start (end) of old match if forward 
(backward),
+           ;; so after exiting minibuffer isearch resumes at the start (end)
+           ;; of this match and can find it again.
+           (if (and old-other-end (eq old-point (point))
+                    (eq isearch-forward isearch-new-forward))
+               (goto-char old-other-end))
+ 
            ;; Always resume isearching by restarting it.
            (isearch-mode isearch-forward
                          isearch-regexp

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




reply via email to

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