Function: LaTeX-auto-cleanup
LaTeX-auto-cleanup is a byte-compiled function defined in latex.el.
Signature
(LaTeX-auto-cleanup)
Documentation
Cleanup after LaTeX parsing.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-auto-cleanup ()
"Cleanup after LaTeX parsing."
;; Cleanup BibTeX/Biber files
(setq LaTeX-auto-bibliography
(apply #'append (mapcar (lambda (arg)
(split-string arg ","))
LaTeX-auto-bibliography)))
;; Cleanup document classes and packages
(unless (null LaTeX-auto-style)
(while LaTeX-auto-style
(let* ((entry (car LaTeX-auto-style))
(options (nth 0 entry))
(style (nth 1 entry))
(class (nth 2 entry)))
;; Next document style.
(setq LaTeX-auto-style (cdr LaTeX-auto-style))
;; Get the options.
(setq options (LaTeX-listify-package-options options))
;; Treat documentclass/documentstyle specially.
(if (or (string-equal "package" class)
(string-equal "Package" class))
(dolist (elt (split-string
style "\\([ \t\r\n]\\|%[^\n\r]*[\n\r]\\|,\\)+"))
;; Append style to the style list.
(add-to-list 'TeX-auto-file elt t)
;; Append to `LaTeX-provided-package-options' the name of the
;; package and the options provided to it at load time.
(TeX-add-to-alist 'LaTeX-provided-package-options
(list (cons elt options))))
;; And a special "art10" style file combining style and size.
(add-to-list 'TeX-auto-file style t)
(add-to-list 'TeX-auto-file
(concat
(cond ((string-equal "article" style)
"art")
((string-equal "book" style)
"bk")
((string-equal "report" style)
"rep")
((string-equal "jarticle" style)
"jart")
((string-equal "jbook" style)
"jbk")
((string-equal "jreport" style)
"jrep")
((string-equal "j-article" style)
"j-art")
((string-equal "j-book" style)
"j-bk")
((string-equal "j-report" style )
"j-rep")
(t style))
(cond ((member "11pt" options)
"11")
((member "12pt" options)
"12")
(t
"10")))
t)
(TeX-add-to-alist 'LaTeX-provided-class-options
(list (cons style options))))
;; The third argument if "class" indicates LaTeX2e features.
(cond ((or (string-equal class "class")
(string-equal class "Class"))
(add-to-list 'TeX-auto-file "latex2e"))
((string-equal class "style")
(add-to-list 'TeX-auto-file "latex2"))))))
;; Cleanup optional arguments
(mapc (lambda (entry)
;; If we're renewcommand-ing and there is already an entry
;; in `TeX-auto-symbol', delete it first:
(when (and (string= (nth 2 entry) "re")
(assoc (car entry) TeX-auto-symbol))
(setq TeX-auto-symbol
(assq-delete-all (car (assoc (car entry)
TeX-auto-symbol))
TeX-auto-symbol)))
(add-to-list 'TeX-auto-symbol
(list (nth 0 entry)
(string-to-number (nth 1 entry)))))
LaTeX-auto-arguments)
;; Cleanup for marcos defined with former xparse commands:
(LaTeX-xparse-macro-parse 'mac)
;; Cleanup default optional arguments
(mapc (lambda (entry)
;; If we're renewcommand-ing and there is already an entry
;; in `TeX-auto-symbol', delete it first:
(when (and (string= (nth 3 entry) "re")
(assoc (car entry) TeX-auto-symbol))
(setq TeX-auto-symbol
(assq-delete-all (car (assoc (car entry)
TeX-auto-symbol))
TeX-auto-symbol)))
(add-to-list 'TeX-auto-symbol
(list (nth 0 entry)
(vector "argument")
(1- (string-to-number (nth 1 entry))))))
LaTeX-auto-optional)
;; Cleanup environments arguments
(mapc (lambda (entry)
;; If we're renewenvironment-ing and there is already an
;; entry in `LaTeX-auto-environment', delete it first:
(when (and (string= (nth 2 entry) "re")
(assoc (car entry) LaTeX-auto-environment))
(setq LaTeX-auto-environment
(assq-delete-all (car (assoc (car entry)
LaTeX-auto-environment))
LaTeX-auto-environment)))
(add-to-list 'LaTeX-auto-environment
(list (nth 0 entry)
(string-to-number (nth 1 entry)))))
LaTeX-auto-env-args)
;; Ditto for environments with an optional arg
(mapc (lambda (entry)
;; If we're renewenvironment-ing and there is already an
;; entry in `LaTeX-auto-environment', delete it first:
(when (and (string= (nth 2 entry) "re")
(assoc (car entry) LaTeX-auto-environment))
(setq LaTeX-auto-environment
(assq-delete-all (car (assoc (car entry)
LaTeX-auto-environment))
LaTeX-auto-environment)))
(add-to-list 'LaTeX-auto-environment
(list (nth 0 entry) #'LaTeX-env-args (vector "argument")
(1- (string-to-number (nth 1 entry))))))
LaTeX-auto-env-args-with-opt)
;; Cleanup for enviroments defined with former xparse commands:
(LaTeX-xparse-macro-parse 'env)
;; Cleanup use of def to add environments
;; NOTE: This uses an O(N^2) algorithm, while an O(N log N)
;; algorithm is possible.
(mapc (lambda (symbol)
(if (not (TeX-member symbol TeX-auto-symbol #'equal))
;; No matching symbol, insert in list
(add-to-list 'TeX-auto-symbol (concat "end" symbol))
;; Matching symbol found, remove from list
(if (equal (car TeX-auto-symbol) symbol)
;; Is it the first symbol?
(setq TeX-auto-symbol (cdr TeX-auto-symbol))
;; Nope! Travel the list
(let ((list TeX-auto-symbol))
(while (consp (cdr list))
;; Until we find it.
(if (equal (car (cdr list)) symbol)
;; Then remove it.
(setcdr list (cdr (cdr list))))
(setq list (cdr list)))))
;; and add the symbol as an environment.
(add-to-list 'LaTeX-auto-environment symbol)))
LaTeX-auto-end-symbol))