@item lazy-highlight-initial-delay
@vindex lazy-highlight-initial-delay
Time in seconds to wait before highlighting visible matches.
+Applies only if the search string is less than
+@code{lazy-highlight-no-delay-length} characters long.
+
+@item lazy-highlight-no-delay-length
+@vindex lazy-highlight-no-delay-length
+For search strings at least as long as the value of this variable,
+lazy highlighting of matches starts immediately.
@item lazy-highlight-interval
@vindex lazy-highlight-interval
input; functions such as 'kbd' and 'read-kbd-macro' accept both styles
as equivalent (they have done so for a long time).
++++
+** New user option 'lazy-highlight-no-delay-length'.
+Lazy highlighting of matches in Isearch now starts immediately if the
+search string is at least this long. 'lazy-highlight-initial-delay'
+still applies for shorter search strings, which avoids flicker in the
+search buffer due to too many matches being highlighted.
+
\f
* Editing Changes in Emacs 28.1
: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
(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
(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)
(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