From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: isearch highlighting Date: Fri, 10 Dec 2004 04:06:04 +0200 Organization: JURTA Message-ID: <87fz2e6h6b.fsf@jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1102645221 25226 80.91.229.6 (10 Dec 2004 02:20:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 10 Dec 2004 02:20:21 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 10 03:20:16 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CcaOF-0007RP-00 for ; Fri, 10 Dec 2004 03:20:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CcaYB-0001R5-2q for ged-emacs-devel@m.gmane.org; Thu, 09 Dec 2004 21:30:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CcaXt-0001Qe-SD for emacs-devel@gnu.org; Thu, 09 Dec 2004 21:30:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CcaXt-0001QS-DN for emacs-devel@gnu.org; Thu, 09 Dec 2004 21:30:13 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CcaXt-0001QP-Aq for emacs-devel@gnu.org; Thu, 09 Dec 2004 21:30:13 -0500 Original-Received: from [194.126.101.100] (helo=MXR-5.estpak.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CcaND-0004z0-3v for emacs-devel@gnu.org; Thu, 09 Dec 2004 21:19:11 -0500 Original-Received: from jurta.org.jurta.org (80-235-41-2-dsl.mus.estpak.ee [80.235.41.2]) by MXR-5.estpak.ee (Postfix) with ESMTP id A7C38F5056 for ; Fri, 10 Dec 2004 04:19:04 +0200 (EET) Original-To: emacs-devel@gnu.org User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at neti.ee X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:30962 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30962 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/