From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Patch to avoid flicker in Isearch with lazy count Date: Wed, 27 Jan 2021 19:48:54 +0200 Organization: LINKOV.NET Message-ID: <87lfce2ruh.fsf@mail.linkov.net> References: <87r1m6jsk7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21865"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Augusto Stoffel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 27 19:00:28 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l4p7D-0005Wh-VF for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Jan 2021 19:00:27 +0100 Original-Received: from localhost ([::1]:38054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4p7C-0005om-RI for ged-emacs-devel@m.gmane-mx.org; Wed, 27 Jan 2021 13:00:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4p4A-0003sf-92 for emacs-devel@gnu.org; Wed, 27 Jan 2021 12:57:18 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:48427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4p48-0002a5-7j for emacs-devel@gnu.org; Wed, 27 Jan 2021 12:57:18 -0500 X-Originating-IP: 91.129.98.64 Original-Received: from mail.gandi.net (m91-129-98-64.cust.tele2.ee [91.129.98.64]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 3C4D1FF812; Wed, 27 Jan 2021 17:57:12 +0000 (UTC) In-Reply-To: <87r1m6jsk7.fsf@gmail.com> (Augusto Stoffel's message of "Wed, 27 Jan 2021 16:41:28 +0100") Received-SPF: pass client-ip=217.70.183.199; envelope-from=juri@linkov.net; helo=relay9-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263516 Archived-At: > Setting ‘lazy-highlight-initial-delay’ to 0 (which should be a > reasonable default on a modern machine) causes some flickering in the > search buffer, and a lot of flickering in the echo are when > ‘isearch-lazy-count’ is on. > > The attached patch addresses these problems. Thanks for the patch. > It also makes the desired effect of setting ‘lazy-highlight-initial-delay’ > to 0 the default, even though that variable is unchanged. Does this mean that for users who already customized ‘lazy-highlight-initial-delay’ to 0, now it's recommended to revert such customization, and leave it at its default non-zero value? So after typing just one letter an initial delay is recommended, and after typing more letters no delay. Then this should be mentioned in etc/NEWS. > Flicker in the search buffer happens because the highlighting of > matches happens after typing just one letter, and there are > potentially many of those. It is fixed by adding a new variable, > ‘lazy-highlight-delay-max-chars’. Lazy highlighting kicks in > immediately if the search string is longer than that number. I set > the default value to 2, but maybe 1 is even better. > > Flicker in the echo area happens even with the default value of > ‘lazy-highlight-initial-delay’, if less pronouncedly, and is due to > too frequent updates to the echo area message. This is solved by > keeping the lazy count in the echo area of out of date for the > fraction of a second where the lazy stuff is waiting to kick in. Please see more comments: > (defcustom lazy-highlight-initial-delay 0.25 > - "Seconds to wait before beginning to lazily highlight all matches." > + "Seconds to wait before beginning to lazily highlight all matches. > +This setting only has effect if the current search string is at most > +`lazy-highlight-initial-delay' character long." Typo? Maybe lazy-highlight-delay-max-chars? > (defcustom lazy-highlight-interval 0 ; 0.0625 > - "Seconds between lazily highlighting successive matches." > + "Seconds between lazily highlighting successive matches. > +This setting only has effect if the current search string is at most > +`lazy-highlight-initial-delay' character long." The same typo? > +(defun isearch-lazy-highlight-with-timer (delay function) > + "Arrange for FUNCTION to be called in idle time, possibly with DELAY. > +There is no delay if the current search string is longer than > +`lazy-highlight-delay-max-chars'." > + (setq isearch-lazy-highlight-timer > + (run-with-idle-timer > + (if (> (length isearch-string) lazy-highlight-delay-max-chars) 0 delay) > + nil function))) Currently, run-with-idle-timer is used for lazy-highlight-initial-delay, and run-at-time for lazy-highlight-interval. But you replaced all with run-with-idle-timer. Any reason not to use run-at-time for lazy-highlight-interval to reduce delays for quickly finishing the already started lazily highlighting successive matches?