Function: reftex-toc-find-section

reftex-toc-find-section is a byte-compiled function defined in reftex-toc.el.gz.

Signature

(reftex-toc-find-section TOC &optional NO-REVISIT)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-toc.el.gz
(defun reftex-toc-find-section (toc &optional no-revisit)
  (let* ((file (nth 3 toc))
         (marker (nth 4 toc))
         (level (nth 5 toc))
         (literal (nth 7 toc))
         (emergency-point (nth 8 toc))
         (match
          (cond
           ((and (markerp marker) (marker-buffer marker))
            ;; Buffer is still live and we have the marker.  Should be easy.
            (switch-to-buffer-other-window (marker-buffer marker))
            (push-mark nil)
            (goto-char (marker-position marker))
            (or (looking-at (regexp-quote literal))
                (looking-at (reftex-make-regexp-allow-for-ctrl-m literal))
                (looking-at (reftex-make-desperate-section-regexp literal))
                (looking-at (concat "\\\\"
                                    (regexp-quote
                                     (car
                                      (rassq level
                                             reftex-section-levels-all)))
                                    "[[{]?"))))
           ((or (not no-revisit)
                (find-buffer-visiting file))
            ;; Marker is lost.  Use the backup method.
            (switch-to-buffer-other-window
             (reftex-get-file-buffer-force file nil))
            (goto-char (or emergency-point (point-min)))
            (or (looking-at (regexp-quote literal))
                (let ((len (length literal)))
                  (or (reftex-nearest-match (regexp-quote literal) len)
                      (reftex-nearest-match
                       (reftex-make-regexp-allow-for-ctrl-m literal) len)
                      (reftex-nearest-match
                       (reftex-make-desperate-section-regexp literal) len)))))
           (t (message "%s" reftex-no-follow-message) nil))))
    (when match
      (goto-char (match-beginning 0))
      (if (not (= (point) (point-max))) (recenter 1))
      (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
    match))