Function: xref--collect-matches-1

xref--collect-matches-1 is a byte-compiled function defined in xref.el.gz.

Signature

(xref--collect-matches-1 REGEXP FILE LINE LINE-BEG LINE-END SYNTAX-NEEDED)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--collect-matches-1 (regexp file line line-beg line-end syntax-needed)
  (let (matches
        stop beg end
        last-beg last-end
        summary-end)
    (when syntax-needed
      (syntax-propertize line-end))
    (while (not stop)
      (if (and
           ;; REGEXP might match an empty string.  Or line.
           (not (and last-beg (eql end line-beg)))
           (re-search-forward regexp line-end t))
          (setq beg (match-beginning 0)
                end (match-end 0)
                summary-end beg)
        (setq stop t
              summary-end line-end))
      (when last-beg
        (let* ((beg-column (- last-beg line-beg))
               (end-column (- last-end line-beg))
               (summary-start (if matches last-beg line-beg))
               (summary (buffer-substring summary-start
                                          summary-end))
               (loc (xref-make-file-location file line beg-column)))
          (add-face-text-property (- last-beg summary-start)
                                  (- last-end summary-start)
                                  'xref-match t summary)
          (push (xref-make-match summary loc (- end-column beg-column))
                matches)))
      (setq last-beg beg
            last-end end))
    (nreverse matches)))