Function: TeX-command-sequence
TeX-command-sequence is a byte-compiled function defined in tex.el.
Signature
(TeX-command-sequence COMMAND &optional RESET FILE-FN)
Documentation
Run a sequence of TeX commands defined by COMMAND.
The COMMAND argument may be
* nil: no command will be run in this case
* a string with a command from TeX-command-list
* a non-nil list of strings, which are commands from
TeX-command-list; the car of the list is used as command to
be executed in the first run of TeX-command-sequence, the
cdr of the list will be passed to the function in the next
run, etc.
* a function name, returning a string which is command from
TeX-command-list; it will be funcall'd (without arguments!)
and used again in the next run of TeX-command-sequence.
* with any other value the function TeX-command-default(var)/TeX-command-default(fun) is
used to determine the command to run, until a stopping
condition is met.
This function runs at most
TeX-command-sequence-max-runs-same-command times the same
command in a row, and TeX-command-sequence-max-runs times in
total in any case. It ends when TeX-command-Show is the
command to be run.
A non-nil value for the optional argument RESET means this is the first run of the function and some variables need to be reset.
FILE-FN is a function of zero arguments returning the current
filename. Valid choices are TeX-master-file (default if
omitted) and TeX-region-file.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-command-sequence (command &optional reset file-fn)
"Run a sequence of TeX commands defined by COMMAND.
The COMMAND argument may be
* nil: no command will be run in this case
* a string with a command from `TeX-command-list'
* a non-nil list of strings, which are commands from
`TeX-command-list'; the car of the list is used as command to
be executed in the first run of `TeX-command-sequence', the
cdr of the list will be passed to the function in the next
run, etc.
* a function name, returning a string which is command from
`TeX-command-list'; it will be funcall'd (without arguments!)
and used again in the next run of `TeX-command-sequence'.
* with any other value the function `TeX-command-default' is
used to determine the command to run, until a stopping
condition is met.
This function runs at most
`TeX-command-sequence-max-runs-same-command' times the same
command in a row, and `TeX-command-sequence-max-runs' times in
total in any case. It ends when `TeX-command-Show' is the
command to be run.
A non-nil value for the optional argument RESET means this is the
first run of the function and some variables need to be reset.
FILE-FN is a function of zero arguments returning the current
filename. Valid choices are `TeX-master-file' (default if
omitted) and `TeX-region-file'."
(setq TeX-command-sequence-file-function (or file-fn #'TeX-master-file))
(if (null command)
(message "No command to run.")
(let (cmd process)
(cond
((stringp command)
(setq cmd command
TeX-command-sequence-command nil))
((listp command)
(setq cmd (pop command)
TeX-command-sequence-command command))
((functionp command)
(setq cmd (funcall command)
TeX-command-sequence-command command))
(t
;; We first call `TeX-master-file' with the third argument
;; (`ask') set to t, so that the master file is properly set.
;; This is also what `TeX-command-master' does.
(funcall TeX-command-sequence-file-function nil nil t)
(setq cmd (TeX-command-default TeX-command-sequence-file-function)
TeX-command-sequence-command t)))
(TeX-command cmd TeX-command-sequence-file-function 0)
(when reset
(setq TeX-command-sequence-count-same-command 1
TeX-command-sequence-count 1
TeX-command-sequence-last-command nil))
(cond
;; Stop when the same command has been run
;; `TeX-command-sequence-max-runs-same-command' times in a row.
((>= TeX-command-sequence-count-same-command
TeX-command-sequence-max-runs-same-command)
(message "Stopping after running %S %d times in a row."
TeX-command-sequence-last-command
TeX-command-sequence-count-same-command))
;; Stop when there have been `TeX-command-sequence-max-runs' total
;; compilations.
((>= TeX-command-sequence-count TeX-command-sequence-max-runs)
(message "Stopping after %d compilations." TeX-command-sequence-count))
;; The command just run is `TeX-command-Show'.
((equal command TeX-command-Show))
;; In any other case continue: increase counters (when needed), update
;; `TeX-command-sequence-last-command' and run the sentinel.
(t
(if (equal cmd TeX-command-sequence-last-command)
(setq TeX-command-sequence-count-same-command
(1+ TeX-command-sequence-count-same-command))
(setq TeX-command-sequence-count-same-command 1))
(setq TeX-command-sequence-count (1+ TeX-command-sequence-count)
TeX-command-sequence-last-command cmd)
(and (setq process (get-buffer-process (current-buffer)))
(setq TeX-command-sequence-sentinel (process-sentinel process))
(set-process-sentinel process
#'TeX-command-sequence-sentinel)))))))