unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* isearch highlighting
@ 2004-12-10  2:06 Juri Linkov
  2004-12-10  3:21 ` Stefan Monnier
  2004-12-13 19:51 ` Richard Stallman
  0 siblings, 2 replies; 15+ messages in thread
From: Juri Linkov @ 2004-12-10  2:06 UTC (permalink / raw)


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/

^ permalink raw reply	[flat|nested] 15+ messages in thread
* RE: isearch highlighting
@ 2004-12-10  7:00 klaus.berndl
  0 siblings, 0 replies; 15+ messages in thread
From: klaus.berndl @ 2004-12-10  7:00 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier wrote:
>> 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.
> 
> Agreed.  I'd even put it in `while-no-input'.  You might want to add

OT: you mention `while-no-input' whic remembers me to a discussion about this.
is this macro now available or have i misunderstood here something??

Klaus

> the patch below, tho, just so the code can't be interrupted after
> placing the new overlay but before it's recorded on the list.  There
> might be other similar issues, I haven't checked.
> 
>> 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). 
> 
> Of course.  The idea of a "really hard C-g" is to work around
> problems, 
> but it should not be an excuse to not fix those problems.
> 
>> because most regexp in Emacs packages are well tested and contains no
>> nested repetitions.
> 
> Is that an attempt at humor?
> 
> 
>         Stefan
> 
> 
> --- orig/lisp/isearch.el
> +++ mod/lisp/isearch.el
> @@ -2480,10 +2480,10 @@
> 
>                      ;; non-zero-length match
>                      (let ((ov (make-overlay mb me)))
> +                      (push ov isearch-lazy-highlight-overlays)
>                        (overlay-put ov 'face
>                        isearch-lazy-highlight-face) (overlay-put ov
> 'priority 0) ;lower than main overlay 
> -                      (overlay-put ov 'window (selected-window))
> -                      (push ov isearch-lazy-highlight-overlays)))
> +                      (overlay-put ov 'window (selected-window))))
>                    (if isearch-forward
>                        (setq isearch-lazy-highlight-end (point))
>                      (setq isearch-lazy-highlight-start (point)))))
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel

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

end of thread, other threads:[~2005-01-12  1:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-10  2:06 isearch highlighting Juri Linkov
2004-12-10  3:21 ` Stefan Monnier
2004-12-10  5:22   ` Juri Linkov
2004-12-13 19:51 ` Richard Stallman
2004-12-14 10:27   ` Juri Linkov
2004-12-15 14:58     ` Richard Stallman
2004-12-17 15:29   ` Juri Linkov
2004-12-20 10:56     ` Richard Stallman
2004-12-20 20:57       ` Juri Linkov
2005-01-06  7:54         ` Juri Linkov
2005-01-09  3:23           ` Richard Stallman
2005-01-09 21:40           ` Stefan Monnier
2005-01-11 14:30             ` Richard Stallman
2005-01-12  1:52               ` Juri Linkov
  -- strict thread matches above, loose matches on Subject: below --
2004-12-10  7:00 klaus.berndl

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