Function: reftex-toc-visit-location
reftex-toc-visit-location is a byte-compiled function defined in
reftex-toc.el.gz.
Signature
(reftex-toc-visit-location &optional FINAL NO-REVISIT)
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex-toc.el.gz
(defun reftex-toc-visit-location (&optional final no-revisit)
;; Visit the tex file corresponding to the TOC entry on the current line.
;; If FINAL is t, stay there
;; If FINAL is 'hide, hide the TOC window.
;; Otherwise, move cursor back into TOC window.
;; NO-REVISIT means don't visit files, just use live buffers.
;; This function is pretty clever about finding back a section heading,
;; even if the buffer is not live, or things like outline, x-symbol etc.
;; have been active.
(let* ((toc (get-text-property (point) :data))
(toc-window (selected-window))
match)
(unless toc (error "Don't know which TOC line to visit"))
(cond
((eq (car toc) 'toc)
;; a toc entry
(setq match (reftex-toc-find-section toc no-revisit)))
((eq (car toc) 'index)
;; an index entry
(setq match (reftex-index-show-entry toc no-revisit)))
((memq (car toc) '(bof eof))
;; A file entry
(setq match
(let ((where (car toc))
(file (nth 1 toc)))
(if (or (not no-revisit) (find-buffer-visiting file))
(progn
(switch-to-buffer-other-window
(reftex-get-file-buffer-force file nil))
(goto-char (if (eq where 'bof) (point-min) (point-max))))
(message "%s" reftex-no-follow-message) nil))))
((stringp (car toc))
;; a label
(setq match (reftex-show-label-location toc reftex-callback-fwd
no-revisit t))))
(unless match
(select-window toc-window)
(error "Cannot find location"))
;; Use the `final' parameter to decide what to do next.
(cond
((eq final t)
(with-selected-window toc-window
(reftex-unhighlight 0)))
((eq final 'hide)
(let ((window (selected-window))
(buffer (window-buffer)))
(unless (eq window toc-window) ;FIXME: Can this happen?
(with-selected-window toc-window
(reftex-unhighlight 0)
(or (one-window-p) (delete-window))))
;; If window is still live, buffer is already visible
;; so let's not make it visible in yet-another-window.
(unless (window-live-p window)
;; FIXME: How could window not be live?
(pop-to-buffer-same-window buffer))
(reftex-re-enlarge)))
(t
(unless (eq (selected-frame) (window-frame toc-window))
;; Make sure `toc-window' is not just selected but has focus.
(select-frame-set-input-focus (window-frame toc-window)))
(select-window toc-window)))))