• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/textmodes/

Lines Matching refs:tex

0 ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- coding: utf-8 -*-
7 ;; Keywords: tex
45 (defgroup tex-file nil
47 :prefix "tex-"
48 :group 'tex)
50 (defgroup tex-run nil
52 :prefix "tex-"
53 :group 'tex)
55 (defgroup tex-view nil
57 :prefix "tex-"
58 :group 'tex)
61 (defcustom tex-shell-file-name nil
65 :group 'tex-run)
68 (defcustom tex-directory "."
71 and you don't try to apply \\[tex-region] or \\[tex-buffer] when there are
74 :group 'tex-file)
77 (defcustom tex-first-line-header-regexp nil
78 "Regexp for matching a first line which `tex-region' should include.
81 `tex-region' always includes the first line in the TeX run."
84 :group 'tex-file)
87 (defcustom tex-main-file nil
89 The command `tex-file' runs TeX on the file specified by `tex-main-file'
93 :group 'tex-file)
96 (defcustom tex-offer-save t
97 "*If non-nil, ask about saving modified buffers before \\[tex-file] is run."
99 :group 'tex-file)
102 (defcustom tex-run-command "tex"
104 TeX Mode sets `tex-command' to this string.
107 :group 'tex-run)
112 LaTeX Mode sets `tex-command' to this string.
115 :group 'tex-run)
120 SliTeX Mode sets `tex-command' to this string.
123 :group 'tex-run)
126 (defcustom tex-start-options ""
128 These immediately precede the commands in `tex-start-commands'
130 If nil, TeX runs with no options. See the documentation of `tex-command'."
132 :group 'tex-run
136 (defcustom tex-start-commands "\\nonstopmode\\input"
139 If nil, no commands are used. See the documentation of `tex-command'."
144 :group 'tex-run
164 :group 'tex-run)
167 (defcustom tex-bibtex-command "bibtex"
168 "*Command used by `tex-bibtex-file' to gather bibliographic data.
172 :group 'tex-run)
175 (defcustom tex-dvi-print-command "lpr -d"
176 "*Command used by \\[tex-print] to print a .dvi file.
180 :group 'tex-view)
183 (defcustom tex-alt-dvi-print-command "lpr -d"
184 "*Command used by \\[tex-print] with a prefix arg to print a .dvi file.
189 `tex-alt-dvi-print-command' to an expression that asks what you want;
192 (setq tex-alt-dvi-print-command
195 would tell \\[tex-print] with a prefix argument to ask you which printer to
199 :group 'tex-view)
202 (defcustom tex-dvi-view-command
207 "*Command used by \\[tex-view] to display a `.dvi' file.
214 :group 'tex-view)
217 (defcustom tex-show-queue-command "lpq"
218 "*Command used by \\[tex-show-print-queue] to show the print queue.
219 Should show the queue(s) that \\[tex-print] puts jobs on."
221 :group 'tex-view)
224 (defcustom tex-default-mode 'latex-mode
228 Normally set to either `plain-tex-mode' or `latex-mode'."
230 :group 'tex)
233 (defcustom tex-open-quote "``"
234 "*String inserted by typing \\[tex-insert-quote] to open a quotation."
237 :group 'tex)
240 (defcustom tex-close-quote "''"
241 "*String inserted by typing \\[tex-insert-quote] to close a quotation."
244 :group 'tex)
246 (defvar tex-last-temp-file nil
247 "Latest temporary file generated by \\[tex-region] and \\[tex-buffer].
248 Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the
249 tex shell terminates.")
251 (defvar tex-command "tex"
254 otherwise the value of `tex-start-options', the \(shell-quoted\)
255 value of `tex-start-commands', and the file name are added at the end
262 (defvar tex-trailer nil
263 "String appended after the end of a region sent to TeX by \\[tex-region].")
265 (defvar tex-start-of-header nil
266 "Regular expression used by \\[tex-region] to find start of file's header.")
268 (defvar tex-end-of-header nil
269 "Regular expression used by \\[tex-region] to find end of file's header.")
271 (defvar tex-shell-cd-command "cd"
273 The value of `tex-directory' is appended to this, separated by a space.")
275 (defvar tex-zap-file nil
279 (defvar tex-last-buffer-texed nil
282 (defvar tex-print-file nil
283 "File name that \\[tex-print] prints.
284 Set by \\[tex-region], \\[tex-buffer], and \\[tex-file].")
286 (defvar tex-mode-syntax-table
317 :group 'tex)
384 ".tex"))
416 ;(defvar tex-font-lock-keywords
447 (defconst tex-font-lock-keywords-1
478 ;; highlighted as tex-verbatim face. Let's undo that.
486 (list "\\$\\$\\([^$]+\\)\\$\\$" 1 'tex-math-face)
513 (defun tex-font-lock-append-prop (prop)
515 '(font-lock-comment-face tex-verbatim))
518 (defconst tex-font-lock-keywords-2
519 (append tex-font-lock-keywords-1
572 '(tex-font-lock-append-prop 'bold) 'append)
574 '(tex-font-lock-append-prop 'italic) 'append)
579 2 '(tex-font-lock-append-prop 'italic) 'append)
583 3 '(tex-font-lock-append-prop 'bold) 'append)))))
586 (defun tex-font-lock-suscript (pos)
589 font-lock-comment-face tex-verbatim))
600 (defun tex-font-lock-match-suscript (limit)
614 (defconst tex-font-lock-keywords-3
615 (append tex-font-lock-keywords-2
616 '((tex-font-lock-match-suscript
617 (1 (tex-font-lock-suscript (match-beginning 0)) append))))
620 (defvar tex-font-lock-keywords tex-font-lock-keywords-1
623 (defvar tex-verbatim-environments
626 (defvar tex-font-lock-syntactic-keywords
627 (let ((verbs (regexp-opt tex-verbatim-environments t)))
636 ;; There's a hack in tex-font-lock-keywords-1 to remove the verbatim
644 1 (tex-font-lock-verb (match-end 1))))))
646 (defun tex-font-lock-unfontify-region (beg end)
660 :group 'tex)
664 :group 'tex)
666 (defface tex-math
669 :group 'tex)
671 (put 'tex-math-face 'face-alias 'tex-math)
672 (defvar tex-math-face 'tex-math)
674 (defface tex-verbatim
678 :group 'tex)
680 (put 'tex-verbatim-face 'face-alias 'tex-verbatim)
681 (defvar tex-verbatim-face 'tex-verbatim)
683 (defun tex-font-lock-verb (end)
691 ;; We used to do it inside tex-font-lock-syntactic-face-function, but
709 (defun tex-font-lock-syntactic-face-function (state)
713 ((eq char ?$) tex-math-face)
714 (t tex-verbatim-face))))
718 (defun tex-define-common-keys (keymap)
720 (define-key keymap "\C-c\C-k" 'tex-kill-job)
721 (define-key keymap "\C-c\C-l" 'tex-recenter-output-buffer)
722 (define-key keymap "\C-c\C-q" 'tex-show-print-queue)
723 (define-key keymap "\C-c\C-p" 'tex-print)
724 (define-key keymap "\C-c\C-v" 'tex-view)
726 (define-key keymap [menu-bar tex] (cons "TeX" (make-sparse-keymap "TeX")))
728 (define-key keymap [menu-bar tex tex-kill-job]
729 '(menu-item "Tex Kill" tex-kill-job :enable (tex-shell-running)))
730 (define-key keymap [menu-bar tex tex-recenter-output-buffer]
731 '(menu-item "Tex Recenter" tex-recenter-output-buffer
732 :enable (get-buffer "*tex-shell*")))
733 (define-key keymap [menu-bar tex tex-show-print-queue]
734 '("Show Print Queue" . tex-show-print-queue))
735 (define-key keymap [menu-bar tex tex-alt-print]
736 '(menu-item "Tex Print (alt printer)" tex-alt-print
737 :enable (stringp tex-print-file)))
738 (define-key keymap [menu-bar tex tex-print]
739 '(menu-item "Tex Print" tex-print :enable (stringp tex-print-file)))
740 (define-key keymap [menu-bar tex tex-view]
741 '(menu-item "Tex View" tex-view :enable (stringp tex-print-file))))
743 (defvar tex-mode-map
746 (tex-define-common-keys map)
747 (define-key map "\"" 'tex-insert-quote)
752 (define-key map "\n" 'tex-terminate-paragraph)
755 (define-key map "\C-c{" 'tex-insert-braces)
756 (define-key map "\C-c\C-r" 'tex-region)
757 (define-key map "\C-c\C-b" 'tex-buffer)
758 (define-key map "\C-c\C-f" 'tex-file)
759 (define-key map "\C-c\C-c" 'tex-compile)
760 (define-key map "\C-c\C-i" 'tex-bibtex-file)
763 (define-key map "\C-c\C-u" 'tex-goto-last-unclosed-latex-block)
764 (define-key map "\C-c\C-m" 'tex-feed-input)
765 (define-key map [(control return)] 'tex-feed-input)
766 (define-key map [menu-bar tex tex-bibtex-file]
767 '("BibTeX File" . tex-bibtex-file))
768 (define-key map [menu-bar tex tex-validate-region]
769 '(menu-item "Validate Region" tex-validate-region :enable mark-active))
770 (define-key map [menu-bar tex tex-validate-buffer]
771 '("Validate Buffer" . tex-validate-buffer))
772 (define-key map [menu-bar tex tex-region]
773 '(menu-item "TeX Region" tex-region :enable mark-active))
774 (define-key map [menu-bar tex tex-buffer]
775 '("TeX Buffer" . tex-buffer))
776 (define-key map [menu-bar tex tex-file] '("TeX File" . tex-file))
782 (set-keymap-parent map tex-mode-map)
785 "Keymap for `latex-mode'. See also `tex-mode-map'.")
787 (defvar plain-tex-mode-map
789 (set-keymap-parent map tex-mode-map)
791 "Keymap for `plain-tex-mode'. See also `tex-mode-map'.")
793 (defvar tex-shell-map
796 (tex-define-common-keys m)
801 (defvar tex-face-alist
809 (defvar tex-latex-face-alist
811 ,@tex-face-alist)
816 (defun tex-guess-mode ()
817 (let ((mode tex-default-mode) slash comment)
838 (tex-executable-exists-p slitex-run-command))
841 'plain-tex-mode))))
844 ;; `tex-mode' plays two roles: it's the parent of several sub-modes
848 (define-derived-mode tex-mode text-mode "generic-TeX"
849 (tex-common-initialization))
855 (defalias 'tex-mode-internal (symbol-function 'tex-mode))
857 (defun tex-mode ()
860 this file is for plain TeX, LaTeX, or SliTeX and calls `plain-tex-mode',
862 such as if there are no commands in the file, the value of `tex-default-mode'
867 (tex-mode-internal)
868 (tex-guess-mode)))
879 (defalias 'TeX-mode 'tex-mode)
881 (defalias 'plain-TeX-mode 'plain-tex-mode)
886 (define-derived-mode plain-tex-mode tex-mode "TeX"
892 Use \\[tex-region] to run TeX on the current region, plus a \"header\"
894 running TeX under a special subshell. \\[tex-buffer] does the whole buffer.
895 \\[tex-file] saves the buffer and then processes the file.
896 \\[tex-print] prints the .dvi file made by any of these.
897 \\[tex-view] previews the .dvi file made by any of these.
898 \\[tex-bibtex-file] runs bibtex on the file of the current buffer.
900 Use \\[tex-validate-buffer] to check buffer for paragraphs containing
904 \\{plain-tex-mode-map}
907 tex-run-command
908 Command string used by \\[tex-region] or \\[tex-buffer].
909 tex-directory
911 run by \\[tex-region] or \\[tex-buffer].
912 tex-dvi-print-command
913 Command string used by \\[tex-print] to print a .dvi file.
914 tex-alt-dvi-print-command
915 Alternative command string used by \\[tex-print] (when given a prefix
917 tex-dvi-view-command
918 Command string used by \\[tex-view] to preview a .dvi file.
919 tex-show-queue-command
920 Command string used by \\[tex-show-print-queue] to show the print
921 queue that \\[tex-print] put your job on.
923 Entering Plain-tex mode runs the hook `text-mode-hook', then the hook
924 `tex-mode-hook', and finally the hook `plain-tex-mode-hook'. When the
925 special subshell is initiated, the hook `tex-shell-hook' is run."
926 (set (make-local-variable 'tex-command) tex-run-command)
927 (set (make-local-variable 'tex-start-of-header) "%\\*\\*start of header")
928 (set (make-local-variable 'tex-end-of-header) "%\\*\\*end of header")
929 (set (make-local-variable 'tex-trailer) "\\bye\n"))
932 (define-derived-mode latex-mode tex-mode "LaTeX"
938 Use \\[tex-region] to run LaTeX on the current region, plus the preamble
940 running LaTeX under a special subshell. \\[tex-buffer] does the whole buffer.
941 \\[tex-file] saves the buffer and then processes the file.
942 \\[tex-print] prints the .dvi file made by any of these.
943 \\[tex-view] previews the .dvi file made by any of these.
944 \\[tex-bibtex-file] runs bibtex on the file of the current buffer.
946 Use \\[tex-validate-buffer] to check buffer for paragraphs containing
954 Command string used by \\[tex-region] or \\[tex-buffer].
955 tex-directory
957 run by \\[tex-region] or \\[tex-buffer].
958 tex-dvi-print-command
959 Command string used by \\[tex-print] to print a .dvi file.
960 tex-alt-dvi-print-command
961 Alternative command string used by \\[tex-print] (when given a prefix
963 tex-dvi-view-command
964 Command string used by \\[tex-view] to preview a .dvi file.
965 tex-show-queue-command
966 Command string used by \\[tex-show-print-queue] to show the print
967 queue that \\[tex-print] put your job on.
970 `tex-mode-hook', and finally `latex-mode-hook'. When the special
971 subshell is initiated, `tex-shell-hook' is run."
972 (set (make-local-variable 'tex-command) latex-run-command)
973 (set (make-local-variable 'tex-start-of-header)
975 (set (make-local-variable 'tex-end-of-header) "\\\\begin\\s-*{document}")
976 (set (make-local-variable 'tex-trailer) "\\end{document}\n")
1004 (set (make-local-variable 'tex-face-alist) tex-latex-face-alist)
1020 Use \\[tex-region] to run SliTeX on the current region, plus the preamble
1022 running SliTeX under a special subshell. \\[tex-buffer] does the whole buffer.
1023 \\[tex-file] saves the buffer and then processes the file.
1024 \\[tex-print] prints the .dvi file made by any of these.
1025 \\[tex-view] previews the .dvi file made by any of these.
1026 \\[tex-bibtex-file] runs bibtex on the file of the current buffer.
1028 Use \\[tex-validate-buffer] to check buffer for paragraphs containing
1036 Command string used by \\[tex-region] or \\[tex-buffer].
1037 tex-directory
1039 run by \\[tex-region] or \\[tex-buffer].
1040 tex-dvi-print-command
1041 Command string used by \\[tex-print] to print a .dvi file.
1042 tex-alt-dvi-print-command
1043 Alternative command string used by \\[tex-print] (when given a prefix
1045 tex-dvi-view-command
1046 Command string used by \\[tex-view] to preview a .dvi file.
1047 tex-show-queue-command
1048 Command string used by \\[tex-show-print-queue] to show the print
1049 queue that \\[tex-print] put your job on.
1052 `tex-mode-hook', then the hook `latex-mode-hook', and finally the hook
1054 `tex-shell-hook' is run."
1055 (setq tex-command slitex-run-command)
1056 (setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}"))
1058 (defun tex-common-initialization ()
1074 'tex-categorize-whitespace)
1077 (or (cdr (assq face tex-face-alist))
1082 '((tex-font-lock-keywords tex-font-lock-keywords-1
1083 tex-font-lock-keywords-2 tex-font-lock-keywords-3)
1088 . tex-font-lock-syntactic-face-function)
1090 . tex-font-lock-unfontify-region)
1092 . tex-font-lock-syntactic-keywords)
1097 (make-local-variable 'tex-command)
1098 (make-local-variable 'tex-start-of-header)
1099 (make-local-variable 'tex-end-of-header)
1100 (make-local-variable 'tex-trailer))
1102 (defun tex-categorize-whitespace (backward-limit)
1132 (defun tex-insert-quote (arg)
1134 Inserts the value of `tex-open-quote' (normally ``) or `tex-close-quote'
1139 (eq (get-text-property (point) 'face) 'tex-verbatim)
1141 (backward-char (length tex-open-quote))
1142 (when (or (looking-at (regexp-quote tex-open-quote))
1143 (looking-at (regexp-quote tex-close-quote)))
1144 (delete-char (length tex-open-quote))
1148 tex-open-quote tex-close-quote))))
1150 (defun tex-validate-buffer ()
1179 (or (tex-validate-region (point) end)
1222 (defun tex-validate-region (start end)
1252 (defun tex-terminate-paragraph (inhibit-validation)
1259 (tex-validate-region
1267 (define-skeleton tex-insert-braces
1316 ;; Like tex-insert-braces, but for LaTeX.
1317 (defalias 'tex-latex-block 'latex-insert-block)
1349 (defmacro tex-search-noncomment (&rest body)
1360 (defun tex-last-unended-begin ()
1363 (while (and (tex-search-noncomment
1366 (tex-last-unended-begin))
1369 (defun tex-next-unmatched-end ()
1371 (while (and (tex-search-noncomment
1375 (tex-next-unmatched-end)))
1377 (defun tex-goto-last-unclosed-latex-block ()
1383 (tex-last-unended-begin)
1403 (tex-last-unended-begin)
1423 (tex-next-unmatched-end))
1461 (with-syntax-table tex-mode-syntax-table
1464 (defalias 'tex-close-latex-block 'latex-close-block)
1468 (tex-last-unended-begin)
1476 (tex-last-unended-begin)
1487 (defconst tex-discount-args-cmds
1492 (defun tex-count-words (begin end)
1513 (when (member cmd tex-discount-args-cmds)
1534 (define-derived-mode tex-shell shell-mode "TeX-Shell"
1536 'tex-compilation-parse-errors)
1540 (defun tex-start-shell ()
1543 "tex-shell"
1544 (or tex-shell-file-name (getenv "ESHELL") shell-file-name)
1548 (let ((proc (get-process "tex-shell")))
1549 (set-process-sentinel proc 'tex-shell-sentinel)
1551 (tex-shell)
1555 (defun tex-feed-input ()
1556 "Send input to the tex shell process.
1557 In the tex buffer this can be used to continue an interactive tex run.
1558 In the tex shell buffer this command behaves like `comint-send-input'."
1560 (set-buffer (tex-shell-buf))
1562 (tex-recenter-output-buffer nil))
1564 (defun tex-display-shell ()
1566 (display-buffer (tex-shell-buf))
1567 (tex-recenter-output-buffer nil))
1569 (defun tex-shell-sentinel (proc msg)
1573 (tex-delete-last-temp-files))
1575 (tex-delete-last-temp-files))))
1577 (defun tex-set-buffer-directory (buffer directory)
1586 (defvar tex-send-command-modified-tick 0)
1587 (make-variable-buffer-local 'tex-send-command-modified-tick)
1589 (defun tex-shell-proc ()
1590 (or (tex-shell-running) (error "No TeX subprocess")))
1591 (defun tex-shell-buf ()
1592 (process-buffer (tex-shell-proc)))
1593 (defun tex-shell-buf-no-error ()
1594 (let ((proc (tex-shell-running)))
1597 (defun tex-send-command (command &optional file background)
1607 (proc (tex-shell-proc))
1623 ;; If text is unchanged since previous tex-send-command,
1625 (if (= (buffer-modified-tick buf) tex-send-command-modified-tick)
1630 (setq tex-send-command-modified-tick (buffer-modified-tick buf))
1633 (defun tex-delete-last-temp-files (&optional not-all)
1636 (if tex-last-temp-file
1637 (let* ((dir (file-name-directory tex-last-temp-file))
1641 (file-name-nondirectory tex-last-temp-file))
1652 (add-hook 'kill-emacs-hook 'tex-delete-last-temp-files)
1658 (defvar tex-compile-history nil)
1660 (defvar tex-input-files-re
1662 (concat "\\." (regexp-opt '("tex" "texi" "texinfo"
1667 (defcustom tex-use-reftex t
1670 :group 'tex)
1672 (defvar tex-compile-commands
1673 '(((concat "pdf" tex-command
1674 " " (if (< 0 (length tex-start-commands))
1675 (shell-quote-argument tex-start-commands)) " %f")
1677 ((concat tex-command
1678 " " (if (< 0 (length tex-start-commands))
1679 (shell-quote-argument tex-start-commands)) " %f")
1695 "List of commands for `tex-compile'.
1707 (defsubst* tex-string-prefix-p (str1 str2)
1711 (defun tex-guess-main-file (&optional all)
1712 "Find a likely `tex-main-file'.
1717 (header-re tex-start-of-header))
1719 ;; Look for a buffer with `tex-main-file' set.
1724 ((eq all 'sub) (tex-string-prefix-p default-directory dir))
1726 (stringp tex-main-file))
1727 (throw 'found (expand-file-name tex-main-file)))))
1728 ;; Look for a buffer containing the magic `tex-start-of-header'.
1733 ((eq all 'sub) (tex-string-prefix-p default-directory dir))
1737 ;; (easy-mmode-derived-mode-p 'plain-tex-mode))
1746 (defun tex-main-file ()
1748 (let* ((file (or tex-main-file
1753 (make-local-variable 'tex-main-file)
1754 (setq tex-main-file TeX-master))
1763 (re-search-forward tex-start-of-header
1768 (or (tex-guess-main-file)
1769 (tex-guess-main-file 'sub)
1770 ;; (tex-guess-main-file t)
1772 (if (or (file-exists-p file) (string-match "\\.tex\\'" file))
1773 file (concat file ".tex"))))
1775 (defun tex-summarize-command (cmd)
1782 (defun tex-uptodate-p (file)
1791 (let ((buf (condition-case nil (tex-shell-buf) (error nil))))
1809 (let ((files (if (and tex-use-reftex
1829 (directory-files f t tex-input-files-re)
1838 (defvar tex-executable-cache nil)
1839 (defun tex-executable-exists-p (name)
1841 (let ((cache (assoc name tex-executable-cache)))
1844 (push (cons name executable) tex-executable-cache)
1847 (defun tex-command-executable (cmd)
1851 (defun tex-command-active-p (cmd fspec)
1862 (not (tex-uptodate-p (format-spec out fspec)))))))
1864 (defun tex-compile-default (fspec)
1870 (dolist (cmd tex-compile-commands)
1871 (when (tex-executable-exists-p (tex-command-executable cmd))
1872 (if (tex-command-active-p cmd fspec)
1876 (setq cmds (if cmds (nreverse cmds) (list (car tex-compile-commands))))
1912 (let ((hist tex-compile-history)
1917 (regexp-quote (tex-command-executable hist-cmd))
1936 (defun tex-compile (dir cmd)
1940 (let* ((file (tex-main-file))
1947 (default (tex-compile-default fspec)))
1950 (format "Command [%s]: " (tex-summarize-command default))
1953 tex-compile-commands)
1954 nil nil nil 'tex-compile-history default))))
1956 (if (tex-shell-running)
1957 (tex-kill-job)
1958 (tex-start-shell))
1959 (tex-send-tex-command cmd dir))
1961 (defun tex-start-tex (command file &optional dir)
1970 tex-start-options
1971 (if (< 0 (length tex-start-commands))
1973 (shell-quote-argument tex-start-commands) " "))
1975 (tex-send-tex-command compile-command dir)))
1977 (defun tex-send-tex-command (cmd &optional dir)
1978 (unless (or (equal dir (let ((buf (tex-shell-buf-no-error)))
1983 (tex-send-command tex-shell-cd-command dir)))
1984 (with-current-buffer (process-buffer (tex-send-command cmd))
1989 (tex-display-shell)
1990 (setq tex-last-buffer-texed (current-buffer)))
1993 (defvar tex-error-parse-syntax-table
2007 (defun tex-compilation-parse-errors (limit-search find-at-least)
2018 (file-name-directory (buffer-file-name tex-last-buffer-texed)))
2036 (with-syntax-table tex-error-parse-syntax-table
2049 (if (equal filename (concat tex-zap-file ".tex"))
2050 tex-last-buffer-texed
2087 (defun tex-region (beg end)
2089 The file's name comes from the variable `tex-zap-file' and the
2090 variable `tex-directory' says where to put it.
2094 defined by `tex-start-of-header' and `tex-end-of-header' inclusive.
2097 The value of `tex-trailer' is given to TeX as input after the region.
2099 The value of `tex-command' specifies the command to use to run TeX."
2101 (if (tex-shell-running)
2102 (tex-kill-job)
2103 (tex-start-shell))
2104 (or tex-zap-file
2105 (setq tex-zap-file (tex-generate-zap-file-name)))
2110 ;; tex-directory is ".".
2112 (file-name-as-directory (expand-file-name tex-directory)))
2113 (tex-out-file (expand-file-name (concat tex-zap-file ".tex")
2116 (or (eq (current-buffer) tex-last-buffer-texed)
2117 (tex-delete-last-temp-files t))
2130 (and tex-first-line-header-regexp
2131 (looking-at tex-first-line-header-regexp)
2135 tex-out-file nil nil))
2140 (if (re-search-forward tex-start-of-header search-end t)
2144 (if (re-search-forward tex-end-of-header nil t)
2150 tex-out-file
2157 tex-out-file
2162 (if tex-trailer
2163 (write-region (concat "\n" tex-trailer) nil
2164 tex-out-file t nil))))
2166 (setq tex-last-temp-file tex-out-file)
2169 ;; too long and can make tex crash.
2170 (tex-start-tex tex-command (concat tex-zap-file ".tex") zap-directory)
2171 (setq tex-print-file tex-out-file)))
2173 (defun tex-buffer ()
2174 "Run TeX on current buffer. See \\[tex-region] for more information.
2176 See \\[tex-file] for an alternative."
2178 (tex-region (point-min) (point-max)))
2180 (defun tex-file ()
2182 This function is more useful than \\[tex-buffer] when you need the
2185 (when tex-offer-save
2187 (let* ((source-file (tex-main-file))
2189 (if (tex-shell-running)
2190 (tex-kill-job)
2191 (tex-start-shell))
2192 (tex-start-tex tex-command source-file file-dir)
2193 (setq tex-print-file (expand-file-name source-file))))
2195 (defun tex-generate-zap-file-name ()
2202 (process-id (get-buffer-process "*tex-shell*"))
2207 (defun tex-expand-files (s)
2218 (defun tex-shell-running ()
2219 (let ((proc (get-process "tex-shell")))
2227 ;; dead tex-shell buffer and live process
2230 (defun tex-kill-job ()
2233 ;; `quit-process' leads to core dumps of the tex process (except if
2237 (let ((proc (get-process "tex-shell")))
2240 (defun tex-recenter-output-buffer (linenum)
2245 (let ((tex-shell (get-buffer "*tex-shell*"))
2247 (if (null tex-shell)
2249 (setq window (display-buffer tex-shell))
2252 (bury-buffer tex-shell)
2258 (defun tex-print (&optional alt)
2259 "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file].
2260 Runs the shell command defined by `tex-dvi-print-command'. If prefix argument
2261 is provided, use the alternative command, `tex-alt-dvi-print-command'."
2263 (let ((print-file-name-dvi (tex-append tex-print-file ".dvi"))
2265 (if (and (not (equal (current-buffer) tex-last-buffer-texed))
2269 (setq test-name (tex-append (buffer-file-name) ".dvi"))
2274 (if (tex-shell-running)
2275 (tex-kill-job)
2276 (tex-start-shell))
2277 (tex-send-command
2278 (if alt tex-alt-dvi-print-command tex-dvi-print-command)
2282 (defun tex-alt-print ()
2283 "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file].
2284 Runs the shell command defined by `tex-alt-dvi-print-command'."
2286 (tex-print t))
2288 (defun tex-view ()
2290 This means, made using \\[tex-region], \\[tex-buffer] or \\[tex-file].
2291 The variable `tex-dvi-view-command' specifies the shell command for preview.
2295 (or tex-dvi-view-command
2296 (error "You must set `tex-dvi-view-command'"))
2298 (or (tex-shell-running)
2299 (tex-start-shell))
2300 (let ((tex-dvi-print-command (eval tex-dvi-view-command)))
2301 (tex-print)))
2303 (defun tex-append (file-name suffix)
2313 ;; named a.tex and a.b.tex are both tex'd;
2330 (defun tex-show-print-queue ()
2331 "Show the print queue that \\[tex-print] put your job on.
2332 Runs the shell command defined by `tex-show-queue-command'."
2334 (if (tex-shell-running)
2335 (tex-kill-job)
2336 (tex-start-shell))
2337 (tex-send-command tex-show-queue-command)
2338 (tex-display-shell))
2340 (defun tex-bibtex-file ()
2343 (if (tex-shell-running)
2344 (tex-kill-job)
2345 (tex-start-shell))
2347 (tex-out-file
2348 (tex-append (file-name-nondirectory (buffer-file-name)) ""))
2350 (tex-send-command tex-shell-cd-command file-dir)
2351 (tex-send-command tex-bibtex-command tex-out-file))
2352 (tex-display-shell))
2359 (defvar tex-indent-allhanging t)
2360 (defvar tex-indent-arg 4)
2361 (defvar tex-indent-basic 2)
2362 (defvar tex-indent-item tex-indent-basic)
2363 (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
2366 (defvar tex-latex-indent-syntax-table
2367 (let ((st (make-syntax-table tex-mode-syntax-table)))
2376 'tex-verbatim))
2378 (with-syntax-table tex-latex-indent-syntax-table
2404 (member (match-string 2) tex-verbatim-environments)
2416 (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0))
2431 (if (and (not tex-indent-allhanging)
2453 0 tex-indent-basic)
2460 ((looking-at tex-indent-item-re)
2462 (+ indent (current-column) tex-indent-item))
2477 (min (current-column) (+ tex-indent-arg col))
2510 (tex-font-lock-syntactic-face-function state)
2515 tex-font-lock-syntactic-keywords
2520 (append tex-font-lock-keywords
2538 (run-hooks 'tex-mode-load-hook)
2540 (provide 'tex-mode)
2543 ;;; tex-mode.el ends here