Function: isearch-lazy-highlight-buffer-update

isearch-lazy-highlight-buffer-update is a byte-compiled function defined in isearch.el.gz.

Signature

(isearch-lazy-highlight-buffer-update)

Documentation

Update highlighting of other matches in the full buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/isearch.el.gz
(defun isearch-lazy-highlight-buffer-update ()
  "Update highlighting of other matches in the full buffer."
  (let ((max lazy-highlight-buffer-max-at-a-time)
        (looping t)
        nomore opoint window-start window-end)
    (with-local-quit
      (save-selected-window
	(if (and (window-live-p isearch-lazy-highlight-window)
		 (not (memq (selected-window) isearch-lazy-highlight-window-group)))
	    (select-window isearch-lazy-highlight-window))
	(setq opoint (point))
	(setq window-start (window-group-start))
	(setq window-end (window-group-end))
	(save-excursion
	  (save-match-data
	    (goto-char (if isearch-lazy-highlight-forward
			   isearch-lazy-highlight-end
			 isearch-lazy-highlight-start))
	    (while looping
	      (let* ((bound (if isearch-lazy-highlight-forward
				(or isearch-lazy-highlight-end-limit (point-max))
			      (or isearch-lazy-highlight-start-limit (point-min))))
		     (found (isearch-lazy-highlight-search
			     isearch-lazy-highlight-last-string
			     bound)))
		(when max
		  (setq max (1- max))
		  (if (<= max 0)
		      (setq looping nil)))
		(if found
		    (let ((mb (match-beginning 0))
			  (me (match-end 0)))
		      (if (= mb me)	;zero-length match
			  (if isearch-lazy-highlight-forward
			      (if (= mb (point-max))
				  (setq found nil)
				(forward-char 1))
			    (if (= mb (point-min))
				(setq found nil)
			      (forward-char -1)))
			(when isearch-lazy-count
			  ;; Count as invisible when can't open overlay,
			  ;; but don't leave search-invisible with the
			  ;; value `open' since then lazy-highlight
			  ;; will open all overlays with matches.
			  (if (not (let ((search-invisible
					  (if (eq isearch-lazy-highlight-invisible 'open)
					      'can-be-opened
					    isearch-lazy-highlight-invisible)))
				     (funcall isearch-filter-predicate mb me)))
			      (setq isearch-lazy-count-invisible
				    (1+ (or isearch-lazy-count-invisible 0)))
			    (setq isearch-lazy-count-total
				  (1+ (or isearch-lazy-count-total 0)))
			    (puthash (if isearch-lazy-highlight-forward me mb)
				     isearch-lazy-count-total
				     isearch-lazy-count-hash)))
			;; Don't highlight the match when this loop is used
			;; only to count matches or when matches were already
			;; highlighted within the current window boundaries
			;; by isearch-lazy-highlight-update
			(unless (or (not isearch-lazy-highlight-buffer)
				    (and (>= mb window-start) (<= me window-end)))
			  ;; non-zero-length match
			  (isearch-lazy-highlight-match mb me)))
		      ;; Remember the current position of point for
		      ;; the next call of `isearch-lazy-highlight-update'
		      ;; when `lazy-highlight-buffer-max-at-a-time' is too small.
		      (if isearch-lazy-highlight-forward
			  (setq isearch-lazy-highlight-end (point))
			(setq isearch-lazy-highlight-start (point)))))

		;; not found or zero-length match at the search bound
		(if (not found)
		    (setq looping nil
			  nomore  t))))
	    (if nomore
		(when isearch-lazy-count
		  (unless isearch-lazy-count-total
		    (setq isearch-lazy-count-total 0))
		  (setq isearch-lazy-count-current
			(gethash opoint isearch-lazy-count-hash 0))
                  (when (and isearch-mode (null isearch-message-function))
                    (isearch-message)))
	      (setq isearch-lazy-highlight-timer
		    (run-at-time lazy-highlight-interval nil
				 'isearch-lazy-highlight-buffer-update)))))
        (when (and nomore isearch-lazy-count)
          (run-hooks 'lazy-count-update-hook))))))