diff options
author | Augusto Stoffel <arstoffel@gmail.com> | 2021-01-27 16:09:38 +0100 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2021-01-30 20:48:28 +0200 |
commit | ece7425c22633196ae164cb6aa0e6d77fabe9f81 (patch) | |
tree | fff63f0d5b3c0a8d17041c88b8ee24de455c8ad9 /lisp/isearch.el | |
parent | 3555657585bb2c1809fa6abff7f565a8c7f226eb (diff) | |
download | emacs-ece7425c22633196ae164cb6aa0e6d77fabe9f81.tar.gz emacs-ece7425c22633196ae164cb6aa0e6d77fabe9f81.tar.bz2 emacs-ece7425c22633196ae164cb6aa0e6d77fabe9f81.zip |
Reduce flicker in Isearch mode
Lazy highlighting now happens immediately when the search string is at
least as long as the value of the new custom variable
`lazy-highlight-no-delay-length`. Also avoid updating the lazy
count in the echo area too often.
* isearch.el (lazy-highlight-no-delay-length): New defcustom.
* isearch.el (lazy-lazy-count-format): Avoid a momentarily incorrect
count when reversing search direction.
* isearch.el (isearch-lazy-highlight-new-loop): Avoid a call to
`isearch-message` that is quickly succeed by a second echo area
update, thus causing flicker.
* isearch.el (isearch-lazy-highlight-new-loop):
Start lazy highlight immediately if appropriate.
* etc/NEWS: Announce the change.
* doc/emacs/search.texi: Document `lazy-highlight-no-delay-length'.
Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r-- | lisp/isearch.el | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index a1e3fe2c3f0..a6978a4c164 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -352,10 +352,20 @@ If this is nil, extra highlighting can be \"manually\" removed with :group 'lazy-highlight) (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 when the search string is less than +`lazy-highlight-no-delay-length' characters long." :type 'number :group 'lazy-highlight) +(defcustom lazy-highlight-no-delay-length 3 + "For search strings at least this long, lazy highlight starts immediately. +For shorter search strings, `lazy-highlight-initial-delay' +applies." + :type 'number + :group 'lazy-highlight + :version "28.1") + (defcustom lazy-highlight-interval 0 ; 0.0625 "Seconds between lazily highlighting successive matches." :type 'number @@ -3356,7 +3366,7 @@ isearch-message-suffix prompt. Otherwise, for isearch-message-prefix." (not isearch-error) (not isearch-suspended)) (format format-string - (if isearch-forward + (if isearch-lazy-highlight-forward isearch-lazy-count-current (if (eq isearch-lazy-count-current 0) 0 @@ -3916,7 +3926,8 @@ by other Emacs features." (clrhash isearch-lazy-count-hash) (setq isearch-lazy-count-current nil isearch-lazy-count-total nil) - (isearch-message))) + ;; Delay updating the message if possible, to avoid flicker + (when (string-equal isearch-string "") (isearch-message)))) (setq isearch-lazy-highlight-window-start-changed nil) (setq isearch-lazy-highlight-window-end-changed nil) (setq isearch-lazy-highlight-error isearch-error) @@ -3961,7 +3972,11 @@ by other Emacs features." (point-min)))) (unless (equal isearch-string "") (setq isearch-lazy-highlight-timer - (run-with-idle-timer lazy-highlight-initial-delay nil + (run-with-idle-timer (if (>= (length isearch-string) + lazy-highlight-no-delay-length) + 0 + lazy-highlight-initial-delay) + nil 'isearch-lazy-highlight-start)))) ;; Update the current match number only in isearch-mode and ;; unless isearch-mode is used specially with isearch-message-function |