Function: reftex-do-parse
reftex-do-parse is an autoloaded and byte-compiled function defined in
reftex-parse.el.gz.
Signature
(reftex-do-parse RESCAN &optional FILE)
Documentation
Do a document rescan.
When allowed, do only a partial scan from FILE.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex-parse.el.gz
;;;###autoload
(defun reftex-do-parse (rescan &optional file)
"Do a document rescan.
When allowed, do only a partial scan from FILE."
;; Normalize the rescan argument
(setq rescan (cond ((eq rescan t) t)
((eq rescan 1) 1)
((equal rescan '(4)) t)
((equal rescan '(16)) 1)
(t 1)))
;; Partial scans only when allowed
(unless reftex-enable-partial-scans
(setq rescan 1))
;; Do the scanning.
(let* ((old-list (symbol-value reftex-docstruct-symbol))
(master (reftex-TeX-master-file))
(true-master (reftex--get-truename master))
(master-dir (file-name-as-directory (reftex--get-directory master)))
(file (or file (reftex--get-buffer-identifier)))
(true-file (reftex--get-truename file))
(bibview-cache (assq 'bibview-cache old-list))
(reftex--index-tags (cdr (assq 'index-tags old-list)))
from-file appendix docstruct tmp)
;; Make sure replacement is really an option here
(when (and (eq rescan t)
(not (and (member (list 'bof file) old-list)
(member (list 'eof file) old-list))))
;; Scan whole document because no such file section exists
(setq rescan 1))
(when (equal true-file true-master)
;; Scan whole document because this file is the master
(setq rescan 1))
;; From which file do we start?
(setq from-file
(cond ((eq rescan t) (or file master))
((eq rescan 1) master)
(t (error "This should not happen (reftex-do-parse)"))))
;; Reset index-tags if we scan everything
(if (equal rescan 1) (setq reftex--index-tags nil))
;; Find active toc entry and initialize section-numbers
(setq reftex-active-toc (reftex-last-assoc-before-elt
'toc (list 'bof from-file) old-list)
appendix (reftex-last-assoc-before-elt
'appendix (list 'bof from-file) old-list))
(reftex-init-section-numbers reftex-active-toc appendix)
(if (eq rescan 1)
(message "Scanning entire document...")
(message "Scanning document from %s..." from-file))
(reftex-with-special-syntax
(save-window-excursion
(save-excursion
(unwind-protect
(setq docstruct
(reftex-parse-from-file
from-file docstruct master-dir))
(reftex-kill-temporary-buffers)))))
(message "Scanning document... done")
;; Turn the list around.
(setq docstruct (nreverse docstruct))
;; Set or insert
(setq docstruct (reftex-replace-label-list-segment
old-list docstruct (eq rescan 1)))
;; Add all missing information
(unless (assq 'label-numbers docstruct)
(push (cons 'label-numbers nil) docstruct))
(unless (assq 'master-dir docstruct)
(push (cons 'master-dir master-dir) docstruct))
(unless (assq 'bibview-cache docstruct)
(push (cons 'bibview-cache (cdr bibview-cache)) docstruct))
(let* ((bof1 (memq (assq 'bof docstruct) docstruct))
(bof2 (assq 'bof (cdr bof1)))
(is-multi (not (not (and bof1 bof2))))
(entry (or (assq 'is-multi docstruct)
(car (push (list 'is-multi is-multi) docstruct)))))
(setcdr entry (cons is-multi nil)))
(and reftex--index-tags
(setq reftex--index-tags (sort reftex--index-tags #'string<)))
(let ((index-tag-cell (assq 'index-tags docstruct)))
(if index-tag-cell
(setcdr index-tag-cell reftex--index-tags)
(push (cons 'index-tags reftex--index-tags) docstruct)))
(unless (assq 'xr docstruct)
(let* ((allxr (reftex-all-assq 'xr-doc docstruct))
(alist (mapcar
(lambda (x)
(if (setq tmp (reftex-locate-file (nth 2 x) "tex"
master-dir))
(cons (nth 1 x) tmp)
(message "Can't find external document %s"
(nth 2 x))
nil))
allxr))
(alist (delq nil alist))
(allprefix (delq nil (mapcar #'car alist)))
(regexp (if allprefix
(concat "\\`\\("
(mapconcat #'identity allprefix "\\|")
"\\)")
"\\\\\\\\\\\\"))) ; this will never match
(push (list 'xr alist regexp) docstruct)))
(set reftex-docstruct-symbol docstruct)
(put reftex-docstruct-symbol 'modified t)))