Function: bib-cite--next-ref
bib-cite--next-ref is a byte-compiled function defined in bib-cite.el.
Signature
(bib-cite--next-ref STR &optional BKWD)
Documentation
Find the next or previous \ref to a given \label.
STR comes from the variable last-tag which the command bib-find
sets. Any non-nil PREV-P argument to bib-find-next sets BKWD here,
producing a backward search. The search itself follows the order in the
*xref* buffer produced by xref-find-apropos.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.2.0/bib-cite.el
(defun bib-cite--next-ref (str &optional bkwd)
"Find the next or previous \\ref to a given \\label.
STR comes from the variable `last-tag' which the command `bib-find'
sets. Any non-nil PREV-P argument to `bib-find-next' sets BKWD here,
producing a backward search. The search itself follows the order in the
*xref* buffer produced by `xref-find-apropos'."
(if str
(let* (notag
(lino (concat (number-to-string (line-number-at-pos nil t)) ":"))
(file (buffer-file-name))
(tag (substring-no-properties str))
(xrtag (seq-subseq tag (1+ (seq-position tag ?{))
(seq-position tag ?})))
(re (concat bib-ref-regexpc xrtag "}"))
(buf (xref-find-apropos xrtag)))
(if bkwd
(with-current-buffer buf
(search-forward file nil t)
(re-search-forward "^[^[:digit:][:space:][:cntrl:]]" nil 1)
(beginning-of-line)
(condition-case nil
(search-backward lino)
(error (progn
(while
(and
(re-search-backward
(concat
"\\(?1:^[^[:digit:][:space:][:cntrl:]]\\)\\|"
"^[[:space:]]*\\(?1:[[:digit:]]+:\\)")
nil 1)
(string-match
"[[:digit:]]+:"
(match-string-no-properties 1) nil t)
(setq notag t)
(string-version-lessp
lino (match-string-no-properties 1))
(setq notag 1)))
(end-of-line))))
(unless (or (re-search-backward re nil 1) (eq notag t) (bobp))
(forward-line -1))
(condition-case nil
(xref-quit-and-goto-xref)
(user-error (progn
(xref-quit-and-pop-marker-stack)
(message "No previous occurrence of %s" re)))))
(with-current-buffer buf
(search-forward file nil t)
(condition-case nil
(search-forward lino)
(error (progn
(setq notag t)
(while
(and
(re-search-forward
(concat
"\\(?1:^[^[:digit:][:space:][:cntrl:]]\\)\\|"
"^[[:space:]]*\\(?1:[[:digit:]]+:\\)")
nil 1)
(string-match
"[[:digit:]]+:"
(match-string-no-properties 1) nil t)
(string-version-lessp
(match-string-no-properties 1) lino))))))
(unless notag
(forward-line))
(re-search-forward re nil 1)
(condition-case nil
(xref-quit-and-goto-xref)
(user-error (progn
(xref-quit-and-pop-marker-stack)
(message "No next occurrence of %s" re)))))))
(message "Sorry, no previous reference to find. Use bib-find?")))