Function: xref--outdated-p

xref--outdated-p is a byte-compiled function defined in xref.el.gz.

Signature

(xref--outdated-p ITEM)

Documentation

Check that the match location at current position is up-to-date.

ITEM is an xref item which is expected to be produced by a search command and have summary that matches buffer contents near point. Depending on whether it's the first of the matches on the line, the summary should either start from bol, or only match after point.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--outdated-p (item)
  "Check that the match location at current position is up-to-date.

ITEM is an xref item which is expected to be produced by a search
command and have summary that matches buffer contents near point.
Depending on whether it's the first of the matches on the line,
the summary should either start from bol, or only match after
point."
  ;; FIXME: The check should most likely be a generic function instead
  ;; of the assumption that all matches' summaries relate to the
  ;; buffer text in a particular way.
  (let* ((summary (xref-item-summary item))
         ;; Sometimes buffer contents include ^M, and sometimes Grep
         ;; output includes it, and they don't always match.
         (strip (lambda (s) (if (string-match "\r\\'" s)
                           (substring-no-properties s 0 -1)
                         s)))
         (stripped-summary (funcall strip summary))
         (lendpos (line-end-position))
         (check (lambda ()
                  (let ((comparison-end
                         (+ (point) (length stripped-summary))))
                    (and (>= lendpos comparison-end)
                         (equal stripped-summary
                                (buffer-substring-no-properties
                                 (point) comparison-end)))))))
    (not
     (or
      ;; Either summary contains match text and after
      ;; (2nd+ match on the line)...
      (funcall check)
      ;; ...or it starts at bol, includes the match and after.
      (and (< (point) (+ (line-beginning-position)
                         (length stripped-summary)))
           (save-excursion
             (forward-line 0)
             (funcall check)))))))