Go to the previous, next section.

Automatic Parsing of TeX files.

AUC TeX depends heavily on being able to extract information from the buffers by parsing them. Since parsing the buffer can be somewhat slow, the parsing is initially disabled. You are encouraged to enable them by adding the following lines to your `.emacs' file.

(setq TeX-parse-self t) ; Enable parse on load.
(setq TeX-auto-save t) ; Enable parse on save.

The later command will make AUC TeX store the parsed information in an `auto' subdirectory in the directory each time the TeX files are stored, see section Automatic Customization for a Directory. If AUC TeX finds the pre-parsed information when loading a file, it will not need to reparse the buffer. The information in the `auto' directory is also useful for multifile documents see section Multifile Documents, since it allows each file to access the parsed information from all the other files in the document. This is done by first reading the information from the master file, and then recursively the information from each file stored in the master file.

The variables can also be done on a per file basis, by changing the file local variables.

% Local Variables: 
% TeX-parse-self: t
% TeX-auto-save: t
% End: 

Even when you have disabled the automatic parsing, you can force the generation of style information by pressing C-c C-n. This is often the best choice, as you will be able to decide when it is necessary to reparse the file.

User Option: TeX-parse-self

Parse file after loading it if no style hook is found for it.

User Option: TeX-auto-save

Automatically save style information when saving the buffer.

Command: TeX-normal-mode arg

(C-c C-n) Remove all information about this buffer, and apply the style hooks again. Save buffer first including style information. With optional argument, also reload the style hooks.

When AUC TeX saves your buffer, it will by default convert all tabs in your buffer into spaces. To disable this behaviour, insert the following in your `.emacs' file.

(setq TeX-auto-untabify nil)

User Option: TeX-auto-untabify

Automatically remove all tabs from a file before saving it.

Instead of disabling the parsing entirely, you can also speed it significantly up by limiting the information it will search for (and store) when parsing the buffer. You can do this by setting the default values for the buffer local variables TeX-auto-regexp-list and TeX-auto-parse-length in your `.emacs' file.

;; Only parse \documentstyle information.
(setq-default TeX-auto-regexp-list 'LaTeX-auto-minimal-regexp-list) 
;; The documentstyle command is usually near the beginning.
(setq-default TeX-auto-parse-length 2000)

This example will speed the parsing up significantly, but AUC TeX will not longer be able to provide completion for labels, macros, environments, or bibitems specified in the document, nor will it know what files belong to the document.

These variables can also be specified on a per file basis, by changing the file local variables.

% Local Variables: 
% TeX-auto-regexp-list: TeX-auto-full-regexp-list
% TeX-auto-parse-length: 999999
% End: 

User Option: TeX-auto-regexp-list

List of regular expresions used for parsing the current file.

User Option: TeX-auto-parse-length

Maximal length of TeX file that will be parsed.

The pre-specified lists of regexps are defined below. You can use these before loading AUC TeX by quoting them, as in the example above.

Constant: TeX-auto-empty-regexp-list

Parse nothing

Constant: LaTeX-auto-minimal-regexp-list

Only parse documentstyle.

Constant: LaTeX-auto-label-regexp-list

Only parse LaTeX labels.

Constant: LaTeX-auto-regexp-list

Parse common LaTeX commands.

Constant: plain-TeX-auto-regexp-list

Parse common plain TeX commands.

Constant: TeX-auto-full-regexp-list

Parse all TeX and LaTeX commands that AUC TeX can use.

Go to the previous, next section.