From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#25751: Query replace lazy highlighting Date: Sun, 19 Feb 2017 01:17:04 +0200 Organization: LINKOV.NET Message-ID: <87h93rcffj.fsf@localhost> References: <87mvdmxoig.fsf@lambda> <87wpcpx32v.fsf@localhost> <83d1ehxqzd.fsf@gnu.org> <87poig2zwg.fsf@localhost> <83mvdjrk6j.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1487459957 14044 195.159.176.226 (18 Feb 2017 23:19:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Feb 2017 23:19:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (x86_64-pc-linux-gnu) Cc: 25751@debbugs.gnu.org, antoine.levitt@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 19 00:19:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfEHW-0002qy-UK for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Feb 2017 00:19:11 +0100 Original-Received: from localhost ([::1]:60100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfEHZ-00060N-8P for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Feb 2017 18:19:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfEHS-000605-Ma for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 18:19:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfEHO-000096-Iy for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 18:19:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47237) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cfEHO-00008u-FZ for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 18:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cfEHO-0000AT-4a for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2017 18:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Feb 2017 23:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25751 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25751-submit@debbugs.gnu.org id=B25751.1487459906602 (code B ref 25751); Sat, 18 Feb 2017 23:19:02 +0000 Original-Received: (at 25751) by debbugs.gnu.org; 18 Feb 2017 23:18:26 +0000 Original-Received: from localhost ([127.0.0.1]:45436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfEGo-00009e-7e for submit@debbugs.gnu.org; Sat, 18 Feb 2017 18:18:26 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:40264 helo=homiemail-a17.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfEGm-00009W-Bd for 25751@debbugs.gnu.org; Sat, 18 Feb 2017 18:18:24 -0500 Original-Received: from homiemail-a17.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a17.g.dreamhost.com (Postfix) with ESMTP id 7EB442B206D; Sat, 18 Feb 2017 15:18:22 -0800 (PST) Original-Received: from localhost.linkov.net (m212-107-59-228.cust.tele2.ee [212.107.59.228]) (Authenticated sender: jurta@jurta.org) by homiemail-a17.g.dreamhost.com (Postfix) with ESMTPA id 787772B206A; Sat, 18 Feb 2017 15:18:21 -0800 (PST) In-Reply-To: <83mvdjrk6j.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Feb 2017 10:13:08 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129521 Archived-At: --=-=-= Content-Type: text/plain >> > I think the problem is not that we remove the highlight and add it >> > anew, the problem is that there's a redisplay cycle in between the >> > removal and the following addition. The fact that setting >> > lazy-highlight-initial-delay alleviates the problem to some extent, >> > but still leaves the flicker tells me that there's a call to sit-for >> > or some such somewhere in the code that processes replacements, and >> > the removal and addition of the highlight are on two different sides >> > of that sit-for call. One possible solution would be to remove the >> > highlight and add it without triggering redisplay, then I'd expect the >> > flicker to go away. >> > >> > Does this make sense? >> >> This feature is called _lazy_ highlighting where _lazy_ implies that it's >> intended to highlight matches much later after a lot of redisplay cycles. > > You could still leave the "lazy" part, if you both remove and re-add > the overlays after the idle delay. IOW, the important thing is not to > have redisplay between removal and addition of the highlight. That's an option too, and here is the tested patch (it sets lazy-highlight-max-at-a-time to nil to avoid redisplay between lazy iterations): --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/lisp/isearch.el b/lisp/isearch.el index 5262435..15143ce 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -332,7 +332,7 @@ (define-obsolete-variable-alias 'isearch-lazy-highlight= -max-at-a-time 'lazy-highlight-max-at-a-time "22.1") =20 -(defcustom lazy-highlight-max-at-a-time 20 +(defcustom lazy-highlight-max-at-a-time nil "Maximum matches to highlight at a time (for `lazy-highlight'). Larger values may reduce Isearch's responsiveness to user input; smaller values make matches highlight slowly. @@ -3122,13 +3122,13 @@ (define-obsolete-variable-alias 'isearch-lazy-highl= ight-word (defvar isearch-lazy-highlight-forward nil) (defvar isearch-lazy-highlight-error nil) =20 -(defun lazy-highlight-cleanup (&optional force) +(defun lazy-highlight-cleanup (&optional force postpone) "Stop lazy highlighting and remove extra highlighting from current buffe= r. FORCE non-nil means do it whether or not `lazy-highlight-cleanup' is nil. This function is called when exiting an incremental search if `lazy-highlight-cleanup' is non-nil." (interactive '(t)) - (if (or force lazy-highlight-cleanup) + (when (and (or force lazy-highlight-cleanup) (not postpone)) (while isearch-lazy-highlight-overlays (delete-overlay (car isearch-lazy-highlight-overlays)) (setq isearch-lazy-highlight-overlays @@ -3173,7 +3173,7 @@ (defun isearch-lazy-highlight-new-loop (&optional beg= end) (not (equal isearch-error isearch-lazy-highlight-error)))) ;; something important did indeed change - (lazy-highlight-cleanup t) ;kill old loop & remove overlays + (lazy-highlight-cleanup t (not (equal isearch-string ""))) ;stop old t= imer (setq isearch-lazy-highlight-error isearch-error) ;; It used to check for `(not isearch-error)' here, but actually ;; lazy-highlighting might find matches to highlight even when @@ -3204,7 +3204,7 @@ (defun isearch-lazy-highlight-new-loop (&optional beg= end) (unless (equal isearch-string "") (setq isearch-lazy-highlight-timer (run-with-idle-timer lazy-highlight-initial-delay nil - 'isearch-lazy-highlight-update))))) + 'isearch-lazy-highlight-start))))) =20 (defun isearch-lazy-highlight-search () "Search ahead for the next or previous match, for lazy highlighting. @@ -3249,6 +3249,10 @@ (defun isearch-lazy-highlight-search () success) (error nil))) =20 +(defun isearch-lazy-highlight-start () + (lazy-highlight-cleanup t) ;remove old overlays + (isearch-lazy-highlight-update)) + (defun isearch-lazy-highlight-update () "Update highlighting of other matches for current search." (let ((max lazy-highlight-max-at-a-time) --=-=-=--