diff options
| author | Stefan Monnier | 2000-11-14 11:41:51 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-11-14 11:41:51 +0000 |
| commit | bdbd9606002777988d481d558dd0932c6f40a8ee (patch) | |
| tree | 4ea55f615c4dc1f96e9fa31e14241d89dc8a796b | |
| parent | 1265b5398a8c19e7b98a93010a8e50216a3163d0 (diff) | |
| download | emacs-bdbd9606002777988d481d558dd0932c6f40a8ee.tar.gz emacs-bdbd9606002777988d481d558dd0932c6f40a8ee.zip | |
(tex-font-lock-keywords-1): Use `keep'
rather than `prepend' and add an interesting comment.
(tex-math-face, tex-font-lock-syntactic-face-function):
New face and function to use it.
(tex-define-common-keys, tex-mode-map): Use menu-item rather
than `menu-enable' symbol property.
(tex-mode-map): Bind {, (, [ and $ to skeleton-pair-insert-maybe.
(tex-mode): Add some latex-mode commands for auto-selection.
Use tex-font-lock-syntactic-face-function.
(tex-insert-quote): Simplify.
(tex-shell): New mode.
(tex-start-shell): Use it.
(tex-shell-proc, tex-shell-buf): New functions.
(tex-send-command): Use it.
(tex-main-file): Fix the meaning of the new arg REALFILE.
(tex-send-tex-command): New function split from `tex-start-tex'.
Set compilation-last-buffer and compilation-parsing-end.
| -rw-r--r-- | lisp/ChangeLog | 18 | ||||
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 265 |
2 files changed, 164 insertions, 119 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 296133f9afb..34cd74fa5e5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,23 @@ | |||
| 1 | 2000-11-14 Stefan Monnier <monnier@cs.yale.edu> | 1 | 2000-11-14 Stefan Monnier <monnier@cs.yale.edu> |
| 2 | 2 | ||
| 3 | * textmodes/tex-mode.el (tex-font-lock-keywords-1): Use `keep' | ||
| 4 | rather than `prepend' and add an interesting comment. | ||
| 5 | (tex-math-face, tex-font-lock-syntactic-face-function): | ||
| 6 | New face and function to use it. | ||
| 7 | (tex-define-common-keys, tex-mode-map): Use menu-item rather | ||
| 8 | than `menu-enable' symbol property. | ||
| 9 | (tex-mode-map): Bind {, (, [ and $ to skeleton-pair-insert-maybe. | ||
| 10 | (tex-mode): Add some latex-mode commands for auto-selection. | ||
| 11 | Use tex-font-lock-syntactic-face-function. | ||
| 12 | (tex-insert-quote): Simplify. | ||
| 13 | (tex-shell): New mode. | ||
| 14 | (tex-start-shell): Use it. | ||
| 15 | (tex-shell-proc, tex-shell-buf): New functions. | ||
| 16 | (tex-send-command): Use it. | ||
| 17 | (tex-main-file): Fix the meaning of the new arg REALFILE. | ||
| 18 | (tex-send-tex-command): New function split from `tex-start-tex'. | ||
| 19 | Set compilation-last-buffer and compilation-parsing-end. | ||
| 20 | |||
| 3 | * newcomment.el (comment-indent-default): Stick \s<\s< to the left | 21 | * newcomment.el (comment-indent-default): Stick \s<\s< to the left |
| 4 | when it follows non-comment text on the line. | 22 | when it follows non-comment text on the line. |
| 5 | 23 | ||
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 8d60f4674d0..2f96300645c 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -446,15 +446,26 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 446 | (list | 446 | (list |
| 447 | ;; Heading args. | 447 | ;; Heading args. |
| 448 | (list (concat slash headings "\\*?" opt arg) | 448 | (list (concat slash headings "\\*?" opt arg) |
| 449 | 3 'font-lock-function-name-face 'prepend) | 449 | ;; If ARG ends up matching too much (if the {} don't match, f.ex) |
| 450 | ;; jit-lock will do funny things: when updating the buffer | ||
| 451 | ;; the re-highlighting is only done locally so it will just | ||
| 452 | ;; match the local line, but defer-contextually will | ||
| 453 | ;; match more lines at a time, so ARG will end up matching | ||
| 454 | ;; a lot more, which might suddenly include a comment | ||
| 455 | ;; so you get things highlighted bold when you type them | ||
| 456 | ;; but they get turned back to normal a little while later | ||
| 457 | ;; because "there's already a face there". | ||
| 458 | ;; Using `keep' works around this un-intuitive behavior as well | ||
| 459 | ;; as improves the behavior in the very rare case where you do have | ||
| 460 | ;; a comment in ARG. | ||
| 461 | 3 'font-lock-function-name-face 'keep) | ||
| 450 | ;; Variable args. | 462 | ;; Variable args. |
| 451 | (list (concat slash variables arg) 2 'font-lock-variable-name-face) | 463 | (list (concat slash variables arg) 2 'font-lock-variable-name-face) |
| 452 | ;; Include args. | 464 | ;; Include args. |
| 453 | (list (concat slash includes opt arg) 3 'font-lock-builtin-face) | 465 | (list (concat slash includes opt arg) 3 'font-lock-builtin-face) |
| 454 | ;; Definitions. I think. | 466 | ;; Definitions. I think. |
| 455 | '("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" | 467 | '("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" |
| 456 | 1 font-lock-function-name-face) | 468 | 1 font-lock-function-name-face)))) |
| 457 | ))) | ||
| 458 | "Subdued expressions to highlight in TeX modes.") | 469 | "Subdued expressions to highlight in TeX modes.") |
| 459 | 470 | ||
| 460 | (defconst tex-font-lock-keywords-2 | 471 | (defconst tex-font-lock-keywords-2 |
| @@ -505,13 +516,22 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 505 | ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. | 516 | ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. |
| 506 | (list (concat "\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>" | 517 | (list (concat "\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>" |
| 507 | "\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)") | 518 | "\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)") |
| 508 | 3 '(if (match-beginning 2) 'bold 'italic) 'append) | 519 | 3 '(if (match-beginning 2) 'bold 'italic) 'append))))) |
| 509 | )))) | ||
| 510 | "Gaudy expressions to highlight in TeX modes.") | 520 | "Gaudy expressions to highlight in TeX modes.") |
| 511 | 521 | ||
| 512 | (defvar tex-font-lock-keywords tex-font-lock-keywords-1 | 522 | (defvar tex-font-lock-keywords tex-font-lock-keywords-1 |
| 513 | "Default expressions to highlight in TeX modes.") | 523 | "Default expressions to highlight in TeX modes.") |
| 514 | 524 | ||
| 525 | |||
| 526 | (defface tex-math-face | ||
| 527 | '((t :inherit font-lock-string-face)) | ||
| 528 | "Face used to highlight TeX math expressions.") | ||
| 529 | (defvar tex-math-face 'tex-math-face) | ||
| 530 | |||
| 531 | ;; Use string syntax but math face for $...$. | ||
| 532 | (defun tex-font-lock-syntactic-face-function (state) | ||
| 533 | (if (nth 3 state) tex-math-face font-lock-comment-face)) | ||
| 534 | |||
| 515 | 535 | ||
| 516 | (defun tex-define-common-keys (keymap) | 536 | (defun tex-define-common-keys (keymap) |
| 517 | "Define the keys that we want defined both in TeX mode and in the TeX shell." | 537 | "Define the keys that we want defined both in TeX mode and in the TeX shell." |
| @@ -523,56 +543,56 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 523 | 543 | ||
| 524 | (define-key keymap [menu-bar tex] (cons "TeX" (make-sparse-keymap "TeX"))) | 544 | (define-key keymap [menu-bar tex] (cons "TeX" (make-sparse-keymap "TeX"))) |
| 525 | 545 | ||
| 526 | (define-key keymap [menu-bar tex tex-kill-job] '("Tex Kill" . tex-kill-job)) | 546 | (define-key keymap [menu-bar tex tex-kill-job] |
| 547 | '(menu-item "Tex Kill" tex-kill-job :enable (tex-shell-running))) | ||
| 527 | (define-key keymap [menu-bar tex tex-recenter-output-buffer] | 548 | (define-key keymap [menu-bar tex tex-recenter-output-buffer] |
| 528 | '("Tex Recenter" . tex-recenter-output-buffer)) | 549 | '(menu-item "Tex Recenter" tex-recenter-output-buffer |
| 550 | :enable (get-buffer "*tex-shell*"))) | ||
| 529 | (define-key keymap [menu-bar tex tex-show-print-queue] | 551 | (define-key keymap [menu-bar tex tex-show-print-queue] |
| 530 | '("Show Print Queue" . tex-show-print-queue)) | 552 | '("Show Print Queue" . tex-show-print-queue)) |
| 531 | (define-key keymap [menu-bar tex tex-alt-print] | 553 | (define-key keymap [menu-bar tex tex-alt-print] |
| 532 | '("Tex Print (alt printer)" . tex-alt-print)) | 554 | '(menu-item "Tex Print (alt printer)" tex-alt-print |
| 533 | (define-key keymap [menu-bar tex tex-print] '("Tex Print" . tex-print)) | 555 | :enable (stringp tex-print-file))) |
| 534 | (define-key keymap [menu-bar tex tex-view] '("Tex View" . tex-view)) | 556 | (define-key keymap [menu-bar tex tex-print] |
| 535 | ) | 557 | '(menu-item "Tex Print" tex-print :enable (stringp tex-print-file))) |
| 536 | 558 | (define-key keymap [menu-bar tex tex-view] | |
| 537 | (defvar tex-mode-map nil "Keymap for TeX mode.") | 559 | '(menu-item "Tex View" tex-view :enable (stringp tex-print-file)))) |
| 538 | 560 | ||
| 539 | (if tex-mode-map | 561 | (defvar tex-mode-map |
| 540 | nil | 562 | (let ((map (make-sparse-keymap))) |
| 541 | (setq tex-mode-map (make-sparse-keymap)) | 563 | (tex-define-common-keys map) |
| 542 | (tex-define-common-keys tex-mode-map) | 564 | (define-key map "\"" 'tex-insert-quote) |
| 543 | (define-key tex-mode-map "\"" 'tex-insert-quote) | 565 | (define-key map "(" 'skeleton-pair-insert-maybe) |
| 544 | (define-key tex-mode-map "\n" 'tex-terminate-paragraph) | 566 | (define-key map "{" 'skeleton-pair-insert-maybe) |
| 545 | (define-key tex-mode-map "\M-\r" 'latex-insert-item) | 567 | (define-key map "[" 'skeleton-pair-insert-maybe) |
| 546 | (define-key tex-mode-map "\C-c}" 'up-list) | 568 | (define-key map "$" 'skeleton-pair-insert-maybe) |
| 547 | (define-key tex-mode-map "\C-c{" 'tex-insert-braces) | 569 | (define-key map "\n" 'tex-terminate-paragraph) |
| 548 | (define-key tex-mode-map "\C-c\C-r" 'tex-region) | 570 | (define-key map "\M-\r" 'latex-insert-item) |
| 549 | (define-key tex-mode-map "\C-c\C-b" 'tex-buffer) | 571 | (define-key map "\C-c}" 'up-list) |
| 550 | (define-key tex-mode-map "\C-c\C-f" 'tex-file) | 572 | (define-key map "\C-c{" 'tex-insert-braces) |
| 551 | (define-key tex-mode-map "\C-c\C-i" 'tex-bibtex-file) | 573 | (define-key map "\C-c\C-r" 'tex-region) |
| 552 | (define-key tex-mode-map "\C-c\C-o" 'tex-latex-block) | 574 | (define-key map "\C-c\C-b" 'tex-buffer) |
| 553 | (define-key tex-mode-map "\C-c\C-e" 'tex-close-latex-block) | 575 | (define-key map "\C-c\C-f" 'tex-file) |
| 554 | (define-key tex-mode-map "\C-c\C-u" 'tex-goto-last-unclosed-latex-block) | 576 | (define-key map "\C-c\C-c" 'tex-compile) |
| 555 | (define-key tex-mode-map "\C-c\C-m" 'tex-feed-input) | 577 | (define-key map "\C-c\C-i" 'tex-bibtex-file) |
| 556 | (define-key tex-mode-map [(control return)] 'tex-feed-input) | 578 | (define-key map "\C-c\C-o" 'tex-latex-block) |
| 557 | (define-key tex-mode-map [menu-bar tex tex-bibtex-file] | 579 | (define-key map "\C-c\C-e" 'tex-close-latex-block) |
| 558 | '("BibTeX File" . tex-bibtex-file)) | 580 | (define-key map "\C-c\C-u" 'tex-goto-last-unclosed-latex-block) |
| 559 | (define-key tex-mode-map [menu-bar tex tex-validate-region] | 581 | (define-key map "\C-c\C-m" 'tex-feed-input) |
| 560 | '("Validate Region" . tex-validate-region)) | 582 | (define-key map [(control return)] 'tex-feed-input) |
| 561 | (define-key tex-mode-map [menu-bar tex tex-validate-buffer] | 583 | (define-key map [menu-bar tex tex-bibtex-file] |
| 562 | '("Validate Buffer" . tex-validate-buffer)) | 584 | '("BibTeX File" . tex-bibtex-file)) |
| 563 | (define-key tex-mode-map [menu-bar tex tex-region] | 585 | (define-key map [menu-bar tex tex-validate-region] |
| 564 | '("TeX Region" . tex-region)) | 586 | '(menu-item "Validate Region" tex-validate-region :enable mark-active)) |
| 565 | (define-key tex-mode-map [menu-bar tex tex-buffer] | 587 | (define-key map [menu-bar tex tex-validate-buffer] |
| 566 | '("TeX Buffer" . tex-buffer)) | 588 | '("Validate Buffer" . tex-validate-buffer)) |
| 567 | (define-key tex-mode-map [menu-bar tex tex-file] '("TeX File" . tex-file))) | 589 | (define-key map [menu-bar tex tex-region] |
| 568 | 590 | '(menu-item "TeX Region" tex-region :enable mark-active)) | |
| 569 | (put 'tex-region 'menu-enable 'mark-active) | 591 | (define-key map [menu-bar tex tex-buffer] |
| 570 | (put 'tex-validate-region 'menu-enable 'mark-active) | 592 | '("TeX Buffer" . tex-buffer)) |
| 571 | (put 'tex-print 'menu-enable '(stringp tex-print-file)) | 593 | (define-key map [menu-bar tex tex-file] '("TeX File" . tex-file)) |
| 572 | (put 'tex-alt-print 'menu-enable '(stringp tex-print-file)) | 594 | map) |
| 573 | (put 'tex-view 'menu-enable '(stringp tex-print-file)) | 595 | "Keymap for TeX modes.") |
| 574 | (put 'tex-recenter-output-buffer 'menu-enable '(get-buffer "*tex-shell*")) | ||
| 575 | (put 'tex-kill-job 'menu-enable '(tex-shell-running)) | ||
| 576 | 596 | ||
| 577 | (defvar tex-shell-map | 597 | (defvar tex-shell-map |
| 578 | (let ((m (make-sparse-keymap))) | 598 | (let ((m (make-sparse-keymap))) |
| @@ -614,13 +634,19 @@ says which mode to use." | |||
| 614 | (save-excursion | 634 | (save-excursion |
| 615 | (beginning-of-line) | 635 | (beginning-of-line) |
| 616 | (search-forward "%" search-end t)))))) | 636 | (search-forward "%" search-end t)))))) |
| 617 | (if (and slash (not comment)) | 637 | (when (and slash (not comment)) |
| 618 | (setq mode (if (looking-at "documentstyle\\|documentclass\\|begin\\b\\|NeedsTeXFormat{LaTeX") | 638 | (setq mode |
| 619 | (if (looking-at | 639 | (if (looking-at |
| 620 | "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") | 640 | (eval-when-compile |
| 621 | 'slitex-mode | 641 | (concat |
| 622 | 'latex-mode) | 642 | (regexp-opt '("documentstyle" "documentclass" |
| 623 | 'plain-tex-mode)))) | 643 | "begin" "section" "part" "chapter") 'words) |
| 644 | "\\|NeedsTeXFormat{LaTeX"))) | ||
| 645 | (if (looking-at | ||
| 646 | "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") | ||
| 647 | 'slitex-mode | ||
| 648 | 'latex-mode) | ||
| 649 | 'plain-tex-mode)))) | ||
| 624 | (funcall mode))) | 650 | (funcall mode))) |
| 625 | 651 | ||
| 626 | ;;;###autoload | 652 | ;;;###autoload |
| @@ -838,7 +864,9 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook | |||
| 838 | tex-font-lock-keywords-1 tex-font-lock-keywords-2) | 864 | tex-font-lock-keywords-1 tex-font-lock-keywords-2) |
| 839 | nil nil ((?$ . "\"")) nil | 865 | nil nil ((?$ . "\"")) nil |
| 840 | ;; Who ever uses that anyway ??? | 866 | ;; Who ever uses that anyway ??? |
| 841 | (font-lock-mark-block-function . mark-paragraph))) | 867 | (font-lock-mark-block-function . mark-paragraph) |
| 868 | (font-lock-syntactic-face-function | ||
| 869 | . tex-font-lock-syntactic-face-function))) | ||
| 842 | (make-local-variable 'tex-command) | 870 | (make-local-variable 'tex-command) |
| 843 | (make-local-variable 'tex-start-of-header) | 871 | (make-local-variable 'tex-start-of-header) |
| 844 | (make-local-variable 'tex-end-of-header) | 872 | (make-local-variable 'tex-end-of-header) |
| @@ -883,15 +911,9 @@ inserts \" characters." | |||
| 883 | (if arg | 911 | (if arg |
| 884 | (self-insert-command (prefix-numeric-value arg)) | 912 | (self-insert-command (prefix-numeric-value arg)) |
| 885 | (insert | 913 | (insert |
| 886 | (cond ((or (bobp) | 914 | (cond ((= (preceding-char) ?\\) ?\") |
| 887 | (save-excursion | 915 | ((memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) tex-open-quote) |
| 888 | (forward-char -1) | 916 | (t tex-close-quote))))) |
| 889 | (looking-at "\\s(\\|\\s \\|\\s>"))) | ||
| 890 | tex-open-quote) | ||
| 891 | ((= (preceding-char) ?\\) | ||
| 892 | ?\") | ||
| 893 | (t | ||
| 894 | tex-close-quote))))) | ||
| 895 | 917 | ||
| 896 | (defun tex-validate-buffer () | 918 | (defun tex-validate-buffer () |
| 897 | "Check current buffer for paragraphs containing mismatched braces or $s. | 919 | "Check current buffer for paragraphs containing mismatched braces or $s. |
| @@ -956,8 +978,7 @@ on the line for the invalidity you want to see." | |||
| 956 | (- (marker-position text-end) 1) | 978 | (- (marker-position text-end) 1) |
| 957 | 'occur tem))))) | 979 | 'occur tem))))) |
| 958 | (goto-char prev-end)))) | 980 | (goto-char prev-end)))) |
| 959 | (save-excursion | 981 | (with-current-buffer standard-output |
| 960 | (set-buffer standard-output) | ||
| 961 | (if (eq num-matches 0) | 982 | (if (eq num-matches 0) |
| 962 | (insert "None!\n")) | 983 | (insert "None!\n")) |
| 963 | (if (interactive-p) | 984 | (if (interactive-p) |
| @@ -990,11 +1011,8 @@ area if a mismatch is found." | |||
| 990 | (error | 1011 | (error |
| 991 | (skip-syntax-forward " .>") | 1012 | (skip-syntax-forward " .>") |
| 992 | (setq failure-point (point))))) | 1013 | (setq failure-point (point))))) |
| 993 | (if failure-point | 1014 | (if failure-point (goto-char failure-point)) |
| 994 | (progn | 1015 | (not failure-point))) |
| 995 | (goto-char failure-point) | ||
| 996 | nil) | ||
| 997 | t))) | ||
| 998 | 1016 | ||
| 999 | (defun tex-terminate-paragraph (inhibit-validation) | 1017 | (defun tex-terminate-paragraph (inhibit-validation) |
| 1000 | "Insert two newlines, breaking a paragraph for TeX. | 1018 | "Insert two newlines, breaking a paragraph for TeX. |
| @@ -1189,6 +1207,9 @@ Mark is left at original location." | |||
| 1189 | 1207 | ||
| 1190 | ;;; The utility functions: | 1208 | ;;; The utility functions: |
| 1191 | 1209 | ||
| 1210 | (define-derived-mode tex-shell shell-mode "TeX-Shell" | ||
| 1211 | (compilation-shell-minor-mode t)) | ||
| 1212 | |||
| 1192 | ;;;###autoload | 1213 | ;;;###autoload |
| 1193 | (defun tex-start-shell () | 1214 | (defun tex-start-shell () |
| 1194 | (with-current-buffer | 1215 | (with-current-buffer |
| @@ -1199,15 +1220,7 @@ Mark is left at original location." | |||
| 1199 | (let ((proc (get-process "tex-shell"))) | 1220 | (let ((proc (get-process "tex-shell"))) |
| 1200 | (set-process-sentinel proc 'tex-shell-sentinel) | 1221 | (set-process-sentinel proc 'tex-shell-sentinel) |
| 1201 | (process-kill-without-query proc) | 1222 | (process-kill-without-query proc) |
| 1202 | (setq comint-prompt-regexp shell-prompt-pattern) | 1223 | (tex-shell) |
| 1203 | (use-local-map tex-shell-map) | ||
| 1204 | (compilation-shell-minor-mode t) | ||
| 1205 | (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) | ||
| 1206 | (make-local-variable 'list-buffers-directory) | ||
| 1207 | (make-local-variable 'shell-dirstack) | ||
| 1208 | (make-local-variable 'shell-last-dir) | ||
| 1209 | (make-local-variable 'shell-dirtrackp) | ||
| 1210 | (run-hooks 'tex-shell-hook) | ||
| 1211 | (while (zerop (buffer-size)) | 1224 | (while (zerop (buffer-size)) |
| 1212 | (sleep-for 1))))) | 1225 | (sleep-for 1))))) |
| 1213 | 1226 | ||
| @@ -1245,6 +1258,11 @@ In the tex shell buffer this command behaves like `comint-send-input'." | |||
| 1245 | (defvar tex-send-command-modified-tick 0) | 1258 | (defvar tex-send-command-modified-tick 0) |
| 1246 | (make-variable-buffer-local 'tex-send-command-modified-tick) | 1259 | (make-variable-buffer-local 'tex-send-command-modified-tick) |
| 1247 | 1260 | ||
| 1261 | (defun tex-shell-proc () | ||
| 1262 | (or (get-process "tex-shell") (error "No TeX subprocess"))) | ||
| 1263 | (defun tex-shell-buf () | ||
| 1264 | (process-buffer (tex-shell-proc))) | ||
| 1265 | |||
| 1248 | (defun tex-send-command (command &optional file background) | 1266 | (defun tex-send-command (command &optional file background) |
| 1249 | "Send COMMAND to TeX shell process, substituting optional FILE for *. | 1267 | "Send COMMAND to TeX shell process, substituting optional FILE for *. |
| 1250 | Do this in background if optional BACKGROUND is t. If COMMAND has no *, | 1268 | Do this in background if optional BACKGROUND is t. If COMMAND has no *, |
| @@ -1255,7 +1273,7 @@ evaluates to a command string. | |||
| 1255 | Return the process in which TeX is running." | 1273 | Return the process in which TeX is running." |
| 1256 | (save-excursion | 1274 | (save-excursion |
| 1257 | (let* ((cmd (eval command)) | 1275 | (let* ((cmd (eval command)) |
| 1258 | (proc (or (get-process "tex-shell") (error "No TeX subprocess"))) | 1276 | (proc (tex-shell-proc)) |
| 1259 | (buf (process-buffer proc)) | 1277 | (buf (process-buffer proc)) |
| 1260 | (star (string-match "\\*" cmd)) | 1278 | (star (string-match "\\*" cmd)) |
| 1261 | (string | 1279 | (string |
| @@ -1329,28 +1347,30 @@ ALL other buffers." | |||
| 1329 | 1347 | ||
| 1330 | (defun tex-main-file (&optional realfile) | 1348 | (defun tex-main-file (&optional realfile) |
| 1331 | "Return the name of the main file with the `.tex' extension stripped. | 1349 | "Return the name of the main file with the `.tex' extension stripped. |
| 1332 | If REALFILE is non-nil, don't strip the extension." | 1350 | If REALFILE is non-nil, return the pair (FILE . REALFILE) where FILE |
| 1333 | (let ((file (or tex-main-file | 1351 | is the filename without the extension while REALFILE is the filename |
| 1334 | ;; Compatibility with AUCTeX. | 1352 | with extension." |
| 1335 | (and (boundp 'TeX-master) (stringp TeX-master) | 1353 | (let* ((file (or tex-main-file |
| 1336 | (set (make-local-variable 'tex-main-file) TeX-master)) | 1354 | ;; Compatibility with AUCTeX. |
| 1337 | ;; Try to guess the main file. | 1355 | (and (boundp 'TeX-master) (stringp TeX-master) |
| 1338 | (if (not buffer-file-name) | 1356 | (set (make-local-variable 'tex-main-file) TeX-master)) |
| 1339 | (error "Buffer is not associated with any file") | 1357 | ;; Try to guess the main file. |
| 1340 | (file-relative-name | 1358 | (if (not buffer-file-name) |
| 1341 | (if (save-excursion | 1359 | (error "Buffer is not associated with any file") |
| 1342 | (goto-char (point-min)) | 1360 | (file-relative-name |
| 1343 | (re-search-forward tex-start-of-header 10000 t)) | 1361 | (if (save-excursion |
| 1344 | ;; This is the main file. | 1362 | (goto-char (point-min)) |
| 1345 | buffer-file-name | 1363 | (re-search-forward tex-start-of-header 10000 t)) |
| 1346 | ;; This isn't the main file, let's try to find better, | 1364 | ;; This is the main file. |
| 1347 | (or (tex-guess-main-file) | 1365 | buffer-file-name |
| 1348 | ;; (tex-guess-main-file t) | 1366 | ;; This isn't the main file, let's try to find better, |
| 1349 | buffer-file-name))))))) | 1367 | (or (tex-guess-main-file) |
| 1350 | (cond | 1368 | ;; (tex-guess-main-file t) |
| 1351 | (realfile (if (file-exists-p file) file (concat file ".tex"))) | 1369 | buffer-file-name)))))) |
| 1352 | ((string-match "\\.tex\\'" file) (substring file 0 (match-beginning 0))) | 1370 | (real (if (file-exists-p file) file (concat file ".tex")))) |
| 1353 | (t file)))) | 1371 | (when (string-match "\\.tex\\'" file) |
| 1372 | (setq file (substring file 0 (match-beginning 0)))) | ||
| 1373 | (if realfile (cons file real) file))) | ||
| 1354 | 1374 | ||
| 1355 | 1375 | ||
| 1356 | (defun tex-start-tex (command file &optional dir) | 1376 | (defun tex-start-tex (command file &optional dir) |
| @@ -1366,18 +1386,25 @@ If REALFILE is non-nil, don't strip the extension." | |||
| 1366 | (concat | 1386 | (concat |
| 1367 | (shell-quote-argument tex-start-options-string) " ")) | 1387 | (shell-quote-argument tex-start-options-string) " ")) |
| 1368 | (comint-quote-filename file))))) | 1388 | (comint-quote-filename file))))) |
| 1369 | (when dir | 1389 | (tex-send-tex-command compile-command dir))) |
| 1370 | (let (shell-dirtrack-verbose) | 1390 | |
| 1371 | (tex-send-command tex-shell-cd-command dir))) | 1391 | (defun tex-send-tex-command (cmd &optional dir) |
| 1372 | (with-current-buffer (process-buffer (tex-send-command compile-command)) | 1392 | (unless (or (equal dir (with-current-buffer (tex-shell-buf) |
| 1373 | (save-excursion | 1393 | default-directory)) |
| 1374 | (forward-line -1) | 1394 | (not dir)) |
| 1375 | (setq tex-start-tex-marker (point-marker))) | 1395 | (let (shell-dirtrack-verbose) |
| 1376 | (make-local-variable 'compilation-parse-errors-function) | 1396 | (tex-send-command tex-shell-cd-command dir))) |
| 1377 | (setq compilation-parse-errors-function 'tex-compilation-parse-errors) | 1397 | (with-current-buffer (process-buffer (tex-send-command cmd)) |
| 1378 | (compilation-forget-errors)) | 1398 | (save-excursion |
| 1379 | (tex-display-shell) | 1399 | (forward-line -1) |
| 1380 | (setq tex-last-buffer-texed (current-buffer)))) | 1400 | (setq tex-start-tex-marker (point-marker))) |
| 1401 | (make-local-variable 'compilation-parse-errors-function) | ||
| 1402 | (setq compilation-parse-errors-function 'tex-compilation-parse-errors) | ||
| 1403 | (setq compilation-last-buffer (current-buffer)) | ||
| 1404 | (compilation-forget-errors) | ||
| 1405 | (set-marker compilation-parsing-end (1- (point-max)))) | ||
| 1406 | (tex-display-shell) | ||
| 1407 | (setq tex-last-buffer-texed (current-buffer))) | ||
| 1381 | 1408 | ||
| 1382 | (defun tex-compilation-parse-errors (limit-search find-at-least) | 1409 | (defun tex-compilation-parse-errors (limit-search find-at-least) |
| 1383 | "Parse the current buffer as TeX error messages. | 1410 | "Parse the current buffer as TeX error messages. |