Mercurial > emacs
comparison lisp/textmodes/tex-mode.el @ 2588:b0a1846fe3b8
Doc fixes. Also a few teaks to pacify the byte-compiler.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Mon, 26 Apr 1993 05:15:08 +0000 |
parents | 48318133e7a6 |
children | 2189edb30955 |
comparison
equal
deleted
inserted
replaced
2587:1cad2ff5ab80 | 2588:b0a1846fe3b8 |
---|---|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to |
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | 26 |
27 ;;; Code: | 27 ;;; Code: |
28 | 28 |
29 ;; This was a pain. Now, make-comint should autoload comint. | 29 (require 'comint) |
30 ;; (require 'comint) | |
31 (require 'compile) | 30 (require 'compile) |
32 | 31 |
33 ;;;###autoload | 32 ;;;###autoload |
34 (defvar tex-shell-file-name nil | 33 (defvar tex-shell-file-name nil |
35 "*If non-nil, is file name to use for the subshell in which TeX is run.") | 34 "*If non-nil, is file name to use for the subshell in which TeX is run.") |
214 | 213 |
215 (defvar tex-shell-map nil | 214 (defvar tex-shell-map nil |
216 "Keymap for the tex-shell. A comint-mode-map with a few additions.") | 215 "Keymap for the tex-shell. A comint-mode-map with a few additions.") |
217 | 216 |
218 ;(defalias 'TeX-mode 'tex-mode) ;in loaddefs. | 217 ;(defalias 'TeX-mode 'tex-mode) ;in loaddefs. |
218 | |
219 (defvar compare-windows-whitespace nil) ; Pacify the byte-compiler | |
219 | 220 |
220 ;;; This would be a lot simpler if we just used a regexp search, | 221 ;;; This would be a lot simpler if we just used a regexp search, |
221 ;;; but then it would be too slow. | 222 ;;; but then it would be too slow. |
222 ;;;###autoload | 223 ;;;###autoload |
223 (defun tex-mode () | 224 (defun tex-mode () |
285 Command string used by \\[tex-view] to preview a .dvi file. | 286 Command string used by \\[tex-view] to preview a .dvi file. |
286 tex-show-queue-command | 287 tex-show-queue-command |
287 Command string used by \\[tex-show-print-queue] to show the print | 288 Command string used by \\[tex-show-print-queue] to show the print |
288 queue that \\[tex-print] put your job on. | 289 queue that \\[tex-print] put your job on. |
289 | 290 |
290 Entering Plain-tex mode calls the value of text-mode-hook, then the value of | 291 Entering Plain-tex mode calls the value of `text-mode-hook', then the value |
291 tex-mode-hook, and then the value of plain-tex-mode-hook. When the special | 292 of `tex-mode-hook', and then the value of `plain-tex-mode-hook'. When the |
292 subshell is initiated, the value of tex-shell-hook is called." | 293 special subshell is initiated, the value of `tex-shell-hook' is called." |
294 | |
293 (interactive) | 295 (interactive) |
294 (tex-common-initialization) | 296 (tex-common-initialization) |
295 (setq mode-name "TeX") | 297 (setq mode-name "TeX") |
296 (setq major-mode 'plain-tex-mode) | 298 (setq major-mode 'plain-tex-mode) |
297 (setq tex-command tex-run-command) | 299 (setq tex-command tex-run-command) |
388 Command string used by \\[tex-view] to preview a .dvi file. | 390 Command string used by \\[tex-view] to preview a .dvi file. |
389 tex-show-queue-command | 391 tex-show-queue-command |
390 Command string used by \\[tex-show-print-queue] to show the print | 392 Command string used by \\[tex-show-print-queue] to show the print |
391 queue that \\[tex-print] put your job on. | 393 queue that \\[tex-print] put your job on. |
392 | 394 |
393 Entering SliTeX mode calls the value of text-mode-hook, then the value of | 395 Entering SliTeX mode calls the value of `text-mode-hook', then the value of |
394 tex-mode-hook, then the value of latex-mode-hook, and then the value of | 396 `tex-mode-hook', then the value of `latex-mode-hook', and then the value of |
395 slitex-mode-hook. When the special subshell is initiated, the value of | 397 `slitex-mode-hook'. When the special subshell is initiated, the value of |
396 tex-shell-hook is called." | 398 `tex-shell-hook' is called." |
397 (interactive) | 399 (interactive) |
398 (tex-common-initialization) | 400 (tex-common-initialization) |
399 (setq mode-name "SliTeX") | 401 (setq mode-name "SliTeX") |
400 (setq major-mode 'slitex-mode) | 402 (setq major-mode 'slitex-mode) |
401 (setq tex-command slitex-run-command) | 403 (setq tex-command slitex-run-command) |
502 ?\") | 504 ?\") |
503 (t | 505 (t |
504 tex-close-quote))))) | 506 tex-close-quote))))) |
505 | 507 |
506 (defun validate-tex-buffer () | 508 (defun validate-tex-buffer () |
507 "Check current buffer for paragraphs containing mismatched $'s. | 509 "Check current buffer for paragraphs containing mismatched $s. |
508 As each such paragraph is found, a mark is pushed at its beginning, | 510 As each such paragraph is found, a mark is pushed at its beginning, |
509 and the location is displayed for a few seconds." | 511 and the location is displayed for a few seconds." |
510 (interactive) | 512 (interactive) |
511 (let ((opoint (point))) | 513 (let ((opoint (point))) |
512 (goto-char (point-max)) | 514 (goto-char (point-max)) |
612 (defun tex-compilation-parse-errors () | 614 (defun tex-compilation-parse-errors () |
613 "Parse the current buffer as error messages. | 615 "Parse the current buffer as error messages. |
614 This makes a list of error descriptors, compilation-error-list. | 616 This makes a list of error descriptors, compilation-error-list. |
615 For each source-file, line-number pair in the buffer, | 617 For each source-file, line-number pair in the buffer, |
616 the source file is read in, and the text location is saved in | 618 the source file is read in, and the text location is saved in |
617 compilation-error-list. The function next-error, assigned to | 619 compilation-error-list. The function `next-error', assigned to |
618 \\[next-error], takes the next error off the list and visits its location. | 620 \\[next-error], takes the next error off the list and visits its location. |
619 | 621 |
620 This function works on TeX compilations only. It is necessary for | 622 This function works on TeX compilations only. It is necessary for |
621 that purpose, since TeX does not put file names on the same line as | 623 that purpose, since TeX does not put file names on the same line as |
622 line numbers for the errors." | 624 line numbers for the errors." |
624 (message "Parsing error messages...") | 626 (message "Parsing error messages...") |
625 (modify-syntax-entry ?\{ "_") | 627 (modify-syntax-entry ?\{ "_") |
626 (modify-syntax-entry ?\} "_") | 628 (modify-syntax-entry ?\} "_") |
627 (modify-syntax-entry ?\[ "_") | 629 (modify-syntax-entry ?\[ "_") |
628 (modify-syntax-entry ?\] "_") | 630 (modify-syntax-entry ?\] "_") |
629 (make-variable-buffer-local 'compilation-error-regexp) | |
630 (setq compilation-error-regexp "^l\.[0-9]+ ") | |
631 (let (text-buffer | 631 (let (text-buffer |
632 last-filename last-linenum) | 632 last-filename last-linenum) |
633 ;; Don't reparse messages already seen at last parse. | 633 ;; Don't reparse messages already seen at last parse. |
634 (goto-char compilation-parsing-end) | 634 (goto-char compilation-parsing-end) |
635 ;; Don't parse the first two lines as error messages. | 635 ;; Don't parse the first two lines as error messages. |
636 ;; This matters for grep. | 636 ;; This matters for grep. |
637 (if (bobp) | 637 (if (bobp) |
638 (forward-line 2)) | 638 (forward-line 2)) |
639 (while (re-search-forward compilation-error-regexp nil t) | 639 (while (re-search-forward "^l\.[0-9]+ " nil t) |
640 (let (linenum filename | 640 (let (linenum filename |
641 error-marker text-marker) | 641 error-marker text-marker) |
642 ;; Extract file name and line number from error message. | 642 ;; Extract file name and line number from error message. |
643 ;; Line number is 2 away from beginning of line: "l.23" | 643 ;; Line number is 2 away from beginning of line: "l.23" |
644 (beginning-of-line) | 644 (beginning-of-line) |
647 ;; The file is the one that was opened last and is still open. | 647 ;; The file is the one that was opened last and is still open. |
648 ;; We need to find the last open parenthesis. | 648 ;; We need to find the last open parenthesis. |
649 (insert ?\)) | 649 (insert ?\)) |
650 (backward-sexp) | 650 (backward-sexp) |
651 (forward-char) | 651 (forward-char) |
652 (setq filename (compilation-grab-filename)) | 652 (setq filename (current-word)) |
653 ;; Locate the erring file and line. | 653 ;; Locate the erring file and line. |
654 (if (and (equal filename last-filename) | 654 (if (and (equal filename last-filename) |
655 (= linenum last-linenum)) | 655 (= linenum last-linenum)) |
656 nil | 656 nil |
657 (skip-chars-backward "^(") | 657 (skip-chars-backward "^(") |
724 (save-excursion | 724 (save-excursion |
725 (set-buffer buffer) | 725 (set-buffer buffer) |
726 (setq default-directory directory)))) | 726 (setq default-directory directory)))) |
727 | 727 |
728 (defun tex-send-command (command &optional file background) | 728 (defun tex-send-command (command &optional file background) |
729 "Send COMMAND to tex-shell, substituting optional FILE for *; in background | 729 "Send COMMAND to tex-shell, substituting optional FILE for *. |
730 if optional BACKGROUND is t. If COMMAND has no *, FILE will be appended, | 730 Do this in background if optional BACKGROUND is t. If COMMAND has no *, |
731 preceded by a blank, to COMMAND. If FILE is nil, no substitution will be made | 731 FILE will be appended, preceded by a blank, to COMMAND. If FILE is nil, no |
732 in COMMAND. COMMAND can be any expression that evaluates to a command string." | 732 substitution will be made in COMMAND. COMMAND can be any expression that |
733 evaluates to a command string." | |
733 (save-excursion | 734 (save-excursion |
734 (let* ((cmd (eval command)) | 735 (let* ((cmd (eval command)) |
735 (star (string-match "\\*" cmd)) | 736 (star (string-match "\\*" cmd)) |
736 (front (substring cmd 0 star)) | 737 (front (substring cmd 0 star)) |
737 (back (if star (substring cmd (1+ star)) ""))) | 738 (back (if star (substring cmd (1+ star)) ""))) |
957 (tex-start-shell)) | 958 (tex-start-shell)) |
958 (let ((tex-out-file | 959 (let ((tex-out-file |
959 (tex-append (file-name-nondirectory (buffer-file-name)) "")) | 960 (tex-append (file-name-nondirectory (buffer-file-name)) "")) |
960 (file-dir (file-name-directory (buffer-file-name)))) | 961 (file-dir (file-name-directory (buffer-file-name)))) |
961 (tex-send-command tex-shell-cd-command file-dir) | 962 (tex-send-command tex-shell-cd-command file-dir) |
962 (tex-send-command bibtex-command tex-out-file))) | 963 (tex-send-command tex-bibtex-command tex-out-file))) |
963 | 964 |
964 (run-hooks 'tex-mode-load-hook) | 965 (run-hooks 'tex-mode-load-hook) |
965 | 966 |
966 (provide 'tex-mode) | 967 (provide 'tex-mode) |
967 | 968 |