Function: bib-display-or-find-label

bib-display-or-find-label is a byte-compiled function defined in bib-cite.el.

Signature

(bib-display-or-find-label THE-REGEXP DISPLAYF)

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/bib-cite.el
;;--------------------------------------------------------------------------
;; Functions for Displaying or moving to matching \ref or \label command

(defun bib-display-or-find-label (the-regexp displayf)
;; work horse for bib-find-label and bib-display-label
  (let* ((masterfile (bib-master-file))
         (masterdir (and masterfile
                         (file-name-directory masterfile)))
         (new-point)(new-buffer))
    (save-excursion
      ;; Now we are either in a simple file, or with a multi-file document
      (cond
       (masterfile                   ;Multi-file document
        (cond
         (displayf                  ;Display only
          (set-buffer (bib-etags-find-noselect the-regexp masterdir))
          (re-search-forward the-regexp nil t)
          ;; ...because tags puts point on beginning of line
          (if (string-match "^\\\\\\\\label" the-regexp)
              (bib-display-this-environment) ;display the label's environment
            (bib-display-this-ref)))    ;     display the ref's context
         (t                         ;Move to it
          (setq new-buffer (bib-etags-find-noselect the-regexp masterdir))
          (if bib-novice
              (message
               (substitute-command-keys
                (concat "Use \\[bib-find-next] to find the next occurrence "
                        "and C-u \\[bib-find-next] to find previous."))))
          (if (equal new-buffer (current-buffer))
              (setq new-point (point)))))) ;Moving with the same buffer
       (t                           ;Single-file document
        (goto-char (point-min))
        (cond
         ((re-search-forward the-regexp nil t)
          (if displayf
              (if (string-match "^\\\\label" the-regexp)
                  (bib-display-this-environment) ;Display the environment
                (bib-display-this-ref)) ;         display the ref's context
            (setq new-point (match-beginning 0))  ;or move there
            (if (string-match "{\\(.*\\)}" the-regexp)
                (setq bib-cite-search-ring (match-string 1 the-regexp)))
            (if bib-novice
                (message
                 (substitute-command-keys
                  (concat "Use \\[bib-find-next] to find the next occurrence "
                          "and C-u \\[bib-find-next] to find previous."))))))
         (t
          (message "Sorry, cannot find it (%s)" the-regexp))))))
    (if new-point
        (progn
          (push-mark (point) t nil)   ;We've moving there... push mark
          (goto-char new-point))
      (if new-buffer                    ;We've changing buffer
          ;;(switch-to-buffer new-buffer)
          (funcall bib-switch-to-buffer-function new-buffer)))
    (if (bib-Is-hidden)
        (save-excursion
          (beginning-of-line)
          (outline-show-entry)))))