Function: isearch-highlight

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

Signature

(isearch-highlight BEG END &optional MATCH-DATA)

Source Code

;; Defined in /usr/src/emacs/lisp/isearch.el.gz
(defun isearch-highlight (beg end &optional match-data)
  (if search-highlight
      (if isearch-overlay
	  ;; Overlay already exists, just move it.
	  (move-overlay isearch-overlay beg end (current-buffer))
	;; Overlay doesn't exist, create it.
	(setq isearch-overlay (make-overlay beg end))
	;; 1001 is higher than lazy's 1000 and ediff's 100+
	(overlay-put isearch-overlay 'priority 1001)
	(overlay-put isearch-overlay 'face isearch-face)))

  (when (and search-highlight-submatches isearch-regexp)
    (mapc 'delete-overlay isearch-submatches-overlays)
    (setq isearch-submatches-overlays nil)
    ;; 'cddr' removes whole expression match from match-data
    (let ((submatch-data (cddr match-data))
          (group 0)
          b e ov face)
      (while submatch-data
        (setq b (pop submatch-data)
              e (pop submatch-data))
        (when (and (integer-or-marker-p b)
                   (integer-or-marker-p e))
          (setq ov (make-overlay b e)
                group (1+ group)
                face (intern-soft (format "isearch-group-%d" group)))
          ;; Recycle faces from beginning
          (unless (facep face)
            (setq group 1 face 'isearch-group-1))
          (overlay-put ov 'face face)
          (overlay-put ov 'priority 1002)
          (push ov isearch-submatches-overlays))))))