aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2017-02-22 01:22:18 +0200
committerJuri Linkov2017-02-22 01:22:18 +0200
commitf2191691d4e814d38369053cdec428ee2142ab18 (patch)
tree1038df189dd5ff5c4687589f9388bdfe4a2195e7
parent217eaf6932f68049e8f7f207b153c09ca85c7032 (diff)
downloademacs-f2191691d4e814d38369053cdec428ee2142ab18.tar.gz
emacs-f2191691d4e814d38369053cdec428ee2142ab18.zip
Avoid flicker in lazy-highlight by doing all updates without redisplay.
* lisp/isearch.el (lazy-highlight-max-at-a-time): Change default value from 20 to nil to not trigger redisplay between updating iterations. (lazy-highlight-cleanup): New arg ‘procrastinate’ to not remove overlays when non-nil. (isearch-lazy-highlight-new-loop): Call lazy-highlight-cleanup with non-nil second arg when the search string is not empty. Run timer with isearch-lazy-highlight-start instead of isearch-lazy-highlight-update. (isearch-lazy-highlight-start): New function. (Bug#25751)
-rw-r--r--lisp/isearch.el28
1 files changed, 17 insertions, 11 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 526243554b0..d0fb15ec641 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -332,7 +332,7 @@ If this is nil, extra highlighting can be \"manually\" removed with
332 'lazy-highlight-max-at-a-time 332 'lazy-highlight-max-at-a-time
333 "22.1") 333 "22.1")
334 334
335(defcustom lazy-highlight-max-at-a-time 20 335(defcustom lazy-highlight-max-at-a-time nil ; 20 (bug#25751)
336 "Maximum matches to highlight at a time (for `lazy-highlight'). 336 "Maximum matches to highlight at a time (for `lazy-highlight').
337Larger values may reduce Isearch's responsiveness to user input; 337Larger values may reduce Isearch's responsiveness to user input;
338smaller values make matches highlight slowly. 338smaller values make matches highlight slowly.
@@ -3122,17 +3122,18 @@ since they have special meaning in a regexp."
3122(defvar isearch-lazy-highlight-forward nil) 3122(defvar isearch-lazy-highlight-forward nil)
3123(defvar isearch-lazy-highlight-error nil) 3123(defvar isearch-lazy-highlight-error nil)
3124 3124
3125(defun lazy-highlight-cleanup (&optional force) 3125(defun lazy-highlight-cleanup (&optional force procrastinate)
3126 "Stop lazy highlighting and remove extra highlighting from current buffer. 3126 "Stop lazy highlighting and remove extra highlighting from current buffer.
3127FORCE non-nil means do it whether or not `lazy-highlight-cleanup' 3127FORCE non-nil means do it whether or not `lazy-highlight-cleanup' is nil.
3128is nil. This function is called when exiting an incremental search if 3128PROCRASTINATE non-nil means postpone cleanup to a later time.
3129This function is called when exiting an incremental search if
3129`lazy-highlight-cleanup' is non-nil." 3130`lazy-highlight-cleanup' is non-nil."
3130 (interactive '(t)) 3131 (interactive '(t))
3131 (if (or force lazy-highlight-cleanup) 3132 (when (and (or force lazy-highlight-cleanup) (not procrastinate))
3132 (while isearch-lazy-highlight-overlays 3133 (while isearch-lazy-highlight-overlays
3133 (delete-overlay (car isearch-lazy-highlight-overlays)) 3134 (delete-overlay (car isearch-lazy-highlight-overlays))
3134 (setq isearch-lazy-highlight-overlays 3135 (setq isearch-lazy-highlight-overlays
3135 (cdr isearch-lazy-highlight-overlays)))) 3136 (cdr isearch-lazy-highlight-overlays))))
3136 (when isearch-lazy-highlight-timer 3137 (when isearch-lazy-highlight-timer
3137 (cancel-timer isearch-lazy-highlight-timer) 3138 (cancel-timer isearch-lazy-highlight-timer)
3138 (setq isearch-lazy-highlight-timer nil))) 3139 (setq isearch-lazy-highlight-timer nil)))
@@ -3173,7 +3174,7 @@ by other Emacs features."
3173 (not (equal isearch-error 3174 (not (equal isearch-error
3174 isearch-lazy-highlight-error)))) 3175 isearch-lazy-highlight-error))))
3175 ;; something important did indeed change 3176 ;; something important did indeed change
3176 (lazy-highlight-cleanup t) ;kill old loop & remove overlays 3177 (lazy-highlight-cleanup t (not (equal isearch-string ""))) ;stop old timer
3177 (setq isearch-lazy-highlight-error isearch-error) 3178 (setq isearch-lazy-highlight-error isearch-error)
3178 ;; It used to check for `(not isearch-error)' here, but actually 3179 ;; It used to check for `(not isearch-error)' here, but actually
3179 ;; lazy-highlighting might find matches to highlight even when 3180 ;; lazy-highlighting might find matches to highlight even when
@@ -3204,7 +3205,7 @@ by other Emacs features."
3204 (unless (equal isearch-string "") 3205 (unless (equal isearch-string "")
3205 (setq isearch-lazy-highlight-timer 3206 (setq isearch-lazy-highlight-timer
3206 (run-with-idle-timer lazy-highlight-initial-delay nil 3207 (run-with-idle-timer lazy-highlight-initial-delay nil
3207 'isearch-lazy-highlight-update))))) 3208 'isearch-lazy-highlight-start)))))
3208 3209
3209(defun isearch-lazy-highlight-search () 3210(defun isearch-lazy-highlight-search ()
3210 "Search ahead for the next or previous match, for lazy highlighting. 3211 "Search ahead for the next or previous match, for lazy highlighting.
@@ -3249,6 +3250,11 @@ Attempt to do the search exactly the way the pending Isearch would."
3249 success) 3250 success)
3250 (error nil))) 3251 (error nil)))
3251 3252
3253(defun isearch-lazy-highlight-start ()
3254 "Start a new lazy-highlight updating loop."
3255 (lazy-highlight-cleanup t) ;remove old overlays
3256 (isearch-lazy-highlight-update))
3257
3252(defun isearch-lazy-highlight-update () 3258(defun isearch-lazy-highlight-update ()
3253 "Update highlighting of other matches for current search." 3259 "Update highlighting of other matches for current search."
3254 (let ((max lazy-highlight-max-at-a-time) 3260 (let ((max lazy-highlight-max-at-a-time)