Function: TeX-command

TeX-command is a byte-compiled function defined in tex.el.

Signature

(TeX-command NAME FILE-FN &optional OVERRIDE-CONFIRM)

Documentation

Run command NAME on the file returned by calling FILE-FN.

FILE-FN is the symbol of a function returning a file name. The function has one optional argument, the extension to use on the file. Valid choices are TeX-master-file and TeX-region-file.

Use the information in TeX-command-list to determine how to run the command.

If OVERRIDE-CONFIRM is a prefix argument, confirmation will be asked if it is positive, and suppressed if it is not.

Run function TeX-check-engine(var)/TeX-check-engine(fun) to check the correct engine has been set.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-command (name file-fn &optional override-confirm)
  "Run command NAME on the file returned by calling FILE-FN.

FILE-FN is the symbol of a function returning a file name.  The
function has one optional argument, the extension to use on the
file.  Valid choices are `TeX-master-file' and `TeX-region-file'.

Use the information in `TeX-command-list' to determine how to run
the command.

If OVERRIDE-CONFIRM is a prefix argument, confirmation will be
asked if it is positive, and suppressed if it is not.

Run function `TeX-check-engine' to check the correct engine has
been set."
  (TeX-check-engine name)

  ;; Make sure that `TeX-command-buffer' is set always.
  ;; It isn't safe to remove similar lines in `TeX-run-command' etc.
  ;; because preview-latex calls `TeX-run-command' directly.
  (setq-default TeX-command-buffer (current-buffer))

  (cond ((eq file-fn #'TeX-region-file)
         (setq TeX-current-process-region-p t))
        ((eq file-fn #'TeX-master-file)
         (setq TeX-current-process-region-p nil)))

  ;; When we're operating on a region, we need to update the position
  ;; of point in the region file so that forward search works.
  (if (string= name "View") (TeX-region-update-point))

  (let ((command (TeX-command-expand (nth 1 (assoc name TeX-command-list))))
        (hook (nth 2 (assoc name TeX-command-list)))
        (confirm (if override-confirm
                     (> (prefix-numeric-value override-confirm) 0)
                   (nth 3 (assoc name TeX-command-list)))))

    ;; Verify the expanded command
    (if confirm
        (setq command
              (read-from-minibuffer (concat name " command: ") command
                                    nil nil)))

    ;; Kill the frame and buffer associated to the error overview before running
    ;; the command, but keep them if the command to be run is View.
    (unless (string= name "View")
      (if (frame-live-p TeX-error-overview-frame)
          (delete-frame TeX-error-overview-frame))
      (if (get-buffer TeX-error-overview-buffer-name)
          (kill-buffer TeX-error-overview-buffer-name)))

    ;; Before running some commands, check that AUCTeX is able to find "tex"
    ;; program.
    (and TeX-check-TeX
         (member name '("TeX" "LaTeX" "AmSTeX" "ConTeXt" "ConTeXt Full"))
         (= TeX-check-TeX-command-not-found
            (call-process TeX-shell nil nil nil
                          TeX-shell-command-option TeX-command))
         (error (format "ERROR: AUCTeX cannot find a working TeX distribution.
Make sure you have one and that TeX binaries are in PATH environment variable%s"
                        (if (eq system-type 'darwin)
                            ".
If you are using macOS 10.14 Mojave or later
remember to add /Library/TeX/texbin/ to your PATH"
                          ""))))

    ;; Now start the process
    (let ((file (funcall file-fn)))
      (TeX-process-set-variable file 'TeX-command-next TeX-command-Show)
      (funcall hook name command file))))