tex-mode.el 38.7 KB
 Eric S. Raymond committed May 30, 1992 1 2 ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands.  Eric S. Raymond committed Jul 22, 1992 3 4 ;; Copyright (C) 1985, 1986, 1989, 1992 Free Software Foundation, Inc.  Eric S. Raymond committed Jul 16, 1992 5 ;; Maintainer: Edward M. Reingold  Eric S. Raymond committed Jul 17, 1992 6 ;; Keywords: tex  Eric S. Raymond committed Jul 16, 1992 7   Richard M. Stallman committed Jul 04, 1992 8 ;; Contributions over the years by William F. Schelter, Dick King,  Eric S. Raymond committed Apr 25, 1993 9 ;; Stephen Gildea, Michael Prange, and Jacob Gore.  Richard M. Stallman committed Jul 04, 1992 10   root committed Aug 28, 1990 11 12 13 14 ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by  Eric S. Raymond committed Jul 16, 1992 15 ;; the Free Software Foundation; either version 2, or (at your option)  root committed Aug 28, 1990 16 17 18 19 20 21 22 23 24 25 26 ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  Eric S. Raymond committed Jul 16, 1992 27 28 ;;; Code:  Eric S. Raymond committed Apr 26, 1993 29 (require 'comint)  Eric S. Raymond committed Apr 25, 1993 30 (require 'compile)  Richard M. Stallman committed Jul 04, 1992 31   Jim Blandy committed Aug 12, 1992 32 ;;;###autoload  Richard M. Stallman committed Jul 04, 1992 33 34 35 (defvar tex-shell-file-name nil "*If non-nil, is file name to use for the subshell in which TeX is run.")  Jim Blandy committed Aug 12, 1992 36 ;;;###autoload  Richard M. Stallman committed Jul 04, 1992 37 38 39 40 41 (defvar tex-directory "." "*Directory in which temporary files are left. You can make this /tmp if your TEXINPUTS has no relative directories in it and you don't try to apply \$tex-region] or \\[tex-buffer] when there are \\input commands with relative directories.")  root committed Aug 28, 1990 42   Jim Blandy committed Aug 12, 1992 43 ;;;###autoload  Richard M. Stallman committed Jul 04, 1992 44 45 (defvar tex-offer-save t "*If non-nil, ask about saving modified buffers before \\[tex-file] is run.")  root committed Aug 28, 1990 46   Jim Blandy committed Aug 12, 1992 47 ;;;###autoload  root committed Aug 28, 1990 48 49 (defvar tex-run-command "tex" "*Command used to run TeX subjob.  Richard M. Stallman committed Jul 04, 1992 50 51 52 If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string.")  root committed Aug 28, 1990 53   Jim Blandy committed Aug 12, 1992 54 ;;;###autoload  root committed Aug 28, 1990 55 56 (defvar latex-run-command "latex" "*Command used to run LaTeX subjob.  Richard M. Stallman committed Jul 04, 1992 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string.") (defvar standard-latex-block-names '("abstract" "array" "center" "description" "displaymath" "document" "enumerate" "eqnarray" "eqnarray*" "equation" "figure" "figure*" "flushleft" "flushright" "itemize" "letter" "list" "minipage" "picture" "quotation" "quote" "slide" "sloppypar" "tabbing" "table" "table*" "tabular" "tabular*" "thebibliography" "theindex*" "titlepage" "trivlist" "verbatim" "verbatim*" "verse") "Standard LaTeX block names.")  Jim Blandy committed Aug 12, 1992 73 ;;;###autoload  Richard M. Stallman committed Jul 04, 1992 74 75 76 (defvar latex-block-names nil "*User defined LaTeX block names. Combined with standard-latex-block-names' for minibuffer completion.")  root committed Aug 28, 1990 77   Jim Blandy committed Aug 12, 1992 78 ;;;###autoload  root committed Aug 28, 1990 79 80 (defvar slitex-run-command "slitex" "*Command used to run SliTeX subjob.  Richard M. Stallman committed Jul 04, 1992 81 82 83 If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string.")  root committed Aug 28, 1990 84   Jim Blandy committed Aug 12, 1992 85 ;;;###autoload  root committed Aug 28, 1990 86 (defvar tex-bibtex-command "bibtex"  Richard M. Stallman committed Jul 04, 1992 87 88 89 90  "*Command used by tex-bibtex-file' to gather bibliographic data. If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string.")  root committed Aug 28, 1990 91   Jim Blandy committed Aug 12, 1992 92 ;;;###autoload  root committed Aug 28, 1990 93 (defvar tex-dvi-print-command "lpr -d"  Richard M. Stallman committed Jul 04, 1992 94 95 96 97 98  "*Command used by \\[tex-print] to print a .dvi file. If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string.")  Jim Blandy committed Aug 12, 1992 99 ;;;###autoload  Richard M. Stallman committed Jul 04, 1992 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 (defvar tex-alt-dvi-print-command "lpr -d" "*Command used by \\[tex-print] with a prefix arg to print a .dvi file. If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string. If two printers are not enough of a choice, you can define the value of tex-alt-dvi-print-command to be an expression that asks what you want; for example, (setq tex-alt-dvi-print-command '(format \"lpr -P%s\" (read-string \"Use printer: \"))) would tell \\[tex-print] with a prefix argument to ask you which printer to use.")  root committed Aug 28, 1990 115   Jim Blandy committed Aug 12, 1992 116 ;;;###autoload  root committed Aug 28, 1990 117 (defvar tex-dvi-view-command nil  Richard M. Stallman committed Jul 04, 1992 118 119 120 121 122 123 124 125 126 127 128 129 130  "*Command used by \\[tex-view] to display a .dvi file. If this string contains an asterisk (*), it will be replaced by the filename; if not, the name of the file, preceded by blank, will be added to this string. This can be set conditionally so that the previewer used is suitable for the window system being used. For example, (setq tex-dvi-view-command (if (eq window-system 'x) \"xdvi\" \"dvi2tty * | cat -s\")) would tell \\[tex-view] use xdvi under X windows and to use dvi2tty otherwise.")  root committed Aug 28, 1990 131   Jim Blandy committed Aug 12, 1992 132 ;;;###autoload  root committed Aug 28, 1990 133 (defvar tex-show-queue-command "lpq"  Richard M. Stallman committed Jul 04, 1992 134 135  "*Command used by \\[tex-show-print-queue] to show the print queue. Should show the queue(s) that \\[tex-print] puts jobs on.")  root committed Aug 28, 1990 136   Jim Blandy committed Aug 12, 1992 137 ;;;###autoload  root committed Aug 28, 1990 138 139 140 141 142 143 (defvar tex-default-mode 'plain-tex-mode "*Mode to enter for a new file that might be either TeX or LaTeX. This variable is used when it can't be determined whether the file is plain TeX or LaTeX or what because the file contains no commands. Normally set to either 'plain-tex-mode or 'latex-mode.")  Jim Blandy committed Aug 12, 1992 144 ;;;###autoload  root committed Aug 28, 1990 145 146 147 (defvar tex-open-quote "" "*String inserted by typing \\[tex-insert-quote] to open a quotation.")  Jim Blandy committed Aug 12, 1992 148 ;;;###autoload  root committed Aug 28, 1990 149 150 151 (defvar tex-close-quote "''" "*String inserted by typing \\[tex-insert-quote] to close a quotation.")  Richard M. Stallman committed Jul 04, 1992 152 153 154 155 156 (defvar tex-last-temp-file nil "Latest temporary file generated by \\[tex-region] and \\[tex-buffer]. Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the tex-shell goes away.")  root committed Aug 28, 1990 157 158 (defvar tex-command nil "Command to run TeX.  Richard M. Stallman committed Jul 04, 1992 159 The name of the file, preceded by a blank, will be added to this string.")  root committed Aug 28, 1990 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194  (defvar tex-trailer nil "String appended after the end of a region sent to TeX by \\[tex-region].") (defvar tex-start-of-header nil "String used by \\[tex-region] to delimit the start of the file's header.") (defvar tex-end-of-header nil "String used by \\[tex-region] to delimit the end of the file's header.") (defvar tex-shell-cd-command "cd" "Command to give to shell running TeX to change directory. The value of tex-directory will be appended to this, separated by a space.") (defvar tex-zap-file nil "Temporary file name used for text being sent as input to TeX. Should be a simple file name with no extension or directory specification.") (defvar tex-last-buffer-texed nil "Buffer which was last TeXed.") (defvar tex-print-file nil "File name that \\[tex-print] prints. Set by \\[tex-region], \\[tex-buffer], and \\[tex-file].") (defvar tex-mode-syntax-table nil "Syntax table used while in TeX mode.") (defun tex-define-common-keys (keymap) "Define the keys that we want defined both in TeX mode and in the tex-shell." (define-key keymap "\C-c\C-k" 'tex-kill-job) (define-key keymap "\C-c\C-l" 'tex-recenter-output-buffer) (define-key keymap "\C-c\C-q" 'tex-show-print-queue) (define-key keymap "\C-c\C-p" 'tex-print) (define-key keymap "\C-c\C-v" 'tex-view)  Richard M. Stallman committed Oct 27, 1993 195 196 197 198  (define-key keymap [menu-bar tex] (cons "TeX" (make-sparse-keymap "TeX"))) (define-key keymap [menu-bar tex tex-kill-job] '("Tex Kill" . tex-kill-job))  Richard M. Stallman committed Nov 06, 1993 199 200  (define-key keymap [menu-bar tex tex-recenter-output-buffer] '("Tex Recenter" . tex-recenter-output-buffer))  Richard M. Stallman committed Oct 27, 1993 201 202  (define-key keymap [menu-bar tex tex-show-print-queue] '("Show Print Queue" . tex-show-print-queue))  Richard M. Stallman committed Nov 06, 1993 203 204  (define-key keymap [menu-bar tex tex-alt-print] '("Tex Print (alt printer)" . tex-alt-print))  Richard M. Stallman committed Oct 27, 1993 205  (define-key keymap [menu-bar tex tex-print] '("Tex Print" . tex-print))  Richard M. Stallman committed Nov 06, 1993 206  (define-key keymap [menu-bar tex tex-view] '("Tex View" . tex-view))  root committed Aug 28, 1990 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223  ) (defvar tex-mode-map nil "Keymap for TeX mode.") (if tex-mode-map nil (setq tex-mode-map (make-sparse-keymap)) (tex-define-common-keys tex-mode-map) (define-key tex-mode-map "\"" 'tex-insert-quote) (define-key tex-mode-map "\n" 'tex-terminate-paragraph) (define-key tex-mode-map "\C-c}" 'up-list) (define-key tex-mode-map "\C-c{" 'tex-insert-braces) (define-key tex-mode-map "\C-c\C-r" 'tex-region) (define-key tex-mode-map "\C-c\C-b" 'tex-buffer) (define-key tex-mode-map "\C-c\C-f" 'tex-file) (define-key tex-mode-map "\C-c\C-i" 'tex-bibtex-file) (define-key tex-mode-map "\C-c\C-o" 'tex-latex-block)  Richard M. Stallman committed Nov 06, 1993 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242  (define-key tex-mode-map "\C-c\C-e" 'tex-close-latex-block) (define-key tex-mode-map [menu-bar tex tex-validate-region] '("Validate Region" . tex-validate-region)) (define-key tex-mode-map [menu-bar tex validate-tex-buffer] '("Validate Buffer" . validate-tex-buffer)) (define-key tex-mode-map [menu-bar tex tex-region] '("Tex Region" . tex-region)) (define-key tex-mode-map [menu-bar tex tex-buffer] '("Tex Buffer" . tex-buffer)) (define-key tex-mode-map [menu-bar tex tex-file] '("Tex File" . tex-file))) (put 'tex-region 'menu-enable 'mark-active) (put 'tex-validate-region 'menu-enable 'mark-active) (put 'tex-print 'menu-enable '(stringp tex-print-file)) (put 'tex-alt-print 'menu-enable '(stringp tex-print-file)) (put 'tex-view 'menu-enable '(stringp tex-print-file)) (put 'tex-recenter-output-buffer 'menu-enable '(get-buffer "*tex-shell*")) (put 'tex-kill-job 'menu-enable '(tex-shell-running))  root committed Aug 28, 1990 243 244  (defvar tex-shell-map nil  Richard M. Stallman committed Jul 04, 1992 245  "Keymap for the tex-shell. A comint-mode-map with a few additions.")  root committed Aug 28, 1990 246   Eric S. Raymond committed Apr 26, 1993 247 248 (defvar compare-windows-whitespace nil) ; Pacify the byte-compiler  root committed Aug 28, 1990 249 250 ;;; This would be a lot simpler if we just used a regexp search, ;;; but then it would be too slow.  Roland McGrath committed May 09, 1991 251 ;;;###autoload  root committed Aug 28, 1990 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 (defun tex-mode () "Major mode for editing files of input for TeX, LaTeX, or SliTeX. Tries to determine (by looking at the beginning of the file) whether this file is for plain TeX, LaTeX, or SliTeX and calls plain-tex-mode, latex-mode, or slitex-mode, respectively. If it cannot be determined, such as if there are no commands in the file, the value of tex-default-mode is used." (interactive) (let (mode slash comment) (save-excursion (goto-char (point-min)) (while (and (setq slash (search-forward "\\" nil t)) (setq comment (let ((search-end (point))) (save-excursion (beginning-of-line) (search-forward "%" search-end t)))))) (if (and slash (not comment)) (setq mode (if (looking-at "documentstyle") (if (looking-at "documentstyle{slides}") 'slitex-mode 'latex-mode) 'plain-tex-mode)))) (if mode (funcall mode) (funcall tex-default-mode))))  Eric S. Raymond committed Apr 28, 1993 276   Jim Blandy committed May 13, 1991 277 ;;;###autoload  Eric S. Raymond committed Apr 23, 1993 278 (defalias 'TeX-mode 'tex-mode)  Jim Blandy committed May 13, 1991 279 ;;;###autoload  Eric S. Raymond committed Apr 23, 1993 280 (defalias 'LaTeX-mode 'latex-mode)  root committed Aug 28, 1990 281   Roland McGrath committed May 09, 1991 282 ;;;###autoload  root committed Aug 28, 1990 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 (defun plain-tex-mode () "Major mode for editing files of input for plain TeX. Makes  and } display the characters they match. Makes \" insert  when it seems to be the beginning of a quotation, and '' when it appears to be the end; it inserts \" only after a \\. Use \\[tex-region] to run TeX on the current region, plus a \"header\" copied from the top of the file (containing macro definitions, etc.), running TeX under a special subshell. \\[tex-buffer] does the whole buffer. \\[tex-file] saves the buffer and then processes the file. \\[tex-print] prints the .dvi file made by any of these. \\[tex-view] previews the .dvi file made by any of these. \\[tex-bibtex-file] runs bibtex on the file of the current buffer. Use \\[validate-tex-buffer] to check buffer for paragraphs containing mismatched 's or braces. Special commands: \\{tex-mode-map} Mode variables: tex-run-command Command string used by \\[tex-region] or \\[tex-buffer]. tex-directory Directory in which to create temporary files for TeX jobs run by \\[tex-region] or \\[tex-buffer]. tex-dvi-print-command Command string used by \\[tex-print] to print a .dvi file.  Richard M. Stallman committed Jul 04, 1992 311 312 313 tex-alt-dvi-print-command Alternative command string used by \\[tex-print] (when given a prefix argument) to print a .dvi file.  root committed Aug 28, 1990 314 315 316 317 318 319 tex-dvi-view-command Command string used by \\[tex-view] to preview a .dvi file. tex-show-queue-command Command string used by \\[tex-show-print-queue] to show the print queue that \\[tex-print] put your job on.  Eric S. Raymond committed Apr 26, 1993 320 321 322 323 Entering Plain-tex mode calls the value of text-mode-hook', then the value of tex-mode-hook', and then the value of plain-tex-mode-hook'. When the special subshell is initiated, the value of tex-shell-hook' is called."  root committed Aug 28, 1990 324 325 326 327 328 329 330 331 332  (interactive) (tex-common-initialization) (setq mode-name "TeX") (setq major-mode 'plain-tex-mode) (setq tex-command tex-run-command) (setq tex-start-of-header "%**start of header") (setq tex-end-of-header "%**end of header") (setq tex-trailer "\\bye\n") (run-hooks 'text-mode-hook 'tex-mode-hook 'plain-tex-mode-hook))  Jim Blandy committed May 13, 1991 333 ;;;###autoload  Eric S. Raymond committed Apr 23, 1993 334 (defalias 'plain-TeX-mode 'plain-tex-mode)  root committed Aug 28, 1990 335   Roland McGrath committed May 09, 1991 336 ;;;###autoload  root committed Aug 28, 1990 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 (defun latex-mode () "Major mode for editing files of input for LaTeX. Makes  and } display the characters they match. Makes \" insert  when it seems to be the beginning of a quotation, and '' when it appears to be the end; it inserts \" only after a \\. Use \\[tex-region] to run LaTeX on the current region, plus the preamble copied from the top of the file (containing \\documentstyle, etc.), running LaTeX under a special subshell. \\[tex-buffer] does the whole buffer. \\[tex-file] saves the buffer and then processes the file. \\[tex-print] prints the .dvi file made by any of these. \\[tex-view] previews the .dvi file made by any of these. \\[tex-bibtex-file] runs bibtex on the file of the current buffer. Use \\[validate-tex-buffer] to check buffer for paragraphs containing mismatched 's or braces. Special commands: \\{tex-mode-map} Mode variables: latex-run-command Command string used by \\[tex-region] or \\[tex-buffer]. tex-directory Directory in which to create temporary files for LaTeX jobs run by \\[tex-region] or \\[tex-buffer]. tex-dvi-print-command Command string used by \\[tex-print] to print a .dvi file.  Richard M. Stallman committed Jul 04, 1992 365 366 367 tex-alt-dvi-print-command Alternative command string used by \\[tex-print] (when given a prefix argument) to print a .dvi file.  root committed Aug 28, 1990 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 tex-dvi-view-command Command string used by \\[tex-view] to preview a .dvi file. tex-show-queue-command Command string used by \\[tex-show-print-queue] to show the print queue that \\[tex-print] put your job on. Entering Latex mode calls the value of text-mode-hook, then the value of tex-mode-hook, and then the value of latex-mode-hook. When the special subshell is initiated, the value of tex-shell-hook is called." (interactive) (tex-common-initialization) (setq mode-name "LaTeX") (setq major-mode 'latex-mode) (setq tex-command latex-run-command) (setq tex-start-of-header "\\documentstyle") (setq tex-end-of-header "\\begin{document}") (setq tex-trailer "\\end{document}\n") (run-hooks 'text-mode-hook 'tex-mode-hook 'latex-mode-hook))  Brian Fox committed Sep 21, 1993 387 ;;;###autoload  root committed Aug 28, 1990 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 (defun slitex-mode () "Major mode for editing files of input for SliTeX. Makes  and } display the characters they match. Makes \" insert  when it seems to be the beginning of a quotation, and '' when it appears to be the end; it inserts \" only after a \\. Use \\[tex-region] to run SliTeX on the current region, plus the preamble copied from the top of the file (containing \\documentstyle, etc.), running SliTeX under a special subshell. \\[tex-buffer] does the whole buffer. \\[tex-file] saves the buffer and then processes the file. \\[tex-print] prints the .dvi file made by any of these. \\[tex-view] previews the .dvi file made by any of these. \\[tex-bibtex-file] runs bibtex on the file of the current buffer. Use \\[validate-tex-buffer] to check buffer for paragraphs containing mismatched 's or braces. Special commands: \\{tex-mode-map} Mode variables: slitex-run-command Command string used by \\[tex-region] or \\[tex-buffer]. tex-directory Directory in which to create temporary files for SliTeX jobs run by \\[tex-region] or \\[tex-buffer]. tex-dvi-print-command Command string used by \\[tex-print] to print a .dvi file.  Richard M. Stallman committed Jul 04, 1992 416 417 418 tex-alt-dvi-print-command Alternative command string used by \\[tex-print] (when given a prefix argument) to print a .dvi file.  root committed Aug 28, 1990 419 420 421 422 423 424 tex-dvi-view-command Command string used by \\[tex-view] to preview a .dvi file. tex-show-queue-command Command string used by \\[tex-show-print-queue] to show the print queue that \\[tex-print] put your job on.  Eric S. Raymond committed Apr 26, 1993 425 426 427 428 Entering SliTeX mode calls the value of text-mode-hook', then the value of tex-mode-hook', then the value of latex-mode-hook', and then the value of slitex-mode-hook'. When the special subshell is initiated, the value of tex-shell-hook' is called."  root committed Aug 28, 1990 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472  (interactive) (tex-common-initialization) (setq mode-name "SliTeX") (setq major-mode 'slitex-mode) (setq tex-command slitex-run-command) (setq tex-start-of-header "\\documentstyle{slides}") (setq tex-end-of-header "\\begin{document}") (setq tex-trailer "\\end{document}\n") (run-hooks 'text-mode-hook 'tex-mode-hook 'latex-mode-hook 'slitex-mode-hook)) (defun tex-common-initialization () (kill-all-local-variables) (use-local-map tex-mode-map) (setq local-abbrev-table text-mode-abbrev-table) (if (null tex-mode-syntax-table) (let ((char 0)) (setq tex-mode-syntax-table (make-syntax-table)) (set-syntax-table tex-mode-syntax-table) (while (< char ? ) (modify-syntax-entry char ".") (setq char (1+ char))) (modify-syntax-entry ?\C-@ "w") (modify-syntax-entry ?\t " ") (modify-syntax-entry ?\n ">") (modify-syntax-entry ?\f ">") (modify-syntax-entry ? "") (modify-syntax-entry ?% "<") (modify-syntax-entry ?\\ "/") (modify-syntax-entry ?\" ".") (modify-syntax-entry ?& ".") (modify-syntax-entry ?_ ".") (modify-syntax-entry ?@ "_") (modify-syntax-entry ?~ " ") (modify-syntax-entry ?' "w")) (set-syntax-table tex-mode-syntax-table)) (make-local-variable 'paragraph-start) (setq paragraph-start "^[ \t]*\\|^[\f\\\\%]") (make-local-variable 'paragraph-separate) (setq paragraph-separate paragraph-start) (make-local-variable 'comment-start) (setq comment-start "%") (make-local-variable 'comment-start-skip) (setq comment-start-skip "\$$\\(^\\|[^\$\$$\$$\\\\\\\\\$$*\\)\$$%+ *\$$")  Eric S. Raymond committed Mar 22, 1993 473 474  (make-local-variable 'comment-indent-function) (setq comment-indent-function 'tex-comment-indent)  root committed Aug 28, 1990 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520  (make-local-variable 'compare-windows-whitespace) (setq compare-windows-whitespace 'tex-categorize-whitespace) (make-local-variable 'tex-command) (make-local-variable 'tex-start-of-header) (make-local-variable 'tex-end-of-header) (make-local-variable 'tex-trailer)) (defun tex-comment-indent () (if (looking-at "%%%") (current-column) (skip-chars-backward " \t") (max (if (bolp) 0 (1+ (current-column))) comment-column))) (defun tex-categorize-whitespace (backward-limit) ;; compare-windows-whitespace is set to this. ;; This is basically a finite-state machine. ;; Returns a symbol telling how TeX would treat ;; the whitespace we are looking at: null, space, or par. (let ((category 'null) (not-finished t)) (skip-chars-backward " \t\n\f" backward-limit) (while not-finished (cond ((looking-at "[ \t]+") (goto-char (match-end 0)) (if (eql category 'null) (setq category 'space))) ((looking-at "\n") (cond ((eql category 'newline) (setq category 'par) (setq not-finished nil)) (t (setq category 'newline) ;a strictly internal state (goto-char (match-end 0))))) ((looking-at "\f+") (setq category 'par) (setq not-finished nil)) (t (setq not-finished nil)))) (skip-chars-forward " \t\n\f") (if (eql category 'newline) 'space ;TeX doesn't distinguish category))) (defun tex-insert-quote (arg) "Insert the appropriate quote marks for TeX.  Richard M. Stallman committed May 16, 1993 521 522 Inserts the value of tex-open-quote' (normally ) or tex-close-quote' $$normally '') depending on the context. With prefix argument, always  root committed Aug 28, 1990 523 inserts \" characters."  Richard M. Stallman committed Jul 04, 1992 524  (interactive "*P")  root committed Aug 28, 1990 525 526 527 528 529 530 531 532 533 534 535 536 537 538  (if arg (self-insert-command (prefix-numeric-value arg)) (insert (cond ((or (bobp) (save-excursion (forward-char -1) (looking-at "\\s(\\|\\s \\|\\s>"))) tex-open-quote) ((= (preceding-char) ?\$$ ?\") (t tex-close-quote))))) (defun validate-tex-buffer ()  Eric S. Raymond committed Apr 26, 1993 539  "Check current buffer for paragraphs containing mismatched $s.  Richard M. Stallman committed Jul 31, 1993 540 541 542 543 Their positions are recorded in the buffer *Occur*'. To find a particular invalidity from *Occur*', switch to to that buffer and type C-c C-c on the line for the invalidity you want to see."  root committed Aug 28, 1990 544  (interactive)  Richard M. Stallman committed Jul 31, 1993 545 546 547 548 549 550 551 552 553 554 555 556 557  (let ((buffer (current-buffer)) (prevpos (point-min)) (linenum nil)) (with-output-to-temp-buffer "*Occur*" (princ "Mismatches:\n") (save-excursion (set-buffer standard-output) (occur-mode) (setq occur-buffer buffer) (setq occur-nlines 0) (setq occur-pos-list nil)) (save-excursion (goto-char (point-max))  root committed Aug 28, 1990 558 559  (while (and (not (input-pending-p)) (not (bobp))) (let ((end (point)))  Richard M. Stallman committed Jul 31, 1993 560  ;; Scan the previous paragraph for invalidities.  root committed Aug 28, 1990 561 562  (search-backward "\n\n" nil 'move) (or (tex-validate-region (point) end)  Richard M. Stallman committed Jul 31, 1993 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592  (let* ((end (save-excursion (forward-line 1) (point))) start tem) (beginning-of-line) (setq start (point)) ;; Keep track of line number as we scan, ;; in a cumulative fashion. (if linenum (setq linenum (- linenum (count-lines prevpos (point)))) (setq linenum (1+ (count-lines 1 start)))) (setq prevpos (point)) ;; Mention this mismatch in *Occur*. ;; Since we scan from end of buffer to beginning, ;; add each mismatch at the beginning of *Occur* ;; and at the beginning of occur-pos-list. (save-excursion (setq tem (point-marker)) (set-buffer standard-output) (goto-char (point-min)) ;; Skip "Mismatches:" header line. (forward-line 1) (setq occur-pos-list (cons tem occur-pos-list)) (insert-buffer-substring buffer start end) (forward-char (- start end)) (insert (format "%3d: " linenum)))))))) (save-excursion (set-buffer standard-output) (if (null occur-pos-list) (insert "None!\n")) (if (interactive-p) (message "%d mismatches found" (length occur-pos-list)))))))  root committed Aug 28, 1990 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618  (defun tex-validate-region (start end) "Check for mismatched braces or$'s in region. Returns t if no mismatches. Returns nil and moves point to suspect area if a mismatch is found." (interactive "r") (let ((failure-point nil) (max-possible-sexps (- end start))) (save-excursion (condition-case () (save-restriction (narrow-to-region start end) (goto-char start) (while (< 0 (setq max-possible-sexps (1- max-possible-sexps))) (forward-sexp 1))) (error (setq failure-point (point))))) (if failure-point (progn (goto-char failure-point) nil) t))) (defun tex-terminate-paragraph (inhibit-validation) "Insert two newlines, breaking a paragraph for TeX. Check for mismatched braces/$'s in paragraph being terminated. A prefix arg inhibits the checking."  Richard M. Stallman committed Jul 04, 1992 619  (interactive "*P")  root committed Aug 28, 1990 620 621 622 623 624 625 626 627 628 629 630 631  (or inhibit-validation (save-excursion (tex-validate-region (save-excursion (search-backward "\n\n" nil 'move) (point)) (point))) (message "Paragraph being closed appears to contain a mismatch")) (insert "\n\n")) (defun tex-insert-braces () "Make a pair of braces and be poised to type inside of them."  Richard M. Stallman committed Jul 04, 1992 632  (interactive "*")  root committed Aug 28, 1990 633 634 635 636 637 638 639 640  (insert ?\{) (save-excursion (insert ?}))) ;;; Like tex-insert-braces, but for LaTeX. (defun tex-latex-block (name) "Creates a matching pair of lines \\begin{NAME} and \\end{NAME} at point. Puts point on a blank line between them."  Richard M. Stallman committed Jul 04, 1992 641 642 643 644 645 646 647 648  (interactive (prog2 (barf-if-buffer-read-only) (list (completing-read "LaTeX block name: " (mapcar 'list (append standard-latex-block-names latex-block-names))))))  root committed Aug 28, 1990 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669  (let ((col (current-column))) (insert (format "\\begin{%s}\n" name)) (indent-to col) (save-excursion (insert ?\n) (indent-to col) (insert-string (format "\\end{%s}" name)) (if (eobp) (insert ?\n))))) (defun tex-last-unended-begin () "Leave point at the beginning of the last \\begin{...} that is unended." (while (and (re-search-backward "\$$\\\\begin\\s *{\$$\\|\$$\\\\end\\s *{\$$") (looking-at "\\\\end{")) (tex-last-unended-begin))) (defun tex-close-latex-block () "Creates an \\end{...} to match the last unclosed \\begin{...}." (interactive "*") (let ((new-line-needed (bolp)) text indentation) (save-excursion  Richard M. Stallman committed Jul 04, 1992 670  (condition-case nil  root committed Aug 28, 1990 671 672 673 674 675 676 677 678 679  (tex-last-unended-begin) (error (error "Couldn't find unended \\begin"))) (setq indentation (current-column)) (re-search-forward "\\\\begin\$$\\s *{[^}\n]*}\$$") (setq text (buffer-substring (match-beginning 1) (match-end 1)))) (indent-to indentation) (insert "\\end" text) (if new-line-needed (insert ?\n))))  Eric S. Raymond committed Apr 25, 1993 680 681 682 683 684 (defun tex-compilation-parse-errors () "Parse the current buffer as error messages. This makes a list of error descriptors, compilation-error-list. For each source-file, line-number pair in the buffer, the source file is read in, and the text location is saved in  Eric S. Raymond committed Apr 26, 1993 685 compilation-error-list. The function next-error', assigned to  Eric S. Raymond committed Apr 25, 1993 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 \$next-error], takes the next error off the list and visits its location. This function works on TeX compilations only. It is necessary for that purpose, since TeX does not put file names on the same line as line numbers for the errors." (setq compilation-error-list nil) (message "Parsing error messages...") (modify-syntax-entry ?\{ "_") (modify-syntax-entry ?\} "_") (modify-syntax-entry ?\[ "_") (modify-syntax-entry ?$ "_") (let (text-buffer last-filename last-linenum) ;; Don't reparse messages already seen at last parse. (goto-char compilation-parsing-end) ;; Don't parse the first two lines as error messages. ;; This matters for grep. (if (bobp) (forward-line 2))  Eric S. Raymond committed Apr 26, 1993 705  (while (re-search-forward "^l\.[0-9]+ " nil t)  Eric S. Raymond committed Apr 25, 1993 706 707 708 709 710 711 712 713 714 715 716 717  (let (linenum filename error-marker text-marker) ;; Extract file name and line number from error message. ;; Line number is 2 away from beginning of line: "l.23" (beginning-of-line) (goto-char (+ (point) 2)) (setq linenum (read (current-buffer))) ;; The file is the one that was opened last and is still open. ;; We need to find the last open parenthesis. (insert ?\)) (backward-sexp) (forward-char)  Eric S. Raymond committed Apr 26, 1993 718  (setq filename (current-word))  Eric S. Raymond committed Apr 25, 1993 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752  ;; Locate the erring file and line. (if (and (equal filename last-filename) (= linenum last-linenum)) nil (skip-chars-backward "^(") (backward-char) (forward-sexp) (backward-delete-char 1) (setq error-marker (point-marker)) ;; text-buffer gets the buffer containing this error's file. (if (not (equal filename last-filename)) (setq text-buffer (and (file-exists-p (setq last-filename filename)) (find-file-noselect filename)) last-linenum 0)) (if text-buffer ;; Go to that buffer and find the erring line. (save-excursion (set-buffer text-buffer) (if (zerop last-linenum) (progn (goto-char 1) (setq last-linenum 1))) (forward-line (- linenum last-linenum)) (setq last-linenum linenum) (setq text-marker (point-marker)) (setq compilation-error-list (cons (list error-marker text-marker) compilation-error-list))))) (forward-line 1))) (setq compilation-parsing-end (point-max))) (message "Parsing error messages...done") (setq compilation-error-list (nreverse compilation-error-list)))  root committed Aug 28, 1990 753 754 755 756 757 758 759 760 761 ;;; Invoking TeX in an inferior shell. ;;; Why use a shell instead of running TeX directly? Because if TeX ;;; gets stuck, the user can switch to the shell window and type at it. ;;; The utility functions: (defun tex-start-shell () (save-excursion  Richard M. Stallman committed Jul 04, 1992 762 763 764 765  (set-buffer (make-comint "tex-shell" (or tex-shell-file-name (getenv "ESHELL") (getenv "SHELL") "/bin/sh")  Richard M. Stallman committed Nov 20, 1993 766  nil))  Richard M. Stallman committed Jul 04, 1992 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785  (let ((proc (get-process "tex-shell"))) (set-process-sentinel proc 'tex-shell-sentinel) (process-kill-without-query proc) (setq tex-shell-map (copy-keymap comint-mode-map)) (tex-define-common-keys tex-shell-map) (use-local-map tex-shell-map) (run-hooks 'tex-shell-hook) (while (zerop (buffer-size)) (sleep-for 1))))) (defun tex-shell-sentinel (proc msg) (cond ((null (buffer-name (process-buffer proc))) ;; buffer killed (set-process-buffer proc nil) (tex-delete-last-temp-files)) ((memq (process-status proc) '(signal exit)) (tex-delete-last-temp-files)))) (defun tex-set-buffer-directory (buffer directory)  root committed Aug 28, 1990 786 787 788 789 790 791 792 793  "Set BUFFER's default directory to be DIRECTORY." (setq directory (file-name-as-directory (expand-file-name directory))) (if (not (file-directory-p directory)) (error "%s is not a directory" directory) (save-excursion (set-buffer buffer) (setq default-directory directory))))  Richard M. Stallman committed Nov 20, 1993 794 795 796 (defvar tex-send-command-modified-tick 0) (make-variable-buffer-local 'tex-send-command-modified-tick)  Richard M. Stallman committed Jul 04, 1992 797 (defun tex-send-command (command &optional file background)  Richard M. Stallman committed Nov 20, 1993 798  "Send COMMAND to TeX shell process, substituting optional FILE for *.  Eric S. Raymond committed Apr 26, 1993 799 800 801 802 Do this in background if optional BACKGROUND is t. If COMMAND has no *, FILE will be appended, preceded by a blank, to COMMAND. If FILE is nil, no substitution will be made in COMMAND. COMMAND can be any expression that evaluates to a command string."  Richard M. Stallman committed Jul 04, 1992 803 804  (save-excursion (let* ((cmd (eval command))  Richard M. Stallman committed Nov 20, 1993 805  (proc (get-process "tex-shell"))  Jim Blandy committed Mar 19, 1993 806  (star (string-match "\\*" cmd))  Richard M. Stallman committed Nov 20, 1993 807 808 809 810 811 812 813 814  (string (concat (if file (if star (concat (substring cmd 0 star) file (substring cmd (1+ star))) (concat cmd " " file)) cmd) (if background "&" ""))))  Richard M. Stallman committed Nov 20, 1993 815 816 817 818  ;; If text is unchanged since previous tex-send-command, ;; we haven't got any output. So wait for output now. (if (= (buffer-modified-tick) tex-send-command-modified-tick) (accept-process-output proc))  Richard M. Stallman committed Nov 20, 1993 819 820 821  (set-buffer (process-buffer proc)) (goto-char (process-mark proc)) (insert string)  Richard M. Stallman committed Nov 20, 1993 822 823  (comint-send-input) (setq tex-send-command-modified-tick (buffer-modified-tick)))))  Richard M. Stallman committed Jul 04, 1992 824 825 826 827 828 829 830 831 832 833 834  (defun tex-delete-last-temp-files () "Delete any junk files from last temp file." (if tex-last-temp-file (let* ((dir (file-name-directory tex-last-temp-file)) (list (file-name-all-completions (file-name-nondirectory tex-last-temp-file) dir))) (while list (delete-file (concat dir (car list))) (setq list (cdr list))))))  Richard M. Stallman committed Jul 05, 1992 835 (add-hook 'kill-emacs-hook 'tex-delete-last-temp-files)  root committed Aug 28, 1990 836   Richard M. Stallman committed Jul 04, 1992 837 ;;; The commands:  root committed Aug 28, 1990 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857  (defun tex-region (beg end) "Run TeX on the current region, via a temporary file. The file's name comes from the variable tex-zap-file' and the variable tex-directory' says where to put it. If the buffer has a header, the header is given to TeX before the region itself. The buffer's header is all lines between the strings defined by tex-start-of-header' and tex-end-of-header' inclusive. The header must start in the first 100 lines of the buffer. The value of tex-trailer' is given to TeX as input after the region. The value of tex-command' specifies the command to use to run TeX." (interactive "r") (if (tex-shell-running) (tex-kill-job) (tex-start-shell)) (or tex-zap-file (setq tex-zap-file (tex-generate-zap-file-name)))  Richard M. Stallman committed Jul 04, 1992 858 859 860 861 862 863 864 865 866 867  (let* ((temp-buffer (get-buffer-create " TeX-Output-Buffer")) ; Temp file will be written and TeX will be run in zap-directory. ; If the TEXINPUTS file has relative directories or if the region has ; \input of files, this must be the same directory as the file for ; TeX to access the correct inputs. That's why it's safest if ; tex-directory is ".". (zap-directory (file-name-as-directory (expand-file-name tex-directory))) (tex-out-file (concat zap-directory tex-zap-file))) (tex-delete-last-temp-files)  root committed Aug 28, 1990 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886  ;; Write the new temp file. (save-excursion (save-restriction (widen) (goto-char (point-min)) (forward-line 100) (let ((search-end (point)) (hbeg (point-min)) (hend (point-min)) (default-directory zap-directory)) (goto-char (point-min)) ;; Initialize the temp file with either the header or nothing (if (search-forward tex-start-of-header search-end t) (progn (beginning-of-line) (setq hbeg (point)) ;mark beginning of header (if (search-forward tex-end-of-header nil t) (progn (forward-line 1) (setq hend (point))) ;mark end of header (setq hbeg (point-min))))) ;no header  Richard M. Stallman committed Jul 04, 1992 887 888 889  (write-region (min hbeg beg) hend (concat tex-out-file ".tex") nil nil) (write-region (max beg hend) end (concat tex-out-file ".tex") t nil))  root committed Aug 28, 1990 890 891 892 893 894 895  (let ((local-tex-trailer tex-trailer)) (set-buffer temp-buffer) (erase-buffer) ;; make sure trailer isn't hidden by a comment (insert-string "\n") (if local-tex-trailer (insert-string local-tex-trailer))  Richard M. Stallman committed Jul 04, 1992 896 897 898 899 900 901 902 903 904  (tex-set-buffer-directory temp-buffer zap-directory) (write-region (point-min) (point-max) (concat tex-out-file ".tex") t nil)))) ;; Record the file name to be deleted afterward. (setq tex-last-temp-file tex-out-file) (tex-send-command tex-shell-cd-command zap-directory) (tex-send-command tex-command tex-out-file) (setq tex-print-file tex-out-file) (setq tex-last-buffer-texed (current-buffer))))  root committed Aug 28, 1990 905 906 907  (defun tex-buffer () "Run TeX on current buffer. See \\[tex-region] for more information.  Richard M. Stallman committed Jul 04, 1992 908 909 Does not save the buffer, so it's useful for trying experimental versions. See \\[tex-file] for an alternative."  root committed Aug 28, 1990 910 911 912 913 914 915 916 917 918 919 920 921 922  (interactive) (tex-region (point-min) (point-max))) (defun tex-file () "Prompt to save all buffers and run TeX (or LaTeX) on current buffer's file. This function is more useful than \\[tex-buffer] when you need the .aux' file of LaTeX to have the correct name." (interactive) (let ((tex-out-file (if (buffer-file-name) (file-name-nondirectory (buffer-file-name)) (error "Buffer does not seem to be associated with any file"))) (file-dir (file-name-directory (buffer-file-name))))  Jim Blandy committed Jul 10, 1992 923  (if tex-offer-save  Richard M. Stallman committed Jul 05, 1992 924  (save-some-buffers))  root committed Aug 28, 1990 925 926 927  (if (tex-shell-running) (tex-kill-job) (tex-start-shell))  Richard M. Stallman committed Jul 04, 1992 928 929  (tex-send-command tex-shell-cd-command file-dir) (tex-send-command tex-command tex-out-file))  root committed Aug 28, 1990 930  (setq tex-last-buffer-texed (current-buffer))  Richard M. Stallman committed Jul 04, 1992 931  (setq tex-print-file (buffer-file-name)))  root committed Aug 28, 1990 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964  (defun tex-generate-zap-file-name () "Generate a unique name suitable for use as a file name." ;; Include the shell process number and host name ;; in case there are multiple shells (for same or different user). (format "#tz%d%s" (process-id (get-buffer-process "*tex-shell*")) (tex-strip-dots (system-name)))) (defun tex-strip-dots (s) (setq s (copy-sequence s)) (while (string-match "\\." s) (aset s (match-beginning 0) ?-)) s) ;; This will perhaps be useful for modifying TEXINPUTS. ;; Expand each file name, separated by colons, in the string S. (defun tex-expand-files (s) (let (elts (start 0)) (while (string-match ":" s start) (setq elts (cons (substring s start (match-beginning 0)) elts)) (setq start (match-end 0))) (or (= start 0) (setq elts (cons (substring s start) elts))) (mapconcat 'expand-file-name (nreverse elts) ":"))) (defun tex-shell-running () (and (get-process "tex-shell") (eq (process-status (get-process "tex-shell")) 'run))) (defun tex-kill-job () "Kill the currently running TeX job." (interactive)  Richard M. Stallman committed Jul 04, 1992 965  (quit-process (get-process "tex-shell") t))  root committed Aug 28, 1990 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981  (defun tex-recenter-output-buffer (linenum) "Redisplay buffer of TeX job output so that most recent output can be seen. The last line of the buffer is displayed on line LINE of the window, or centered if LINE is nil." (interactive "P") (let ((tex-shell (get-buffer "*tex-shell*")) (old-buffer (current-buffer))) (if (null tex-shell) (message "No TeX output buffer") (pop-to-buffer tex-shell) (bury-buffer tex-shell) (goto-char (point-max)) (recenter (if linenum (prefix-numeric-value linenum) (/ (window-height) 2)))  Richard M. Stallman committed Jul 04, 1992 982  (pop-to-buffer old-buffer))))  root committed Aug 28, 1990 983   Richard M. Stallman committed Jul 04, 1992 984 (defun tex-print (&optional alt)  root committed Aug 28, 1990 985  "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file].  Christopher Zaborsky committed Nov 10, 1992 986 987 Runs the shell command defined by tex-dvi-print-command'. If prefix argument is provided, use the alternative command, tex-alt-dvi-print-command'."  Richard M. Stallman committed Jul 04, 1992 988  (interactive "P")  root committed Aug 28, 1990 989 990 991 992 993  (let ((print-file-name-dvi (tex-append tex-print-file ".dvi")) test-name) (if (and (not (equal (current-buffer) tex-last-buffer-texed)) (file-newer-than-file-p (setq test-name (tex-append (buffer-file-name) ".dvi"))  Richard M. Stallman committed Jul 04, 1992 994  print-file-name-dvi))  root committed Aug 28, 1990 995  (setq print-file-name-dvi test-name))  Richard M. Stallman committed Jul 04, 1992 996 997 998 999 1000  (if (not (file-exists-p print-file-name-dvi)) (error "No appropriate .dvi' file could be found") (tex-send-command (if alt tex-alt-dvi-print-command tex-dvi-print-command) print-file-name-dvi t))))  root committed Aug 28, 1990 1001   Richard M. Stallman committed Nov 06, 1993 1002 1003 1004 1005 1006 1007 (defun tex-alt-print () "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file]. Runs the shell command defined by tex-alt-dvi-print-command." (interactive) (tex-print t))  root committed Aug 28, 1990 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 (defun tex-view () "Preview the last .dvi' file made by running TeX under Emacs. This means, made using \\[tex-region], \\[tex-buffer] or \\[tex-file]. The variable tex-dvi-view-command' specifies the shell command for preview." (interactive) (let ((tex-dvi-print-command tex-dvi-view-command)) (tex-print))) (defun tex-append (file-name suffix) "Append to FILENAME the suffix SUFFIX, using same algorithm TeX uses.  Richard M. Stallman committed Nov 06, 1993 1018 Pascal-based TeX scans for the first period, C TeX uses the last.  root committed Aug 28, 1990 1019 1020 1021 No period is retained immediately before SUFFIX, so normally SUFFIX starts with one." (if (stringp file-name)  Richard M. Stallman committed Nov 06, 1993 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037  (let ((file (file-name-nondirectory file-name)) trial-name) ;; try spliting on first period (setq trial-name (concat (file-name-directory file-name) (substring file 0 (string-match "\\." file)) suffix)) (if (or (file-exists-p trial-name) (file-exists-p (concat trial-name ".aux"))) ;for BibTeX files trial-name ;; not found, so split on last period (concat (file-name-directory file-name) (substring file 0 (string-match "\\.[^.]*$" file)) suffix)))  root committed Aug 28, 1990 1038 1039 1040 1041  " ")) (defun tex-show-print-queue () "Show the print queue that \\[tex-print] put your job on.  Christopher Zaborsky committed Nov 10, 1992 1042 Runs the shell command defined by tex-show-queue-command'."  root committed Aug 28, 1990 1043 1044 1045 1046  (interactive) (if (tex-shell-running) (tex-kill-job) (tex-start-shell))  Richard M. Stallman committed Jul 04, 1992 1047  (tex-send-command tex-show-queue-command))  root committed Aug 28, 1990 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057  (defun tex-bibtex-file () "Run BibTeX on the current buffer's file." (interactive) (if (tex-shell-running) (tex-kill-job) (tex-start-shell)) (let ((tex-out-file (tex-append (file-name-nondirectory (buffer-file-name)) "")) (file-dir (file-name-directory (buffer-file-name))))  Richard M. Stallman committed Jul 04, 1992 1058  (tex-send-command tex-shell-cd-command file-dir)  Eric S. Raymond committed Apr 26, 1993 1059  (tex-send-command tex-bibtex-command tex-out-file)))  Richard M. Stallman committed Jul 04, 1992 1060 1061  (run-hooks 'tex-mode-load-hook)  root committed Aug 28, 1990 1062   Jim Blandy committed Mar 16, 1992 1063 1064 (provide 'tex-mode)  Eric S. Raymond committed May 30, 1992 1065 ;;; tex-mode.el ends here ` Richard M. Stallman committed Jul 05, 1992 1066