Function: xref--buf-pairs-iterator
xref--buf-pairs-iterator is a byte-compiled function defined in
xref.el.gz.
Signature
(xref--buf-pairs-iterator XREFS)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--buf-pairs-iterator (xrefs)
(let (chunk-done item next-pair file-buf pairs all-pairs)
(lambda (action)
(pcase action
(:next
(when (or xrefs next-pair)
(setq chunk-done nil)
(when next-pair
(setq file-buf (marker-buffer (car next-pair))
pairs (list next-pair)
next-pair nil))
(while (and (not chunk-done)
(setq item (pop xrefs)))
(save-excursion
(let* ((loc (xref-item-location item))
(beg (xref-location-marker loc))
(end (move-marker (make-marker)
(+ beg (xref-match-length item))
(marker-buffer beg))))
(let ((pair (cons beg end)))
(push pair all-pairs)
;; Perform sanity check first.
(xref--goto-location loc)
(if (xref--outdated-p item)
(message "Search result out of date, skipping")
(cond
((null file-buf)
(setq file-buf (marker-buffer beg))
(push pair pairs))
((equal file-buf (marker-buffer beg))
(push pair pairs))
(t
(setq chunk-done t
next-pair pair))))))))
(cons file-buf (nreverse pairs))))
(:cleanup
(dolist (pair all-pairs)
(move-marker (car pair) nil)
(move-marker (cdr pair) nil)))))))