Mercurial > emacs
annotate lisp/textmodes/tex-mode.el @ 54847:5acc1d864551
(update_window): Only set changed_p if
scrolling_window actually did scroll.
(scrolling_window): Only return 1 if we actually did scroll.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 13 Apr 2004 21:30:56 +0000 |
parents | 802a91a2e43a |
children | 624ac8a21b21 |
rev | line source |
---|---|
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1 ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands -*- coding: utf-8 -*- |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
54423
802a91a2e43a
(tex-shell): Set error parsing function here.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53489
diff
changeset
|
3 ;; Copyright (C) 1985,86,89,92,94,95,96,97,98,1999,2002,03,2004 |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
5 |
10215 | 6 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: tex |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
8 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
9 ;; Contributions over the years by William F. Schelter, Dick King, |
10215 | 10 ;; Stephen Gildea, Michael Prange, Jacob Gore, and Edward M. Reingold. |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
11 |
85 | 12 ;; This file is part of GNU Emacs. |
13 | |
14 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
15 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
16 ;; the Free Software Foundation; either version 2, or (at your option) |
85 | 17 ;; any later version. |
18 | |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
14383
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
27 ;; Boston, MA 02111-1307, USA. |
85 | 28 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
38083
diff
changeset
|
29 ;;; Commentary: |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
38083
diff
changeset
|
30 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
31 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
32 |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
33 ;; Pacify the byte-compiler |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
34 (eval-when-compile |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
35 (require 'compare-w) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
36 (require 'cl) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
37 (require 'skeleton)) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
38 |
6632
652dc23b83fd
(tex-start-shell): Use shell-mode-map (instead of comint-mode-map) because
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
6479
diff
changeset
|
39 (require 'shell) |
2576
48318133e7a6
(tex-compilation-parse-errors): Added. At the moment, this would have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2571
diff
changeset
|
40 (require 'compile) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
41 |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
42 (defgroup tex-file nil |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
43 "TeX files and directories" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
44 :prefix "tex-" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
45 :group 'tex) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
46 |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
47 (defgroup tex-run nil |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
48 "Running external commands from TeX mode" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
49 :prefix "tex-" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
50 :group 'tex) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
51 |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
52 (defgroup tex-view nil |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
53 "Viewing and printing TeX files" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
54 :prefix "tex-" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
55 :group 'tex) |
85 | 56 |
957 | 57 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
58 (defcustom tex-shell-file-name nil |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
59 "*If non-nil, the shell file name to run in the subshell used to run TeX." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
60 :type '(choice (const :tag "None" nil) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
61 string) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
62 :group 'tex-run) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
63 |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
64 ;;;###autoload |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
65 (defcustom tex-directory "." |
15916
61e90a3e66aa
(tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15644
diff
changeset
|
66 "*Directory in which temporary files are written. |
7285 | 67 You can make this `/tmp' if your TEXINPUTS has no relative directories in it |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
68 and you don't try to apply \\[tex-region] or \\[tex-buffer] when there are |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
69 `\\input' commands with relative directories." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
70 :type 'directory |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
71 :group 'tex-file) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
72 |
957 | 73 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
74 (defcustom tex-first-line-header-regexp nil |
16777
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
75 "Regexp for matching a first line which `tex-region' should include. |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
76 If this is non-nil, it should be a regular expression string; |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
77 if it matches the first line of the file, |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
78 `tex-region' always includes the first line in the TeX run." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
79 :type '(choice (const :tag "None" nil) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
80 regexp) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
81 :group 'tex-file) |
16777
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
82 |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
83 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
84 (defcustom tex-main-file nil |
15916
61e90a3e66aa
(tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15644
diff
changeset
|
85 "*The main TeX source file which includes this buffer's file. |
22847
31924d388b84
(tex-main-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
22707
diff
changeset
|
86 The command `tex-file' runs TeX on the file specified by `tex-main-file' |
31924d388b84
(tex-main-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
22707
diff
changeset
|
87 if the variable is non-nil." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
88 :type '(choice (const :tag "None" nil) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
89 file) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
90 :group 'tex-file) |
15916
61e90a3e66aa
(tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15644
diff
changeset
|
91 |
61e90a3e66aa
(tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15644
diff
changeset
|
92 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
93 (defcustom tex-offer-save t |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
94 "*If non-nil, ask about saving modified buffers before \\[tex-file] is run." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
95 :type 'boolean |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
96 :group 'tex-file) |
85 | 97 |
957 | 98 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
99 (defcustom tex-run-command "tex" |
85 | 100 "*Command used to run TeX subjob. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
101 TeX Mode sets `tex-command' to this string. |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
102 See the documentation of that variable." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
103 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
104 :group 'tex-run) |
85 | 105 |
957 | 106 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
107 (defcustom latex-run-command "latex" |
85 | 108 "*Command used to run LaTeX subjob. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
109 LaTeX Mode sets `tex-command' to this string. |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
110 See the documentation of that variable." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
111 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
112 :group 'tex-run) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
113 |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
114 ;;;###autoload |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
115 (defcustom slitex-run-command "slitex" |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
116 "*Command used to run SliTeX subjob. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
117 SliTeX Mode sets `tex-command' to this string. |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
118 See the documentation of that variable." |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
119 :type 'string |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
120 :group 'tex-run) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
121 |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
122 ;;;###autoload |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
123 (defcustom tex-start-options "" |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
124 "*TeX options to use when starting TeX. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
125 These immediately precede the commands in `tex-start-commands' |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
126 and the input file name, with no separating space and are not shell-quoted. |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
127 If nil, TeX runs with no options. See the documentation of `tex-command'." |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
128 :type 'string |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
129 :group 'tex-run |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
130 :version "21.4") |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
131 |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
132 ;;;###autoload |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
133 (defcustom tex-start-commands "\\nonstopmode\\input" |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
134 "*TeX commands to use when starting TeX. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
135 They are shell-quoted and precede the input file name, with a separating space. |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
136 If nil, no commands are used. See the documentation of `tex-command'." |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
137 :type '(radio (const :tag "Interactive \(nil\)" nil) |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
138 (const :tag "Nonstop \(\"\\nonstopmode\\input\"\)" |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
139 "\\nonstopmode\\input") |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
140 (string :tag "String at your choice")) |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
141 :group 'tex-run |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
142 :version "21.4") |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
143 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
144 (defvar latex-standard-block-names |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
145 '("abstract" "array" "center" "description" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
146 "displaymath" "document" "enumerate" "eqnarray" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
147 "eqnarray*" "equation" "figure" "figure*" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
148 "flushleft" "flushright" "itemize" "letter" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
149 "list" "minipage" "picture" "quotation" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
150 "quote" "slide" "sloppypar" "tabbing" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
151 "table" "table*" "tabular" "tabular*" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
152 "thebibliography" "theindex*" "titlepage" "trivlist" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
153 "verbatim" "verbatim*" "verse" "math") |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
154 "Standard LaTeX block names.") |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
155 |
957 | 156 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
157 (defcustom latex-block-names nil |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
158 "*User defined LaTeX block names. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
159 Combined with `latex-standard-block-names' for minibuffer completion." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
160 :type '(repeat string) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
161 :group 'tex-run) |
85 | 162 |
957 | 163 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
164 (defcustom tex-bibtex-command "bibtex" |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
165 "*Command used by `tex-bibtex-file' to gather bibliographic data. |
7285 | 166 If this string contains an asterisk (`*'), that is replaced by the file name; |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
167 otherwise, the file name, preceded by blank, is added at the end." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
168 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
169 :group 'tex-run) |
85 | 170 |
957 | 171 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
172 (defcustom tex-dvi-print-command "lpr -d" |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
173 "*Command used by \\[tex-print] to print a .dvi file. |
7285 | 174 If this string contains an asterisk (`*'), that is replaced by the file name; |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
175 otherwise, the file name, preceded by blank, is added at the end." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
176 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
177 :group 'tex-view) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
178 |
957 | 179 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
180 (defcustom tex-alt-dvi-print-command "lpr -d" |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
181 "*Command used by \\[tex-print] with a prefix arg to print a .dvi file. |
7285 | 182 If this string contains an asterisk (`*'), that is replaced by the file name; |
183 otherwise, the file name, preceded by blank, is added at the end. | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
184 |
7285 | 185 If two printers are not enough of a choice, you can set the variable |
186 `tex-alt-dvi-print-command' to an expression that asks what you want; | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
187 for example, |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
188 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
189 (setq tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
190 '(format \"lpr -P%s\" (read-string \"Use printer: \"))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
191 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
192 would tell \\[tex-print] with a prefix argument to ask you which printer to |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
193 use." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
194 :type '(choice (string :tag "Command") |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
195 (sexp :tag "Expression")) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
196 :group 'tex-view) |
85 | 197 |
957 | 198 ;;;###autoload |
52128
78cae600e6ef
(tex-dvi-view-command): Fix quoted quotes.
Dave Love <fx@gnu.org>
parents:
51796
diff
changeset
|
199 (defcustom tex-dvi-view-command '(if (eq window-system 'x) "xdvi" "dvi2tty * | cat -s") |
7285 | 200 "*Command used by \\[tex-view] to display a `.dvi' file. |
48170
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
201 If it is a string, that specifies the command directly. |
7285 | 202 If this string contains an asterisk (`*'), that is replaced by the file name; |
48170
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
203 otherwise, the file name, preceded by a space, is added at the end. |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
204 |
48170
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
205 If the value is a form, it is evaluated to get the command to use." |
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
206 :type '(choice (const nil) string sexp) |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
207 :group 'tex-view) |
85 | 208 |
957 | 209 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
210 (defcustom tex-show-queue-command "lpq" |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
211 "*Command used by \\[tex-show-print-queue] to show the print queue. |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
212 Should show the queue(s) that \\[tex-print] puts jobs on." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
213 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
214 :group 'tex-view) |
85 | 215 |
957 | 216 ;;;###autoload |
26270
14dbec3a82b4
(tex-default-mode): Changed to latex-mode.
Gerd Moellmann <gerd@gnu.org>
parents:
25414
diff
changeset
|
217 (defcustom tex-default-mode 'latex-mode |
85 | 218 "*Mode to enter for a new file that might be either TeX or LaTeX. |
219 This variable is used when it can't be determined whether the file | |
220 is plain TeX or LaTeX or what because the file contains no commands. | |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
221 Normally set to either `plain-tex-mode' or `latex-mode'." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
222 :type 'function |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
223 :group 'tex) |
85 | 224 |
957 | 225 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
226 (defcustom tex-open-quote "``" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
227 "*String inserted by typing \\[tex-insert-quote] to open a quotation." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
228 :type 'string |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
229 :options '("``" "\"<" "\"`" "<<" "«") |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
230 :group 'tex) |
85 | 231 |
957 | 232 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
233 (defcustom tex-close-quote "''" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
234 "*String inserted by typing \\[tex-insert-quote] to close a quotation." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
235 :type 'string |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
236 :options '("''" "\">" "\"'" ">>" "»") |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
237 :group 'tex) |
85 | 238 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
239 (defvar tex-last-temp-file nil |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
240 "Latest temporary file generated by \\[tex-region] and \\[tex-buffer]. |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
241 Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the |
7285 | 242 tex shell terminates.") |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
243 |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
244 (defvar tex-command "tex" |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
245 "*Command to run TeX. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
246 If this string contains an asterisk \(`*'\), that is replaced by the file name; |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
247 otherwise the value of `tex-start-options', the \(shell-quoted\) |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
248 value of `tex-start-commands', and the file name are added at the end |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
249 with blanks as separators. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
250 |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
251 In TeX, LaTeX, and SliTeX Mode this variable becomes buffer local. |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
252 In these modes, use \\[set-variable] if you want to change it for the |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
253 current buffer.") |
85 | 254 |
255 (defvar tex-trailer nil | |
256 "String appended after the end of a region sent to TeX by \\[tex-region].") | |
257 | |
258 (defvar tex-start-of-header nil | |
13248
a7e83f7eb499
(tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents:
12704
diff
changeset
|
259 "Regular expression used by \\[tex-region] to find start of file's header.") |
85 | 260 |
261 (defvar tex-end-of-header nil | |
13248
a7e83f7eb499
(tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents:
12704
diff
changeset
|
262 "Regular expression used by \\[tex-region] to find end of file's header.") |
85 | 263 |
264 (defvar tex-shell-cd-command "cd" | |
265 "Command to give to shell running TeX to change directory. | |
7285 | 266 The value of `tex-directory' is appended to this, separated by a space.") |
85 | 267 |
268 (defvar tex-zap-file nil | |
269 "Temporary file name used for text being sent as input to TeX. | |
270 Should be a simple file name with no extension or directory specification.") | |
271 | |
272 (defvar tex-last-buffer-texed nil | |
273 "Buffer which was last TeXed.") | |
274 | |
275 (defvar tex-print-file nil | |
276 "File name that \\[tex-print] prints. | |
277 Set by \\[tex-region], \\[tex-buffer], and \\[tex-file].") | |
278 | |
51525
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
279 (defvar tex-mode-syntax-table |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
280 (let ((st (make-syntax-table))) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
281 (modify-syntax-entry ?% "<" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
282 (modify-syntax-entry ?\n ">" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
283 (modify-syntax-entry ?\f ">" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
284 (modify-syntax-entry ?\C-@ "w" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
285 (modify-syntax-entry ?' "w" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
286 (modify-syntax-entry ?@ "_" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
287 (modify-syntax-entry ?* "_" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
288 (modify-syntax-entry ?\t " " st) |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
289 ;; ~ is printed by TeX as a space, but it's semantics in the syntax |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
290 ;; of TeX is not `whitespace' (i.e. it's just like \hspace{foo}). |
51525
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
291 (modify-syntax-entry ?~ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
292 (modify-syntax-entry ?$ "$$" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
293 (modify-syntax-entry ?\\ "/" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
294 (modify-syntax-entry ?\" "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
295 (modify-syntax-entry ?& "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
296 (modify-syntax-entry ?_ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
297 (modify-syntax-entry ?^ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
298 st) |
85 | 299 "Syntax table used while in TeX mode.") |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
300 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
301 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
302 ;;;; Imenu support |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
303 ;;;; |
85 | 304 |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
305 (defcustom latex-imenu-indent-string ". " |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
306 "*String to add repeated in front of nested sectional units for Imenu. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
307 An alternative value is \" . \", if you use a font with a narrow period." |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
308 :type 'string |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
309 :group 'tex) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
310 |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
311 (defvar latex-section-alist |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
312 '(("part" . 0) ("chapter" . 1) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
313 ("section" . 2) ("subsection" . 3) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
314 ("subsubsection" . 4) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
315 ("paragraph" . 5) ("subparagraph" . 6))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
316 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
317 (defvar latex-metasection-list |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
318 '("documentstyle" "documentclass" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
319 "begin{document}" "end{document}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
320 "appendix" "frontmatter" "mainmatter" "backmatter")) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
321 |
15240
21998d33460f
(latex-imenu-create-index):
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
322 (defun latex-imenu-create-index () |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
323 "Generate an alist for imenu from a LaTeX buffer." |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
324 (let ((section-regexp |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
325 (concat "\\\\" (regexp-opt (mapcar 'car latex-section-alist) t) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
326 "\\*?[ \t]*{")) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
327 (metasection-regexp |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
328 (concat "\\\\" (regexp-opt latex-metasection-list t))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
329 i0 menu case-fold-search) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
330 (save-excursion |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
331 ;; Find the top-most level in this file but don't allow it to be |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
332 ;; any deeper than "section" (which is top-level in an article). |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
333 (goto-char (point-min)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
334 (if (search-forward-regexp "\\\\part\\*?[ \t]*{" nil t) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
335 (setq i0 0) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
336 (if (search-forward-regexp "\\\\chapter\\*?[ \t]*{" nil t) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
337 (setq i0 1) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
338 (setq i0 2))) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
339 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
340 ;; Look for chapters and sections. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
341 (goto-char (point-min)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
342 (while (search-forward-regexp section-regexp nil t) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
343 (let ((start (match-beginning 0)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
344 (here (point)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
345 (i (cdr (assoc (buffer-substring-no-properties |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
346 (match-beginning 1) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
347 (match-end 1)) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
348 latex-section-alist)))) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
349 (backward-char 1) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
350 (condition-case err |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
351 (progn |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
352 ;; Using sexps allows some use of matching {...} inside |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
353 ;; titles. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
354 (forward-sexp 1) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
355 (push (cons (concat (apply 'concat |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
356 (make-list |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
357 (max 0 (- i i0)) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
358 latex-imenu-indent-string)) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
359 (buffer-substring-no-properties |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
360 here (1- (point)))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
361 start) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
362 menu)) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
363 (error nil)))) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
364 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
365 ;; Look for included material. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
366 (goto-char (point-min)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
367 (while (search-forward-regexp |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
368 "\\\\\\(include\\|input\\|verbatiminput\\|bibliography\\)\ |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
369 \[ \t]*{\\([^}\n]+\\)}" |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
370 nil t) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
371 (push (cons (concat "<<" (buffer-substring-no-properties |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
372 (match-beginning 2) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
373 (match-end 2)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
374 (if (= (char-after (match-beginning 1)) ?b) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
375 ".bbl" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
376 ".tex")) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
377 (match-beginning 0)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
378 menu)) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
379 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
380 ;; Look for \frontmatter, \mainmatter, \backmatter, and \appendix. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
381 (goto-char (point-min)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
382 (while (search-forward-regexp metasection-regexp nil t) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
383 (push (cons "--" (match-beginning 0)) menu)) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
384 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
385 ;; Sort in increasing buffer position order. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
386 (sort menu (function (lambda (a b) (< (cdr a) (cdr b)))))))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
387 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
388 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
389 ;;;; Outline support |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
390 ;;;; |
12704
0b36e50fb5af
(latex-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
11617
diff
changeset
|
391 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
392 (defvar latex-outline-regexp |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
393 (concat "\\\\" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
394 (regexp-opt (append latex-metasection-list |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
395 (mapcar 'car latex-section-alist)) t))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
396 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
397 (defun latex-outline-level () |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
398 (if (looking-at latex-outline-regexp) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
399 (1+ (or (cdr (assoc (match-string 1) latex-section-alist)) -1)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
400 1000)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
401 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
402 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
403 ;;;; Font-Lock support |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
404 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
405 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
406 ;(defvar tex-font-lock-keywords |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
407 ; ;; Regexps updated with help from Ulrik Dickow <dickow@nbi.dk>. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
408 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
409 ; 2 font-lock-function-name-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
410 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
411 ; 2 font-lock-constant-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
412 ; ;; It seems a bit dubious to use `bold' and `italic' faces since we might |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
413 ; ;; not be able to display those fonts. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
414 ; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
415 ; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
416 ; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
417 ; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
418 ; ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
419 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
420 ; 2 font-lock-function-name-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
421 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
422 ; 2 font-lock-constant-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
423 ; ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
424 ; "\\\\\\([a-zA-Z@]+\\|.\\)" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
425 ; ;; It seems a bit dubious to use `bold' and `italic' faces since we might |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
426 ; ;; not be able to display those fonts. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
427 ; ;; LaTeX2e: \emph{This is emphasized}. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
428 ; ("\\\\emph{\\([^}]+\\)}" 1 'italic keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
429 ; ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...} |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
430 ; ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
431 ; 3 (if (match-beginning 2) 'bold 'italic) keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
432 ; ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
433 ; ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
434 ; 3 (if (match-beginning 2) 'bold 'italic) keep)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
435 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
436 ;; Rewritten with the help of Alexandra Bac <abac@welcome.disi.unige.it>. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
437 (defconst tex-font-lock-keywords-1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
438 (eval-when-compile |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
439 (let* (;; Names of commands whose arg should be fontified as heading, etc. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
440 (headings (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
441 '("title" "begin" "end" "chapter" "part" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
442 "section" "subsection" "subsubsection" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
443 "paragraph" "subparagraph" "subsubparagraph" |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
444 "newcommand" "renewcommand" "providecommand" |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
445 "newenvironment" "renewenvironment" |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
446 "newtheorem" "renewtheorem") |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
447 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
448 (variables (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
449 '("newcounter" "newcounter*" "setcounter" "addtocounter" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
450 "setlength" "addtolength" "settowidth") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
451 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
452 (includes (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
453 '("input" "include" "includeonly" "bibliography" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
454 "epsfig" "psfig" "epsf" "nofiles" "usepackage" |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
455 "documentstyle" "documentclass" "verbatiminput" |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
456 "includegraphics" "includegraphics*") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
457 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
458 ;; Miscellany. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
459 (slash "\\\\") |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
460 (opt " *\\(\\[[^]]*\\] *\\)*") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
461 ;; This would allow highlighting \newcommand\CMD but requires |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
462 ;; adapting subgroup numbers below. |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
463 ;; (arg "\\(?:{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)\\|\\\\[a-z*]+\\)")) |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
464 (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)")) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
465 (list |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
466 ;; display $$ math $$ |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
467 ;; We only mark the match between $$ and $$ because the $$ delimiters |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
468 ;; themselves have already been marked (along with $..$) by syntactic |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
469 ;; fontification. Also this is done at the very beginning so as to |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
470 ;; interact with the other keywords in the same way as $...$ does. |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
471 (list "\\$\\$\\([^$]+\\)\\$\\$" 1 'tex-math-face) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
472 ;; Heading args. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
473 (list (concat slash headings "\\*?" opt arg) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
474 ;; If ARG ends up matching too much (if the {} don't match, f.ex) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
475 ;; jit-lock will do funny things: when updating the buffer |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
476 ;; the re-highlighting is only done locally so it will just |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
477 ;; match the local line, but defer-contextually will |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
478 ;; match more lines at a time, so ARG will end up matching |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
479 ;; a lot more, which might suddenly include a comment |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
480 ;; so you get things highlighted bold when you type them |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
481 ;; but they get turned back to normal a little while later |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
482 ;; because "there's already a face there". |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
483 ;; Using `keep' works around this un-intuitive behavior as well |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
484 ;; as improves the behavior in the very rare case where you do |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
485 ;; have a comment in ARG. |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
486 3 'font-lock-function-name-face 'keep) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
487 (list (concat slash "\\(?:provide\\|\\(?:re\\)?new\\)command\\** *\\(\\\\[A-Za-z@]+\\)") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
488 1 'font-lock-function-name-face 'keep) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
489 ;; Variable args. |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
490 (list (concat slash variables " *" arg) 2 'font-lock-variable-name-face) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
491 ;; Include args. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
492 (list (concat slash includes opt arg) 3 'font-lock-builtin-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
493 ;; Definitions. I think. |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
494 '("^[ \t]*\\\\def *\\\\\\(\\(\\w\\|@\\)+\\)" |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
495 1 font-lock-function-name-face)))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
496 "Subdued expressions to highlight in TeX modes.") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
497 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
498 (defconst tex-font-lock-keywords-2 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
499 (append tex-font-lock-keywords-1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
500 (eval-when-compile |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
501 (let* (;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
502 ;; Names of commands whose arg should be fontified with fonts. |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
503 (bold (regexp-opt '("textbf" "textsc" "textup" |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
504 "boldsymbol" "pmb") t)) |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
505 (italic (regexp-opt '("textit" "textsl" "emph") t)) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
506 ;; FIXME: unimplemented yet. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
507 ;; (type (regexp-opt '("texttt" "textmd" "textrm" "textsf") t)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
508 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
509 ;; Names of commands whose arg should be fontified as a citation. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
510 (citations (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
511 '("label" "ref" "pageref" "vref" "eqref" |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
512 "cite" "nocite" "index" "glossary" "bibitem" |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
513 ;; These are text, rather than citations. |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
514 ;; "caption" "footnote" "footnotemark" "footnotetext" |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
515 ) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
516 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
517 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
518 ;; Names of commands that should be fontified. |
43307
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
519 (specials-1 (regexp-opt '("\\" "\\*") t)) ;; "-" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
520 (specials-2 (regexp-opt |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
521 '("linebreak" "nolinebreak" "pagebreak" "nopagebreak" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
522 "newline" "newpage" "clearpage" "cleardoublepage" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
523 "displaybreak" "allowdisplaybreaks" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
524 "enlargethispage") t)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
525 (general "\\([a-zA-Z@]+\\**\\|[^ \t\n]\\)") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
526 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
527 ;; Miscellany. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
528 (slash "\\\\") |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
529 (opt " *\\(\\[[^]]*\\] *\\)*") |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
530 (args "\\(\\(?:[^{}&\\]+\\|\\\\.\\|{[^}]*}\\)+\\)") |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
531 (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)")) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
532 (list |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
533 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
534 ;; Citation args. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
535 (list (concat slash citations opt arg) 3 'font-lock-constant-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
536 ;; |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
537 ;; Text between `` quotes ''. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
538 (cons (concat (regexp-opt `("``" "\"<" "\"`" "<<" "«") t) |
46120
7177a47bc557
(tex-file): call `save-some-buffers' before `tex-main-file'
Sam Steingold <sds@gnu.org>
parents:
45055
diff
changeset
|
539 "[^'\">{]+" ;a bit pessimistic |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
540 (regexp-opt `("''" "\">" "\"'" ">>" "»") t)) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
541 'font-lock-string-face) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
542 ;; |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
543 ;; Command names, special and general. |
43307
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
544 (cons (concat slash specials-1) 'font-lock-warning-face) |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
545 (list (concat "\\(" slash specials-2 "\\)\\([^a-zA-Z@]\\|\\'\\)") |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
546 1 'font-lock-warning-face) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
547 (concat slash general) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
548 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
549 ;; Font environments. It seems a bit dubious to use `bold' etc. faces |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
550 ;; since we might not be able to display those fonts. |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
551 (list (concat slash bold " *" arg) 2 '(quote bold) 'append) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
552 (list (concat slash italic " *" arg) 2 '(quote italic) 'append) |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
553 ;; (list (concat slash type arg) 2 '(quote bold-italic) 'append) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
554 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
555 ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for tables. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
556 (list (concat "\\\\\\(em\\|it\\|sl\\)\\>" args) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
557 2 '(quote italic) 'append) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
558 ;; This is separate from the previous one because of cases like |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
559 ;; {\em foo {\bf bar} bla} where both match. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
560 (list (concat "\\\\bf\\>" args) 1 '(quote bold) 'append))))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
561 "Gaudy expressions to highlight in TeX modes.") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
562 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
563 (defun tex-font-lock-suscript (pos) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
564 (unless (or (memq (get-text-property pos 'face) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
565 '(font-lock-constant-face font-lock-builtin-face |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
566 font-lock-comment-face tex-verbatim-face)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
567 ;; Check for backslash quoting |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
568 (let ((odd nil) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
569 (pos pos)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
570 (while (eq (char-before pos) ?\\) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
571 (setq pos (1- pos) odd (not odd))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
572 odd)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
573 (if (eq (char-after pos) ?_) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
574 '(face subscript display (raise -0.3)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
575 '(face superscript display (raise +0.3))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
576 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
577 (defconst tex-font-lock-keywords-3 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
578 (append tex-font-lock-keywords-2 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
579 (eval-when-compile |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
580 (let ((general "\\([a-zA-Z@]+\\|[^ \t\n]\\)") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
581 (slash "\\\\") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
582 ;; This is not the same regexp as before: it has a `+' removed. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
583 ;; The + makes the matching faster in the above cases (where we can |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
584 ;; exit as soon as the match fails) but would make this matching |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
585 ;; degenerate to nasty complexity (because we try to match the |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
586 ;; closing brace, which forces trying all matching combinations). |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
587 (arg "{\\(?:[^{}\\]\\|\\\\.\\|{[^}]*}\\)*")) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
588 `((,(concat "[_^] *\\([^\n\\{}]\\|" slash general "\\|" arg "}\\)") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
589 (1 (tex-font-lock-suscript (match-beginning 0)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
590 append)))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
591 "Experimental expressions to highlight in TeX modes.") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
592 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
593 (defvar tex-font-lock-keywords tex-font-lock-keywords-1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
594 "Default expressions to highlight in TeX modes.") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
595 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
596 (defvar tex-verbatim-environments |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
597 '("verbatim" "verbatim*")) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
598 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
599 (defvar tex-font-lock-syntactic-keywords |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
600 (let ((verbs (regexp-opt tex-verbatim-environments t))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
601 `((,(concat "^\\\\begin *{" verbs "}.*\\(\n\\)") 2 "|") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
602 (,(concat "^\\\\end *{" verbs "}\\(.?\\)") 2 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
603 (unless (<= (match-beginning 0) (point-min)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
604 (put-text-property (1- (match-beginning 0)) (match-beginning 0) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
605 'syntax-table (string-to-syntax "|")) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
606 "<")) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
607 ;; ("^\\(\\\\\\)begin *{comment}" 1 "< b") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
608 ;; ("^\\\\end *{comment}.*\\(\n\\)" 1 "> b") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
609 ("\\\\verb\\**\\([^a-z@*]\\)" 1 "\"")))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
610 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
611 (defun tex-font-lock-unfontify-region (beg end) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
612 (font-lock-default-unfontify-region beg end) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
613 (while (< beg end) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
614 (let ((next (next-single-property-change beg 'display nil end)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
615 (prop (get-text-property beg 'display))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
616 (if (and (eq (car-safe prop) 'raise) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
617 (member (car-safe (cdr prop)) '(-0.3 +0.3)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
618 (null (cddr prop))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
619 (put-text-property beg next 'display nil)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
620 (setq beg next)))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
621 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
622 (defface superscript |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
623 '((t :height 0.8)) ;; :raise 0.3 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
624 "Face used for superscripts.") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
625 (defface subscript |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
626 '((t :height 0.8)) ;; :raise -0.3 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
627 "Face used for subscripts.") |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
628 |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
629 (defface tex-math-face |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
630 '((t :inherit font-lock-string-face)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
631 "Face used to highlight TeX math expressions.") |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
632 (defvar tex-math-face 'tex-math-face) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
633 (defface tex-verbatim-face |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
634 ;; '((t :inherit font-lock-string-face)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
635 '((t :family "courier")) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
636 "Face used to highlight TeX verbatim environments.") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
637 (defvar tex-verbatim-face 'tex-verbatim-face) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
638 |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
639 ;; Use string syntax but math face for $...$. |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
640 (defun tex-font-lock-syntactic-face-function (state) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
641 (let ((char (nth 3 state))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
642 (cond |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
643 ((not char) font-lock-comment-face) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
644 ((eq char ?$) tex-math-face) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
645 (t |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
646 (when (char-valid-p char) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
647 ;; This is a \verb?...? construct. Let's find the end and mark it. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
648 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
649 (skip-chars-forward (string ?^ char)) ;; Use `end' ? |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
650 (when (eq (char-syntax (preceding-char)) ?/) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
651 (put-text-property (1- (point)) (point) 'syntax-table '(1))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
652 (unless (eobp) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
653 (put-text-property (point) (1+ (point)) 'syntax-table '(7))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
654 tex-verbatim-face)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
655 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
656 |
85 | 657 (defun tex-define-common-keys (keymap) |
7285 | 658 "Define the keys that we want defined both in TeX mode and in the TeX shell." |
85 | 659 (define-key keymap "\C-c\C-k" 'tex-kill-job) |
660 (define-key keymap "\C-c\C-l" 'tex-recenter-output-buffer) | |
661 (define-key keymap "\C-c\C-q" 'tex-show-print-queue) | |
662 (define-key keymap "\C-c\C-p" 'tex-print) | |
663 (define-key keymap "\C-c\C-v" 'tex-view) | |
4900
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
664 |
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
665 (define-key keymap [menu-bar tex] (cons "TeX" (make-sparse-keymap "TeX"))) |
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
666 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
667 (define-key keymap [menu-bar tex tex-kill-job] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
668 '(menu-item "Tex Kill" tex-kill-job :enable (tex-shell-running))) |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
669 (define-key keymap [menu-bar tex tex-recenter-output-buffer] |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
670 '(menu-item "Tex Recenter" tex-recenter-output-buffer |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
671 :enable (get-buffer "*tex-shell*"))) |
4900
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
672 (define-key keymap [menu-bar tex tex-show-print-queue] |
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
673 '("Show Print Queue" . tex-show-print-queue)) |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
674 (define-key keymap [menu-bar tex tex-alt-print] |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
675 '(menu-item "Tex Print (alt printer)" tex-alt-print |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
676 :enable (stringp tex-print-file))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
677 (define-key keymap [menu-bar tex tex-print] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
678 '(menu-item "Tex Print" tex-print :enable (stringp tex-print-file))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
679 (define-key keymap [menu-bar tex tex-view] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
680 '(menu-item "Tex View" tex-view :enable (stringp tex-print-file)))) |
85 | 681 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
682 (defvar tex-mode-map |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
683 (let ((map (make-sparse-keymap))) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
684 (set-keymap-parent map text-mode-map) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
685 (tex-define-common-keys map) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
686 (define-key map "\"" 'tex-insert-quote) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
687 (define-key map "(" 'skeleton-pair-insert-maybe) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
688 (define-key map "{" 'skeleton-pair-insert-maybe) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
689 (define-key map "[" 'skeleton-pair-insert-maybe) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
690 (define-key map "$" 'skeleton-pair-insert-maybe) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
691 (define-key map "\n" 'tex-terminate-paragraph) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
692 (define-key map "\M-\r" 'latex-insert-item) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
693 (define-key map "\C-c}" 'up-list) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
694 (define-key map "\C-c{" 'tex-insert-braces) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
695 (define-key map "\C-c\C-r" 'tex-region) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
696 (define-key map "\C-c\C-b" 'tex-buffer) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
697 (define-key map "\C-c\C-f" 'tex-file) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
698 (define-key map "\C-c\C-c" 'tex-compile) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
699 (define-key map "\C-c\C-i" 'tex-bibtex-file) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
700 (define-key map "\C-c\C-o" 'latex-insert-block) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
701 (define-key map "\C-c\C-e" 'latex-close-block) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
702 (define-key map "\C-c\C-u" 'tex-goto-last-unclosed-latex-block) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
703 (define-key map "\C-c\C-m" 'tex-feed-input) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
704 (define-key map [(control return)] 'tex-feed-input) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
705 (define-key map [menu-bar tex tex-bibtex-file] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
706 '("BibTeX File" . tex-bibtex-file)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
707 (define-key map [menu-bar tex tex-validate-region] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
708 '(menu-item "Validate Region" tex-validate-region :enable mark-active)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
709 (define-key map [menu-bar tex tex-validate-buffer] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
710 '("Validate Buffer" . tex-validate-buffer)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
711 (define-key map [menu-bar tex tex-region] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
712 '(menu-item "TeX Region" tex-region :enable mark-active)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
713 (define-key map [menu-bar tex tex-buffer] |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
714 '("TeX Buffer" . tex-buffer)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
715 (define-key map [menu-bar tex tex-file] '("TeX File" . tex-file)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
716 map) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
717 "Keymap shared by TeX modes.") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
718 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
719 (defvar latex-mode-map |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
720 (let ((map (make-sparse-keymap))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
721 (set-keymap-parent map tex-mode-map) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
722 (define-key map "\C-c\C-s" 'latex-split-block) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
723 map) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
724 "Keymap for `latex-mode'. See also `tex-mode-map'.") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
725 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
726 (defvar plain-tex-mode-map |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
727 (let ((map (make-sparse-keymap))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
728 (set-keymap-parent map tex-mode-map) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
729 map) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
730 "Keymap for `plain-tex-mode'. See also `tex-mode-map'.") |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
731 |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
732 (defvar tex-shell-map |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
733 (let ((m (make-sparse-keymap))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
734 (set-keymap-parent m shell-mode-map) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
735 (tex-define-common-keys m) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
736 m) |
7285 | 737 "Keymap for the TeX shell. |
10197
66681eddfd70
Make keymap for tex-shell the shell-mode-map.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
10190
diff
changeset
|
738 Inherits `shell-mode-map' with a few additions.") |
85 | 739 |
14383
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
740 (defvar tex-face-alist |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
741 '((bold . "{\\bf ") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
742 (italic . "{\\it ") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
743 (bold-italic . "{\\bi ") ; hypothetical |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
744 (underline . "\\underline{") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
745 (default . "{\\rm ")) |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
746 "Alist of face and TeX font name for facemenu.") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
747 |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
748 (defvar tex-latex-face-alist |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
749 `((italic . "{\\em ") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
750 ,@tex-face-alist) |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
751 "Alist of face and LaTeX font name for facemenu.") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
752 |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
753 ;; This would be a lot simpler if we just used a regexp search, |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
754 ;; but then it would be too slow. |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
755 (defun tex-guess-mode () |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
756 (let ((mode tex-default-mode) slash comment) |
85 | 757 (save-excursion |
758 (goto-char (point-min)) | |
759 (while (and (setq slash (search-forward "\\" nil t)) | |
760 (setq comment (let ((search-end (point))) | |
761 (save-excursion | |
762 (beginning-of-line) | |
763 (search-forward "%" search-end t)))))) | |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
764 (when (and slash (not comment)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
765 (setq mode |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
766 (if (looking-at |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
767 (eval-when-compile |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
768 (concat |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
769 (regexp-opt '("documentstyle" "documentclass" |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
770 "begin" "subsection" "section" |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
771 "part" "chapter" "newcommand" |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
772 "renewcommand") 'words) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
773 "\\|NeedsTeXFormat{LaTeX"))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
774 (if (looking-at |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
775 "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
776 'slitex-mode |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
777 'latex-mode) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
778 'plain-tex-mode)))) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
779 (funcall mode))) |
2598
2189edb30955
Removed spurious comment (obsoleted by ;;;###autoload).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2588
diff
changeset
|
780 |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
781 ;; `tex-mode' plays two roles: it's the parent of several sub-modes |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
782 ;; but it's also the function that chooses between those submodes. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
783 ;; To tell the difference between those two cases where the function |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
784 ;; might be called, we check `delay-mode-hooks'. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
785 (define-derived-mode tex-mode text-mode "generic-TeX" |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
786 (tex-common-initialization)) |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
787 ;; We now move the function and define it again. This gives a warning |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
788 ;; in the byte-compiler :-( but it's difficult to avoid because |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
789 ;; `define-derived-mode' will necessarily define the function once |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
790 ;; and we need to define it a second time for `autoload' to get the |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
791 ;; proper docstring. |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
792 (defalias 'tex-mode-internal (symbol-function 'tex-mode)) |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
793 ;;;###autoload |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
794 (defun tex-mode () |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
795 "Major mode for editing files of input for TeX, LaTeX, or SliTeX. |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
796 Tries to determine (by looking at the beginning of the file) whether |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
797 this file is for plain TeX, LaTeX, or SliTeX and calls `plain-tex-mode', |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
798 `latex-mode', or `slitex-mode', respectively. If it cannot be determined, |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
799 such as if there are no commands in the file, the value of `tex-default-mode' |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
800 says which mode to use." |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
801 (interactive) |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
802 (if delay-mode-hooks |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
803 ;; We're called from one of the children already. |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
804 (tex-mode-internal) |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
805 (tex-guess-mode))) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
806 |
269 | 807 ;;;###autoload |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
808 (defalias 'TeX-mode 'tex-mode) |
269 | 809 ;;;###autoload |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
810 (defalias 'plain-TeX-mode 'plain-tex-mode) |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
811 ;;;###autoload |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
812 (defalias 'LaTeX-mode 'latex-mode) |
85 | 813 |
256 | 814 ;;;###autoload |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
815 (define-derived-mode plain-tex-mode tex-mode "TeX" |
85 | 816 "Major mode for editing files of input for plain TeX. |
817 Makes $ and } display the characters they match. | |
818 Makes \" insert `` when it seems to be the beginning of a quotation, | |
819 and '' when it appears to be the end; it inserts \" only after a \\. | |
820 | |
821 Use \\[tex-region] to run TeX on the current region, plus a \"header\" | |
822 copied from the top of the file (containing macro definitions, etc.), | |
823 running TeX under a special subshell. \\[tex-buffer] does the whole buffer. | |
824 \\[tex-file] saves the buffer and then processes the file. | |
825 \\[tex-print] prints the .dvi file made by any of these. | |
826 \\[tex-view] previews the .dvi file made by any of these. | |
827 \\[tex-bibtex-file] runs bibtex on the file of the current buffer. | |
828 | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
829 Use \\[tex-validate-buffer] to check buffer for paragraphs containing |
85 | 830 mismatched $'s or braces. |
831 | |
832 Special commands: | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
833 \\{plain-tex-mode-map} |
85 | 834 |
835 Mode variables: | |
836 tex-run-command | |
837 Command string used by \\[tex-region] or \\[tex-buffer]. | |
838 tex-directory | |
839 Directory in which to create temporary files for TeX jobs | |
840 run by \\[tex-region] or \\[tex-buffer]. | |
841 tex-dvi-print-command | |
842 Command string used by \\[tex-print] to print a .dvi file. | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
843 tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
844 Alternative command string used by \\[tex-print] (when given a prefix |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
845 argument) to print a .dvi file. |
85 | 846 tex-dvi-view-command |
847 Command string used by \\[tex-view] to preview a .dvi file. | |
848 tex-show-queue-command | |
849 Command string used by \\[tex-show-print-queue] to show the print | |
850 queue that \\[tex-print] put your job on. | |
851 | |
7285 | 852 Entering Plain-tex mode runs the hook `text-mode-hook', then the hook |
853 `tex-mode-hook', and finally the hook `plain-tex-mode-hook'. When the | |
854 special subshell is initiated, the hook `tex-shell-hook' is run." | |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
855 (set (make-local-variable 'tex-command) tex-run-command) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
856 (set (make-local-variable 'tex-start-of-header) "%\\*\\*start of header") |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
857 (set (make-local-variable 'tex-end-of-header) "%\\*\\*end of header") |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
858 (set (make-local-variable 'tex-trailer) "\\bye\n")) |
85 | 859 |
256 | 860 ;;;###autoload |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
861 (define-derived-mode latex-mode tex-mode "LaTeX" |
85 | 862 "Major mode for editing files of input for LaTeX. |
863 Makes $ and } display the characters they match. | |
864 Makes \" insert `` when it seems to be the beginning of a quotation, | |
865 and '' when it appears to be the end; it inserts \" only after a \\. | |
866 | |
867 Use \\[tex-region] to run LaTeX on the current region, plus the preamble | |
868 copied from the top of the file (containing \\documentstyle, etc.), | |
869 running LaTeX under a special subshell. \\[tex-buffer] does the whole buffer. | |
870 \\[tex-file] saves the buffer and then processes the file. | |
871 \\[tex-print] prints the .dvi file made by any of these. | |
872 \\[tex-view] previews the .dvi file made by any of these. | |
873 \\[tex-bibtex-file] runs bibtex on the file of the current buffer. | |
874 | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
875 Use \\[tex-validate-buffer] to check buffer for paragraphs containing |
85 | 876 mismatched $'s or braces. |
877 | |
878 Special commands: | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
879 \\{latex-mode-map} |
85 | 880 |
881 Mode variables: | |
882 latex-run-command | |
883 Command string used by \\[tex-region] or \\[tex-buffer]. | |
884 tex-directory | |
885 Directory in which to create temporary files for LaTeX jobs | |
886 run by \\[tex-region] or \\[tex-buffer]. | |
887 tex-dvi-print-command | |
888 Command string used by \\[tex-print] to print a .dvi file. | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
889 tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
890 Alternative command string used by \\[tex-print] (when given a prefix |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
891 argument) to print a .dvi file. |
85 | 892 tex-dvi-view-command |
893 Command string used by \\[tex-view] to preview a .dvi file. | |
894 tex-show-queue-command | |
895 Command string used by \\[tex-show-print-queue] to show the print | |
896 queue that \\[tex-print] put your job on. | |
897 | |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
898 Entering Latex mode runs the hook `text-mode-hook', then |
7285 | 899 `tex-mode-hook', and finally `latex-mode-hook'. When the special |
900 subshell is initiated, `tex-shell-hook' is run." | |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
901 (set (make-local-variable 'tex-command) latex-run-command) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
902 (set (make-local-variable 'tex-start-of-header) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
903 "\\\\document\\(style\\|class\\)") |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
904 (set (make-local-variable 'tex-end-of-header) "\\\\begin\\s-*{document}") |
53185
85f57f9a360f
(latex-mode): `tex-trailer' is not a regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52957
diff
changeset
|
905 (set (make-local-variable 'tex-trailer) "\\end{document}\n") |
5425
3dd5ff54e1cd
(slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents:
5262
diff
changeset
|
906 ;; A line containing just $$ is treated as a paragraph separator. |
3dd5ff54e1cd
(slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents:
5262
diff
changeset
|
907 ;; A line starting with $$ starts a paragraph, |
3dd5ff54e1cd
(slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents:
5262
diff
changeset
|
908 ;; but does not separate paragraphs if it has more stuff on it. |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
909 (setq paragraph-start |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
910 (concat "[ \t]*\\(\\$\\$\\|" |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
911 "\\\\[][]\\|" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
912 "\\\\" (regexp-opt (append |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
913 (mapcar 'car latex-section-alist) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
914 '("begin" "label" "end" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
915 "item" "bibitem" "newline" "noindent" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
916 "newpage" "footnote" "marginpar" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
917 "parbox" "caption")) t) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
918 "\\>\\|\\\\[a-z]*" (regexp-opt '("space" "skip" "page") t) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
919 "\\>\\)")) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
920 (setq paragraph-separate |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
921 (concat "[\f%]\\|[ \t]*\\($\\|" |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
922 "\\\\[][]\\|" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
923 "\\\\" (regexp-opt (append |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
924 (mapcar 'car latex-section-alist) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
925 '("begin" "label" "end" )) t) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
926 "\\>\\|\\\\\\(" (regexp-opt '("item" "bibitem" "newline" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
927 "noindent" "newpage" "footnote" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
928 "marginpar" "parbox" "caption")) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
929 "\\|\\$\\$\\|[a-z]*\\(space\\|skip\\|page[a-z]*\\)" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
930 "\\>\\)[ \t]*\\($\\|%\\)\\)")) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
931 (set (make-local-variable 'imenu-create-index-function) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
932 'latex-imenu-create-index) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
933 (set (make-local-variable 'tex-face-alist) tex-latex-face-alist) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
934 (add-hook 'fill-nobreak-predicate 'latex-fill-nobreak-predicate nil t) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
935 (set (make-local-variable 'indent-line-function) 'latex-indent) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
936 (set (make-local-variable 'fill-indent-according-to-mode) t) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
937 (set (make-local-variable 'outline-regexp) latex-outline-regexp) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
938 (set (make-local-variable 'outline-level) 'latex-outline-level) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
939 (set (make-local-variable 'forward-sexp-function) 'latex-forward-sexp) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
940 (set (make-local-variable 'skeleton-end-hook) nil)) |
85 | 941 |
4768
9d84105b1248
(slitex-mode): Add ###autoload magic cookie.
Brian Fox <bfox@gnu.org>
parents:
4376
diff
changeset
|
942 ;;;###autoload |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
943 (define-derived-mode slitex-mode latex-mode "SliTeX" |
85 | 944 "Major mode for editing files of input for SliTeX. |
945 Makes $ and } display the characters they match. | |
946 Makes \" insert `` when it seems to be the beginning of a quotation, | |
947 and '' when it appears to be the end; it inserts \" only after a \\. | |
948 | |
949 Use \\[tex-region] to run SliTeX on the current region, plus the preamble | |
950 copied from the top of the file (containing \\documentstyle, etc.), | |
951 running SliTeX under a special subshell. \\[tex-buffer] does the whole buffer. | |
952 \\[tex-file] saves the buffer and then processes the file. | |
953 \\[tex-print] prints the .dvi file made by any of these. | |
954 \\[tex-view] previews the .dvi file made by any of these. | |
955 \\[tex-bibtex-file] runs bibtex on the file of the current buffer. | |
956 | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
957 Use \\[tex-validate-buffer] to check buffer for paragraphs containing |
85 | 958 mismatched $'s or braces. |
959 | |
960 Special commands: | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
961 \\{slitex-mode-map} |
85 | 962 |
963 Mode variables: | |
964 slitex-run-command | |
965 Command string used by \\[tex-region] or \\[tex-buffer]. | |
966 tex-directory | |
967 Directory in which to create temporary files for SliTeX jobs | |
968 run by \\[tex-region] or \\[tex-buffer]. | |
969 tex-dvi-print-command | |
970 Command string used by \\[tex-print] to print a .dvi file. | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
971 tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
972 Alternative command string used by \\[tex-print] (when given a prefix |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
973 argument) to print a .dvi file. |
85 | 974 tex-dvi-view-command |
975 Command string used by \\[tex-view] to preview a .dvi file. | |
976 tex-show-queue-command | |
977 Command string used by \\[tex-show-print-queue] to show the print | |
978 queue that \\[tex-print] put your job on. | |
979 | |
7285 | 980 Entering SliTeX mode runs the hook `text-mode-hook', then the hook |
981 `tex-mode-hook', then the hook `latex-mode-hook', and finally the hook | |
982 `slitex-mode-hook'. When the special subshell is initiated, the hook | |
983 `tex-shell-hook' is run." | |
85 | 984 (setq tex-command slitex-run-command) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
985 (setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}")) |
85 | 986 |
987 (defun tex-common-initialization () | |
18587
3290767e31d8
(tex-common-initialization):
Richard M. Stallman <rms@gnu.org>
parents:
18393
diff
changeset
|
988 ;; Regexp isearch should accept newline and formfeed as whitespace. |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
989 (set (make-local-variable 'search-whitespace-regexp) "[ \t\r\n\f]+") |
5262
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
990 ;; A line containing just $$ is treated as a paragraph separator. |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
991 (set (make-local-variable 'paragraph-start) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
992 "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") |
5425
3dd5ff54e1cd
(slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents:
5262
diff
changeset
|
993 ;; A line starting with $$ starts a paragraph, |
3dd5ff54e1cd
(slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents:
5262
diff
changeset
|
994 ;; but does not separate paragraphs if it has more stuff on it. |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
995 (set (make-local-variable 'paragraph-separate) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
996 "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
997 (set (make-local-variable 'comment-start) "%") |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
998 (set (make-local-variable 'comment-add) 1) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
999 (set (make-local-variable 'comment-start-skip) |
48120
16ca3f0efd84
(tex-common-initialization): comment-start-skip shouldn't match on next line.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46367
diff
changeset
|
1000 "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+ *\\)") |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1001 (set (make-local-variable 'parse-sexp-ignore-comments) t) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1002 (set (make-local-variable 'compare-windows-whitespace) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1003 'tex-categorize-whitespace) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1004 (set (make-local-variable 'facemenu-add-face-function) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1005 (lambda (face end) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1006 (let ((face-text (cdr (assq face tex-face-alist)))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1007 (if face-text |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1008 face-text |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1009 (error "Face %s not configured for %s mode" face mode-name))))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1010 (set (make-local-variable 'facemenu-end-add-face) "}") |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1011 (set (make-local-variable 'facemenu-remove-face-function) t) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1012 (set (make-local-variable 'font-lock-defaults) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1013 '((tex-font-lock-keywords tex-font-lock-keywords-1 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1014 tex-font-lock-keywords-2 tex-font-lock-keywords-3) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1015 nil nil ((?$ . "\"")) nil |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1016 ;; Who ever uses that anyway ??? |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1017 (font-lock-mark-block-function . mark-paragraph) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1018 (font-lock-syntactic-face-function |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1019 . tex-font-lock-syntactic-face-function) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1020 (font-lock-unfontify-region-function |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1021 . tex-font-lock-unfontify-region) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1022 (font-lock-syntactic-keywords |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1023 . tex-font-lock-syntactic-keywords) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1024 (parse-sexp-lookup-properties . t))) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1025 ;; TABs in verbatim environments don't do what you think. |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1026 (set (make-local-variable 'indent-tabs-mode) nil) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1027 ;; Other vars that should be buffer-local. |
85 | 1028 (make-local-variable 'tex-command) |
1029 (make-local-variable 'tex-start-of-header) | |
1030 (make-local-variable 'tex-end-of-header) | |
1031 (make-local-variable 'tex-trailer)) | |
1032 | |
1033 (defun tex-categorize-whitespace (backward-limit) | |
1034 ;; compare-windows-whitespace is set to this. | |
1035 ;; This is basically a finite-state machine. | |
1036 ;; Returns a symbol telling how TeX would treat | |
1037 ;; the whitespace we are looking at: null, space, or par. | |
1038 (let ((category 'null) | |
1039 (not-finished t)) | |
1040 (skip-chars-backward " \t\n\f" backward-limit) | |
1041 (while not-finished | |
1042 (cond ((looking-at "[ \t]+") | |
1043 (goto-char (match-end 0)) | |
18931
43b52e6a35c2
(tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents:
18587
diff
changeset
|
1044 (if (eq category 'null) |
85 | 1045 (setq category 'space))) |
1046 ((looking-at "\n") | |
18931
43b52e6a35c2
(tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents:
18587
diff
changeset
|
1047 (cond ((eq category 'newline) |
85 | 1048 (setq category 'par) |
1049 (setq not-finished nil)) | |
1050 (t | |
1051 (setq category 'newline) ;a strictly internal state | |
1052 (goto-char (match-end 0))))) | |
1053 ((looking-at "\f+") | |
1054 (setq category 'par) | |
1055 (setq not-finished nil)) | |
1056 (t | |
1057 (setq not-finished nil)))) | |
1058 (skip-chars-forward " \t\n\f") | |
18931
43b52e6a35c2
(tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents:
18587
diff
changeset
|
1059 (if (eq category 'newline) |
85 | 1060 'space ;TeX doesn't distinguish |
1061 category))) | |
1062 | |
1063 (defun tex-insert-quote (arg) | |
1064 "Insert the appropriate quote marks for TeX. | |
2836
d95acb2243f9
(tex-insert-quote): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2598
diff
changeset
|
1065 Inserts the value of `tex-open-quote' (normally ``) or `tex-close-quote' |
d95acb2243f9
(tex-insert-quote): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2598
diff
changeset
|
1066 \(normally '') depending on the context. With prefix argument, always |
85 | 1067 inserts \" characters." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1068 (interactive "*P") |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1069 (if (or arg (memq (char-syntax (preceding-char)) '(?/ ?\\)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1070 (eq (get-text-property (point) 'face) 'tex-verbatim-face) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1071 (save-excursion |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1072 (backward-char (length tex-open-quote)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1073 (when (or (looking-at (regexp-quote tex-open-quote)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1074 (looking-at (regexp-quote tex-close-quote))) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1075 (delete-char (length tex-open-quote)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1076 t))) |
85 | 1077 (self-insert-command (prefix-numeric-value arg)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1078 (insert (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1079 tex-open-quote tex-close-quote)))) |
85 | 1080 |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1081 (defun tex-validate-buffer () |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1082 "Check current buffer for paragraphs containing mismatched braces or $s. |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1083 Their positions are recorded in the buffer `*Occur*'. |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1084 To find a particular invalidity from `*Occur*', switch to that buffer |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1085 and type C-c C-c or click with mouse-2 |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1086 on the line for the invalidity you want to see." |
85 | 1087 (interactive) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1088 (let ((buffer (current-buffer)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1089 (prevpos (point-min)) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1090 (linenum nil) |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1091 (num-matches 0)) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1092 (with-output-to-temp-buffer "*Occur*" |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1093 (princ "Mismatches:\n") |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
1094 (with-current-buffer standard-output |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1095 (occur-mode) |
45055
b9c9078b245d
(tex-validate-buffer): Use `occur-revert-arguments' instead of setting
Colin Walters <walters@gnu.org>
parents:
44884
diff
changeset
|
1096 ;; This won't actually work...Really, this whole thing should |
b9c9078b245d
(tex-validate-buffer): Use `occur-revert-arguments' instead of setting
Colin Walters <walters@gnu.org>
parents:
44884
diff
changeset
|
1097 ;; be rewritten instead of being a hack on top of occur. |
b9c9078b245d
(tex-validate-buffer): Use `occur-revert-arguments' instead of setting
Colin Walters <walters@gnu.org>
parents:
44884
diff
changeset
|
1098 (setq occur-revert-arguments (list nil 0 (list buffer)))) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1099 (save-excursion |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1100 (goto-char (point-max)) |
45055
b9c9078b245d
(tex-validate-buffer): Use `occur-revert-arguments' instead of setting
Colin Walters <walters@gnu.org>
parents:
44884
diff
changeset
|
1101 (while (and (not (bobp))) |
15644
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1102 (let ((end (point)) |
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1103 prev-end) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1104 ;; Scan the previous paragraph for invalidities. |
15644
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1105 (if (search-backward "\n\n" nil t) |
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1106 (progn |
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1107 (setq prev-end (point)) |
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1108 (forward-char 2)) |
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1109 (goto-char (setq prev-end (point-min)))) |
85 | 1110 (or (tex-validate-region (point) end) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
1111 (let* ((end (line-beginning-position 2)) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1112 start tem) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1113 (beginning-of-line) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1114 (setq start (point)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1115 ;; Keep track of line number as we scan, |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1116 ;; in a cumulative fashion. |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1117 (if linenum |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1118 (setq linenum (- linenum (count-lines prevpos (point)))) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1119 (setq linenum (1+ (count-lines 1 start)))) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1120 (setq prevpos (point)) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1121 ;; Mention this mismatch in *Occur*. |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1122 ;; Since we scan from end of buffer to beginning, |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1123 ;; add each mismatch at the beginning of *Occur*. |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1124 (save-excursion |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1125 (setq tem (point-marker)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1126 (set-buffer standard-output) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1127 (goto-char (point-min)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1128 ;; Skip "Mismatches:" header line. |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1129 (forward-line 1) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1130 (setq num-matches (1+ num-matches)) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1131 (insert-buffer-substring buffer start end) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1132 (let (text-beg (text-end (point-marker))) |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1133 (forward-char (- start end)) |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1134 (setq text-beg (point-marker)) |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1135 (insert (format "%3d: " linenum)) |
38083
745b05b3e5ed
(tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents:
37952
diff
changeset
|
1136 (add-text-properties |
745b05b3e5ed
(tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents:
37952
diff
changeset
|
1137 text-beg (- text-end 1) |
745b05b3e5ed
(tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents:
37952
diff
changeset
|
1138 '(mouse-face highlight |
745b05b3e5ed
(tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents:
37952
diff
changeset
|
1139 help-echo "mouse-2: go to this invalidity")) |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1140 (put-text-property text-beg (- text-end 1) |
45055
b9c9078b245d
(tex-validate-buffer): Use `occur-revert-arguments' instead of setting
Colin Walters <walters@gnu.org>
parents:
44884
diff
changeset
|
1141 'occur-target tem))))) |
15644
3b4678aa4e9f
(tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents:
15513
diff
changeset
|
1142 (goto-char prev-end)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1143 (with-current-buffer standard-output |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1144 (if (eq num-matches 0) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1145 (insert "None!\n")) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1146 (if (interactive-p) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1147 (message "%d mismatches found" num-matches)))))) |
85 | 1148 |
1149 (defun tex-validate-region (start end) | |
1150 "Check for mismatched braces or $'s in region. | |
1151 Returns t if no mismatches. Returns nil and moves point to suspect | |
1152 area if a mismatch is found." | |
1153 (interactive "r") | |
1154 (let ((failure-point nil) (max-possible-sexps (- end start))) | |
1155 (save-excursion | |
1156 (condition-case () | |
1157 (save-restriction | |
1158 (narrow-to-region start end) | |
20203
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1159 ;; First check that the open and close parens balance in numbers. |
85 | 1160 (goto-char start) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1161 (while (<= 0 (setq max-possible-sexps (1- max-possible-sexps))) |
20203
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1162 (forward-sexp 1)) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1163 ;; Now check that like matches like. |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1164 (goto-char start) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1165 (while (progn (skip-syntax-forward "^(") |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1166 (not (eobp))) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1167 (let ((match (matching-paren (following-char)))) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1168 (save-excursion |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1169 (forward-sexp 1) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1170 (or (= (preceding-char) match) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1171 (error "Mismatched parentheses")))) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1172 (forward-char 1))) |
85 | 1173 (error |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1174 (skip-syntax-forward " .>") |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1175 (setq failure-point (point))))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1176 (if failure-point (goto-char failure-point)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1177 (not failure-point))) |
85 | 1178 |
1179 (defun tex-terminate-paragraph (inhibit-validation) | |
1180 "Insert two newlines, breaking a paragraph for TeX. | |
7285 | 1181 Check for mismatched braces or $s in paragraph being terminated. |
85 | 1182 A prefix arg inhibits the checking." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1183 (interactive "*P") |
85 | 1184 (or inhibit-validation |
1185 (save-excursion | |
1186 (tex-validate-region | |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1187 (save-excursion |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1188 (search-backward "\n\n" nil 'move) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1189 (point)) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1190 (point))) |
85 | 1191 (message "Paragraph being closed appears to contain a mismatch")) |
1192 (insert "\n\n")) | |
1193 | |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1194 (define-skeleton tex-insert-braces |
85 | 1195 "Make a pair of braces and be poised to type inside of them." |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1196 nil |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1197 ?\{ _ ?}) |
85 | 1198 |
21121
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1199 ;; This function is used as the value of fill-nobreak-predicate |
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1200 ;; in LaTeX mode. Its job is to prevent line-breaking inside |
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1201 ;; of a \verb construct. |
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1202 (defun latex-fill-nobreak-predicate () |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1203 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1204 (skip-chars-backward " ") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1205 ;; Don't break after \ since `\ ' has special meaning. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1206 (or (and (not (bobp)) (memq (char-syntax (char-before)) '(?\\ ?/))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1207 (let ((opoint (point)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1208 inside) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1209 (beginning-of-line) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1210 (while (re-search-forward "\\\\verb\\(.\\)" opoint t) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1211 (unless (re-search-forward (regexp-quote (match-string 1)) opoint t) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1212 (setq inside t))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1213 inside)))) |
21121
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1214 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1215 (defvar latex-block-default "enumerate") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1216 |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1217 (defvar latex-block-args-alist |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1218 '(("array" nil ?\{ (skeleton-read "[options]: ") ?\}) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1219 ("tabular" nil ?\{ (skeleton-read "[options]: ") ?\})) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1220 "Skeleton element to use for arguments to particular environments. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1221 Every element of the list has the form (NAME . SKEL-ELEM) where NAME is |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1222 the name of the environment and SKEL-ELEM is an element to use in |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1223 a skeleton (see `skeleton-insert').") |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1224 |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1225 (defvar latex-block-body-alist |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1226 '(("enumerate" nil '(latex-insert-item) > _) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1227 ("itemize" nil '(latex-insert-item) > _) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1228 ("table" nil "\\caption{" > - "}" > \n _) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1229 ("figure" nil > _ \n "\\caption{" > _ "}" >)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1230 "Skeleton element to use for the body of particular environments. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1231 Every element of the list has the form (NAME . SKEL-ELEM) where NAME is |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1232 the name of the environment and SKEL-ELEM is an element to use in |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1233 a skeleton (see `skeleton-insert').") |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1234 |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1235 ;; Like tex-insert-braces, but for LaTeX. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1236 (defalias 'tex-latex-block 'latex-insert-block) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1237 (define-skeleton latex-insert-block |
51525
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
1238 "Create a matching pair of lines \\begin{NAME} and \\end{NAME} at point. |
85 | 1239 Puts point on a blank line between them." |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1240 (let ((choice (completing-read (format "LaTeX block name [%s]: " |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1241 latex-block-default) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1242 (append latex-block-names |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1243 latex-standard-block-names) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1244 nil nil nil nil latex-block-default))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1245 (setq latex-block-default choice) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1246 (unless (or (member choice latex-standard-block-names) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1247 (member choice latex-block-names)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1248 ;; Remember new block names for later completion. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1249 (push choice latex-block-names)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1250 choice) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1251 \n "\\begin{" str "}" |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1252 (cdr (assoc str latex-block-args-alist)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1253 > \n (or (cdr (assoc str latex-block-body-alist)) '(nil > _)) \n |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1254 "\\end{" str "}" > \n) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1255 |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1256 (define-skeleton latex-insert-item |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1257 "Insert a \item macro." |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1258 nil |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1259 \n "\\item " >) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1260 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1261 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1262 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1263 ;;;; LaTeX syntax navigation |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1264 ;;;; |
85 | 1265 |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1266 (defmacro tex-search-noncomment (&rest body) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1267 "Execute BODY as long as it return non-nil and point is in a comment. |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1268 Return the value returned by the last execution of BODY." |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1269 (declare (debug t)) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1270 (let ((res-sym (make-symbol "result"))) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1271 `(let (,res-sym) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1272 (while |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1273 (and (setq ,res-sym (progn ,@body)) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1274 (save-excursion (skip-chars-backward "^\n%") (not (bolp))))) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1275 ,res-sym))) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1276 |
85 | 1277 (defun tex-last-unended-begin () |
7285 | 1278 "Leave point at the beginning of the last `\\begin{...}' that is unended." |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1279 (condition-case nil |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1280 (while (and (tex-search-noncomment |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1281 (re-search-backward "\\\\\\(begin\\|end\\)\\s *{")) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1282 (looking-at "\\\\end")) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1283 (tex-last-unended-begin)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1284 (search-failed (error "Couldn't find unended \\begin")))) |
85 | 1285 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1286 (defun tex-next-unmatched-end () |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1287 "Leave point at the end of the next `\\end' that is unended." |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1288 (while (and (tex-search-noncomment |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1289 (re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}")) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1290 (save-excursion (goto-char (match-beginning 0)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1291 (looking-at "\\\\begin"))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1292 (tex-next-unmatched-end))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1293 |
7297
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1294 (defun tex-goto-last-unclosed-latex-block () |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1295 "Move point to the last unclosed \\begin{...}. |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1296 Mark is left at original location." |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1297 (interactive) |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1298 (let ((spot)) |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1299 (save-excursion |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1300 (tex-last-unended-begin) |
7297
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1301 (setq spot (point))) |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1302 (push-mark) |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1303 (goto-char spot))) |
a480d11d5594
(tex-goto-last-unclosed-latex-block): New function. Bound to C-c C-u in
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7285
diff
changeset
|
1304 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1305 (defun latex-backward-sexp-1 () |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1306 "Like (backward-sexp 1) but aware of multi-char elements." |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1307 (let ((pos (point)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1308 (forward-sexp-function)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1309 (backward-sexp 1) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1310 (if (looking-at "\\\\begin\\>") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1311 (signal 'scan-error |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1312 (list "Containing expression ends prematurely" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1313 (point) (prog1 (point) (goto-char pos)))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1314 (when (eq (char-after) ?{) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1315 (let ((newpos (point))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1316 (when (ignore-errors (backward-sexp 1) t) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1317 (if (looking-at "\\\\end\\>") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1318 (tex-last-unended-begin) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1319 (goto-char newpos)))))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1320 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1321 (defun latex-forward-sexp-1 () |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1322 "Like (forward-sexp 1) but aware of multi-char elements." |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1323 (let ((pos (point)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1324 (forward-sexp-function)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1325 (forward-sexp 1) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1326 (let ((newpos (point))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1327 (skip-syntax-backward "/w") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1328 (cond |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1329 ((looking-at "\\\\end\\>") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1330 (signal 'scan-error |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1331 (list "Containing expression ends prematurely" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1332 (point) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1333 (prog1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1334 (progn (ignore-errors (forward-sexp 2)) (point)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1335 (goto-char pos))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1336 ((looking-at "\\\\begin\\>") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1337 (goto-char (match-end 0)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1338 (tex-next-unmatched-end)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1339 (t (goto-char newpos)))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1340 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1341 (defun latex-forward-sexp (&optional arg) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1342 "Like `forward-sexp' but aware of multi-char elements." |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1343 (interactive "P") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1344 (unless arg (setq arg 1)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1345 (let ((pos (point))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1346 (condition-case err |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1347 (while (/= arg 0) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1348 (setq arg |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1349 (if (> arg 0) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1350 (progn (latex-forward-sexp-1) (1- arg)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1351 (progn (latex-backward-sexp-1) (1+ arg))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1352 (scan-error |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1353 (goto-char pos) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1354 (signal (car err) (cdr err)))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1355 |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1356 (defun latex-syntax-after () |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1357 "Like (char-syntax (char-after)) but aware of multi-char elements." |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1358 (if (looking-at "\\\\end\\>") ?\) (char-syntax (following-char)))) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1359 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1360 (defun latex-skip-close-parens () |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1361 "Like (skip-syntax-forward \" )\") but aware of multi-char elements." |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1362 (let ((forward-sexp-function nil)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1363 (while (progn (skip-syntax-forward " )") |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1364 (looking-at "\\\\end\\>")) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1365 (forward-sexp 2)))) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1366 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1367 (defun latex-down-list () |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1368 "Like (down-list 1) but aware of multi-char elements." |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1369 (forward-comment (point-max)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1370 (let ((forward-sexp-function nil)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1371 (if (not (looking-at "\\\\begin\\>")) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1372 (down-list 1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1373 (forward-sexp 1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1374 ;; Skip arguments. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1375 (while (looking-at "[ \t]*[[{(]") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1376 (with-syntax-table tex-mode-syntax-table |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1377 (forward-sexp)))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1378 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1379 (defalias 'tex-close-latex-block 'latex-close-block) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1380 (define-skeleton latex-close-block |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1381 "Create an \\end{...} to match the last unclosed \\begin{...}." |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1382 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1383 (tex-last-unended-begin) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1384 (if (not (looking-at "\\\\begin\\(\\s *{[^}\n]*}\\)")) '("{" _ "}") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1385 (match-string 1))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1386 \n "\\end" str > \n) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1387 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1388 (define-skeleton latex-split-block |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1389 "Split the enclosing environment by inserting \\end{..}\\begin{..} at point." |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1390 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1391 (tex-last-unended-begin) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1392 (if (not (looking-at "\\\\begin\\(\\s *{[^}\n]*}\\)")) '("{" _ "}") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1393 (prog1 (match-string 1) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1394 (goto-char (match-end 1)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1395 (setq v1 (buffer-substring (point) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1396 (progn |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1397 (while (looking-at "[ \t]*[[{]") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1398 (forward-sexp 1)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1399 (point))))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1400 \n "\\end" str > \n _ \n "\\begin" str v1 > \n) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1401 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1402 (defconst tex-discount-args-cmds |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1403 '("begin" "end" "input" "special" "cite" "ref" "include" "includeonly" |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1404 "documentclass" "usepackage" "label") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1405 "TeX commands whose arguments should not be counted as text.") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1406 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1407 (defun tex-count-words (begin end) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1408 "Count the number of words in the buffer." |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1409 (interactive |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1410 (if (and transient-mark-mode mark-active) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1411 (list (region-beginning) (region-end)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1412 (list (point-min) (point-max)))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1413 ;; TODO: skip comments and math and maybe some environments. |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1414 (save-excursion |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1415 (goto-char begin) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1416 (let ((count 0)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1417 (while (and (< (point) end) (re-search-forward "\\<" end t)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1418 (if (not (eq (char-syntax (preceding-char)) ?/)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1419 (progn |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1420 ;; Don't count single-char words. |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1421 (unless (looking-at ".\\>") (incf count)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1422 (forward-char 1)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1423 (let ((cmd |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1424 (buffer-substring-no-properties |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1425 (point) (progn (when (zerop (skip-chars-forward "a-zA-Z@")) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1426 (forward-char 1)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1427 (point))))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1428 (when (member cmd tex-discount-args-cmds) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1429 (skip-chars-forward "*") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1430 (forward-comment (point-max)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1431 (when (looking-at "\\[") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1432 (forward-sexp 1) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1433 (forward-comment (point-max))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1434 (if (not (looking-at "{")) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1435 (forward-char 1) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1436 (forward-sexp 1)))))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1437 (message "%s words" count)))) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1438 |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1439 |
85 | 1440 |
1441 ;;; Invoking TeX in an inferior shell. | |
1442 | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1443 ;; Why use a shell instead of running TeX directly? Because if TeX |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1444 ;; gets stuck, the user can switch to the shell window and type at it. |
85 | 1445 |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1446 ;; The utility functions: |
85 | 1447 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1448 (define-derived-mode tex-shell shell-mode "TeX-Shell" |
54423
802a91a2e43a
(tex-shell): Set error parsing function here.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53489
diff
changeset
|
1449 (set (make-local-variable 'compilation-parse-errors-function) |
802a91a2e43a
(tex-shell): Set error parsing function here.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53489
diff
changeset
|
1450 'tex-compilation-parse-errors) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1451 (compilation-shell-minor-mode t)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1452 |
7834
fc1c95bf734b
(tex-start-shell): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
7827
diff
changeset
|
1453 ;;;###autoload |
85 | 1454 (defun tex-start-shell () |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1455 (with-current-buffer |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1456 (make-comint |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1457 "tex-shell" |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
1458 (or tex-shell-file-name (getenv "ESHELL") shell-file-name) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1459 nil) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1460 (let ((proc (get-process "tex-shell"))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1461 (set-process-sentinel proc 'tex-shell-sentinel) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1462 (process-kill-without-query proc) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1463 (tex-shell) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1464 (while (zerop (buffer-size)) |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1465 (sleep-for 1))))) |
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1466 |
23761
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1467 (defun tex-feed-input () |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1468 "Send input to the tex shell process. |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1469 In the tex buffer this can be used to continue an interactive tex run. |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1470 In the tex shell buffer this command behaves like `comint-send-input'." |
23761
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1471 (interactive) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1472 (set-buffer (tex-shell-buf)) |
23761
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1473 (comint-send-input) |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1474 (tex-recenter-output-buffer nil)) |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1475 |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1476 (defun tex-display-shell () |
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1477 "Make the TeX shell buffer visible in a window." |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1478 (display-buffer (tex-shell-buf)) |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1479 (tex-recenter-output-buffer nil)) |
85 | 1480 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1481 (defun tex-shell-sentinel (proc msg) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1482 (cond ((null (buffer-name (process-buffer proc))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1483 ;; buffer killed |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1484 (set-process-buffer proc nil) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1485 (tex-delete-last-temp-files)) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1486 ((memq (process-status proc) '(signal exit)) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1487 (tex-delete-last-temp-files)))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1488 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1489 (defun tex-set-buffer-directory (buffer directory) |
85 | 1490 "Set BUFFER's default directory to be DIRECTORY." |
1491 (setq directory (file-name-as-directory (expand-file-name directory))) | |
1492 (if (not (file-directory-p directory)) | |
1493 (error "%s is not a directory" directory) | |
1494 (save-excursion | |
1495 (set-buffer buffer) | |
1496 (setq default-directory directory)))) | |
1497 | |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1498 (defvar tex-send-command-modified-tick 0) |
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1499 (make-variable-buffer-local 'tex-send-command-modified-tick) |
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1500 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1501 (defun tex-shell-proc () |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1502 (or (tex-shell-running) (error "No TeX subprocess"))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1503 (defun tex-shell-buf () |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1504 (process-buffer (tex-shell-proc))) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1505 (defun tex-shell-buf-no-error () |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1506 (let ((proc (tex-shell-running))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1507 (and proc (process-buffer proc)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1508 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1509 (defun tex-send-command (command &optional file background) |
5087
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1510 "Send COMMAND to TeX shell process, substituting optional FILE for *. |
2588
b0a1846fe3b8
Doc fixes. Also a few teaks to pacify the byte-compiler.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2576
diff
changeset
|
1511 Do this in background if optional BACKGROUND is t. If COMMAND has no *, |
b0a1846fe3b8
Doc fixes. Also a few teaks to pacify the byte-compiler.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2576
diff
changeset
|
1512 FILE will be appended, preceded by a blank, to COMMAND. If FILE is nil, no |
b0a1846fe3b8
Doc fixes. Also a few teaks to pacify the byte-compiler.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2576
diff
changeset
|
1513 substitution will be made in COMMAND. COMMAND can be any expression that |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1514 evaluates to a command string. |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1515 |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1516 Return the process in which TeX is running." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1517 (save-excursion |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1518 (let* ((cmd (eval command)) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1519 (proc (tex-shell-proc)) |
5262
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
1520 (buf (process-buffer proc)) |
2265
daf268a98d5e
* tex-mode.el (tex-send-command): Fix the command sent so that no
Jim Blandy <jimb@redhat.com>
parents:
1577
diff
changeset
|
1521 (star (string-match "\\*" cmd)) |
5087
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1522 (string |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1523 (concat |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1524 (if file |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1525 (if star (concat (substring cmd 0 star) |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1526 file (substring cmd (1+ star))) |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1527 (concat cmd " " file)) |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1528 cmd) |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1529 (if background "&" "")))) |
5262
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
1530 ;; Switch to buffer before checking for subproc output in it. |
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
1531 (set-buffer buf) |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1532 ;; If text is unchanged since previous tex-send-command, |
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1533 ;; we haven't got any output. So wait for output now. |
5262
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
1534 (if (= (buffer-modified-tick buf) tex-send-command-modified-tick) |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1535 (accept-process-output proc)) |
5087
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1536 (goto-char (process-mark proc)) |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1537 (insert string) |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1538 (comint-send-input) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1539 (setq tex-send-command-modified-tick (buffer-modified-tick buf)) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1540 proc))) |
85 | 1541 |
6479
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1542 (defun tex-delete-last-temp-files (&optional not-all) |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1543 "Delete any junk files from last temp file. |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1544 If NOT-ALL is non-nil, save the `.dvi' file." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1545 (if tex-last-temp-file |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1546 (let* ((dir (file-name-directory tex-last-temp-file)) |
7536
efecdee78026
(tex-delete-last-temp-files): Don't fail on non-existent directory.
Karl Heuer <kwzh@gnu.org>
parents:
7298
diff
changeset
|
1547 (list (and (file-directory-p dir) |
efecdee78026
(tex-delete-last-temp-files): Don't fail on non-existent directory.
Karl Heuer <kwzh@gnu.org>
parents:
7298
diff
changeset
|
1548 (file-name-all-completions |
22707
4fa39e6af756
(tex-delete-last-temp-files): Use file-name-sans-extensions.
Richard M. Stallman <rms@gnu.org>
parents:
22292
diff
changeset
|
1549 (file-name-sans-extension |
4fa39e6af756
(tex-delete-last-temp-files): Use file-name-sans-extensions.
Richard M. Stallman <rms@gnu.org>
parents:
22292
diff
changeset
|
1550 (file-name-nondirectory tex-last-temp-file)) |
4fa39e6af756
(tex-delete-last-temp-files): Use file-name-sans-extensions.
Richard M. Stallman <rms@gnu.org>
parents:
22292
diff
changeset
|
1551 dir)))) |
7536
efecdee78026
(tex-delete-last-temp-files): Don't fail on non-existent directory.
Karl Heuer <kwzh@gnu.org>
parents:
7298
diff
changeset
|
1552 (while list |
6479
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1553 (if not-all |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1554 (and |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1555 ;; If arg is non-nil, don't delete the .dvi file. |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1556 (not (string-match "\\.dvi$" (car list))) |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1557 (delete-file (concat dir (car list)))) |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1558 (delete-file (concat dir (car list)))) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1559 (setq list (cdr list)))))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1560 |
741
587f7a98341d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
739
diff
changeset
|
1561 (add-hook 'kill-emacs-hook 'tex-delete-last-temp-files) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1562 |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1563 ;; |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1564 ;; Machinery to guess the command that the user wants to execute. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1565 ;; |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1566 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1567 (defvar tex-compile-history nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1568 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1569 (defvar tex-input-files-re |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1570 (eval-when-compile |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1571 (concat "\\." (regexp-opt '("tex" "texi" "texinfo" |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1572 "bbl" "ind" "sty" "cls") t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1573 ;; Include files with no dots (for directories). |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1574 "\\'\\|\\`[^.]+\\'"))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1575 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1576 (defcustom tex-use-reftex t |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1577 "If non-nil, use RefTeX's list of files to determine what command to use." |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1578 :type 'boolean) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1579 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1580 (defvar tex-compile-commands |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1581 '(((concat "pdf" tex-command |
51562
65f7a99a6241
(tex-compile-commands): Handle tex-start-commands like tex-start-tex does.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51533
diff
changeset
|
1582 " " (if (< 0 (length tex-start-commands)) |
65f7a99a6241
(tex-compile-commands): Handle tex-start-commands like tex-start-tex does.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51533
diff
changeset
|
1583 (shell-quote-argument tex-start-commands)) " %f") |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1584 t "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1585 ((concat tex-command |
51562
65f7a99a6241
(tex-compile-commands): Handle tex-start-commands like tex-start-tex does.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51533
diff
changeset
|
1586 " " (if (< 0 (length tex-start-commands)) |
65f7a99a6241
(tex-compile-commands): Handle tex-start-commands like tex-start-tex does.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51533
diff
changeset
|
1587 (shell-quote-argument tex-start-commands)) " %f") |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1588 t "%r.dvi") |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1589 ("yap %r &" "%r.dvi") |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1590 ("xdvi %r &" "%r.dvi") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1591 ("advi %r &" "%r.dvi") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1592 ("bibtex %r" "%r.aux" "%r.bbl") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1593 ("makeindex %r" "%r.idx" "%r.ind") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1594 ("texindex %r.??") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1595 ("dvipdfm %r" "%r.dvi" "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1596 ("dvipdf %r" "%r.dvi" "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1597 ("dvips %r" "%r.dvi" "%r.ps") |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1598 ("ps2pdf %r.ps" "%r.ps" "%r.pdf") |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1599 ("gv %r.ps &" "%r.ps") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1600 ("gv %r.pdf &" "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1601 ("xpdf %r.pdf &" "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1602 ("lpr %r.ps" "%r.ps")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1603 "List of commands for `tex-compile'. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1604 Each element should be of the form (FORMAT IN OUT) where |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1605 FORMAT is an expression that evaluates to a string that can contain |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1606 - `%r' the main file name without extension. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1607 - `%f' the main file name. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1608 IN can be either a string (with the same % escapes in it) indicating |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1609 the name of the input file, or t to indicate that the input is all |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1610 the TeX files of the document, or nil if we don't know. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1611 OUT describes the output file and is either a %-escaped string |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1612 or nil to indicate that there is no output file.") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1613 |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1614 ;; defsubst* gives better byte-code than defsubst. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1615 (defsubst* tex-string-prefix-p (str1 str2) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1616 "Return non-nil if STR1 is a prefix of STR2" |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1617 (eq t (compare-strings str2 nil (length str1) str1 nil nil))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1618 |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1619 (defun tex-guess-main-file (&optional all) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1620 "Find a likely `tex-main-file'. |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1621 Looks for hints in other buffers in the same directory or in |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1622 ALL other buffers. If ALL is `sub' only look at buffers in parent directories |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1623 of the current buffer." |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1624 (let ((dir default-directory) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1625 (header-re tex-start-of-header)) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1626 (catch 'found |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1627 ;; Look for a buffer with `tex-main-file' set. |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1628 (dolist (buf (if (consp all) all (buffer-list))) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1629 (with-current-buffer buf |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1630 (when (and (cond |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1631 ((null all) (equal dir default-directory)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1632 ((eq all 'sub) (tex-string-prefix-p default-directory dir)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1633 (t)) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1634 (stringp tex-main-file)) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1635 (throw 'found (expand-file-name tex-main-file))))) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1636 ;; Look for a buffer containing the magic `tex-start-of-header'. |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1637 (dolist (buf (if (consp all) all (buffer-list))) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1638 (with-current-buffer buf |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1639 (when (and (cond |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1640 ((null all) (equal dir default-directory)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1641 ((eq all 'sub) (tex-string-prefix-p default-directory dir)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1642 (t)) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1643 buffer-file-name |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1644 ;; (or (easy-mmode-derived-mode-p 'latex-mode) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1645 ;; (easy-mmode-derived-mode-p 'plain-tex-mode)) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1646 (save-excursion |
43691
f8e3c1819848
(tex-guess-main-file): Handle the case where one of the buffers is narrowed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43307
diff
changeset
|
1647 (save-restriction |
f8e3c1819848
(tex-guess-main-file): Handle the case where one of the buffers is narrowed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43307
diff
changeset
|
1648 (widen) |
f8e3c1819848
(tex-guess-main-file): Handle the case where one of the buffers is narrowed.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43307
diff
changeset
|
1649 (goto-char (point-min)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1650 (re-search-forward |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1651 header-re (+ (point) 10000) t)))) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1652 (throw 'found (expand-file-name buffer-file-name)))))))) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1653 |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
1654 (defun tex-main-file () |
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
1655 "Return the relative name of the main file." |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1656 (let* ((file (or tex-main-file |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1657 ;; Compatibility with AUCTeX. |
51796
09e60f24d0c4
(tex-main-file): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51562
diff
changeset
|
1658 (with-no-warnings |
09e60f24d0c4
(tex-main-file): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51562
diff
changeset
|
1659 (when (and (boundp 'TeX-master) (stringp TeX-master)) |
09e60f24d0c4
(tex-main-file): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51562
diff
changeset
|
1660 (make-local-variable 'tex-main-file) |
09e60f24d0c4
(tex-main-file): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51562
diff
changeset
|
1661 (setq tex-main-file TeX-master))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1662 ;; Try to guess the main file. |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1663 (if (not buffer-file-name) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1664 (error "Buffer is not associated with any file") |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1665 (file-relative-name |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1666 (if (save-excursion |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1667 (goto-char (point-min)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1668 (re-search-forward tex-start-of-header |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1669 (+ (point) 10000) t)) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1670 ;; This is the main file. |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1671 buffer-file-name |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1672 ;; This isn't the main file, let's try to find better, |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1673 (or (tex-guess-main-file) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1674 (tex-guess-main-file 'sub) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1675 ;; (tex-guess-main-file t) |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
1676 buffer-file-name))))))) |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1677 (if (or (file-exists-p file) (string-match "\\.tex\\'" file)) |
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1678 file (concat file ".tex")))) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1679 |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1680 (defun tex-summarize-command (cmd) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1681 (if (not (stringp cmd)) "" |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1682 (mapconcat 'identity |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1683 (mapcar (lambda (s) (car (split-string s))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1684 (split-string cmd "\\s-*\\(?:;\\|&&\\)\\s-*")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1685 "&"))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1686 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1687 (defun tex-uptodate-p (file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1688 "Return non-nil if FILE is not uptodate w.r.t the document source files. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1689 FILE is typically the output DVI or PDF file." |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1690 ;; We should check all the files included !!! |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1691 (and |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1692 ;; Clearly, the target must exist. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1693 (file-exists-p file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1694 ;; And the last run must not have asked for a rerun. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1695 ;; FIXME: this should check that the last run was done on the same file. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1696 (let ((buf (condition-case nil (tex-shell-buf) (error nil)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1697 (when buf |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1698 (with-current-buffer buf |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1699 (save-excursion |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1700 (goto-char (point-max)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1701 (and (re-search-backward |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1702 "(see the transcript file for additional information)" nil t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1703 (> (save-excursion |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1704 (or (re-search-backward "\\[[0-9]+\\]" nil t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1705 (point-min))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1706 (save-excursion |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1707 (or (re-search-backward "Rerun" nil t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1708 (point-min))))))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1709 ;; And the input files must not have been changed in the meantime. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1710 (let ((files (if (and tex-use-reftex |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1711 (fboundp 'reftex-scanning-info-available-p) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1712 (reftex-scanning-info-available-p)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1713 (reftex-all-document-files) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1714 (list (file-name-directory (expand-file-name file))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1715 (ignored-dirs-re |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1716 (concat |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1717 (regexp-opt |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1718 (delq nil (mapcar (lambda (s) (if (eq (aref s (1- (length s))) ?/) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1719 (substring s 0 (1- (length s))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1720 completion-ignored-extensions)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1721 t) "\\'")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1722 (uptodate t)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1723 (while (and files uptodate) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1724 (let ((f (pop files))) |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1725 (if (and (file-directory-p f) |
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1726 ;; Avoid infinite loops. |
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1727 (not (file-symlink-p f))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1728 (unless (string-match ignored-dirs-re f) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1729 (setq files (nconc |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1730 (directory-files f t tex-input-files-re) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1731 files))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1732 (when (file-newer-than-file-p f file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1733 (setq uptodate nil))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1734 uptodate))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1735 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1736 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1737 (autoload 'format-spec "format-spec") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1738 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1739 (defvar tex-executable-cache nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1740 (defun tex-executable-exists-p (name) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1741 "Like `executable-find' but with a cache." |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1742 (let ((cache (assoc name tex-executable-cache))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1743 (if cache (cdr cache) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1744 (let ((executable (executable-find name))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1745 (push (cons name executable) tex-executable-cache) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1746 executable)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1747 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1748 (defun tex-command-executable (cmd) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1749 (let ((s (if (stringp cmd) cmd (eval (car cmd))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1750 (substring s 0 (string-match "[ \t]\\|\\'" s)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1751 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1752 (defun tex-command-active-p (cmd fspec) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1753 "Return non-nil if the CMD spec might need to be run." |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1754 (let ((in (nth 1 cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1755 (out (nth 2 cmd))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1756 (if (stringp in) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1757 (let ((file (format-spec in fspec))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1758 (when (file-exists-p file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1759 (or (not out) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1760 (file-newer-than-file-p |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1761 file (format-spec out fspec))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1762 (when (and (eq in t) (stringp out)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1763 (not (tex-uptodate-p (format-spec out fspec))))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1764 |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1765 (defun tex-compile-default (fspec) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1766 "Guess a default command given the format-spec FSPEC." |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1767 ;; TODO: Learn to do latex+dvips! |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1768 (let ((cmds nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1769 (unchanged-in nil)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1770 ;; Only consider active commands. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1771 (dolist (cmd tex-compile-commands) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1772 (when (tex-executable-exists-p (tex-command-executable cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1773 (if (tex-command-active-p cmd fspec) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1774 (push cmd cmds) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1775 (push (nth 1 cmd) unchanged-in)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1776 ;; Remove those commands whose input was considered stable for |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1777 ;; some other command (typically if (t . "%.pdf") is inactive |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1778 ;; then we're using pdflatex and the fact that the dvi file |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1779 ;; is inexistent doesn't matter). |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1780 (let ((tmp nil)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1781 (dolist (cmd cmds) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1782 (unless (member (nth 1 cmd) unchanged-in) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1783 (push cmd tmp))) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1784 ;; Only remove if there's something left. |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1785 (if tmp (setq cmds tmp))) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1786 ;; Remove commands whose input is not uptodate either. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1787 (let ((outs (delq nil (mapcar (lambda (x) (nth 2 x)) cmds))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1788 (tmp nil)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1789 (dolist (cmd cmds) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1790 (unless (member (nth 1 cmd) outs) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1791 (push cmd tmp))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1792 ;; Only remove if there's something left. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1793 (if tmp (setq cmds tmp))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1794 ;; Select which file we're going to operate on (the latest). |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1795 (let ((latest (nth 1 (car cmds)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1796 (dolist (cmd (prog1 (cdr cmds) (setq cmds (list (car cmds))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1797 (if (equal latest (nth 1 cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1798 (push cmd cmds) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1799 (unless (eq latest t) ;Can't beat that! |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1800 (if (or (not (stringp latest)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1801 (eq (nth 1 cmd) t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1802 (and (stringp (nth 1 cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1803 (file-newer-than-file-p |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1804 (format-spec (nth 1 cmd) fspec) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1805 (format-spec latest fspec)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1806 (setq latest (nth 1 cmd) cmds (list cmd))))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1807 ;; Expand the command spec into the actual text. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1808 (dolist (cmd (prog1 cmds (setq cmds nil))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1809 (push (cons (eval (car cmd)) (cdr cmd)) cmds)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1810 ;; Select the favorite command from the history. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1811 (let ((hist tex-compile-history) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1812 re hist-cmd) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1813 (while hist |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1814 (setq hist-cmd (pop hist)) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1815 (setq re (concat "\\`" |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1816 (regexp-quote (tex-command-executable hist-cmd)) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1817 "\\([ \t]\\|\\'\\)")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1818 (dolist (cmd cmds) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1819 ;; If the hist entry uses the same command and applies to a file |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1820 ;; of the same type (e.g. `gv %r.pdf' vs `gv %r.ps'), select cmd. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1821 (and (string-match re (car cmd)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1822 (or (not (string-match "%[fr]\\([-._[:alnum:]]+\\)" (car cmd))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1823 (string-match (regexp-quote (match-string 1 (car cmd))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1824 hist-cmd)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1825 (setq hist nil cmds (list cmd))))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1826 ;; Substitute and return. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1827 (if (and hist-cmd |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1828 (string-match (concat "[' \t\"]" (format-spec "%r" fspec) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1829 "\\([;&' \t\"]\\|\\'\\)") hist-cmd)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1830 ;; The history command was already applied to the same file, |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1831 ;; so just reuse it. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1832 hist-cmd |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1833 (if cmds (format-spec (caar cmds) fspec)))))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1834 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1835 (defun tex-compile (dir cmd) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1836 "Run a command CMD on current TeX buffer's file in DIR." |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1837 ;; FIXME: Use time-stamps on files to decide the next op. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1838 (interactive |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1839 (let* ((file (tex-main-file)) |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1840 (default-directory |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1841 (prog1 (file-name-directory (expand-file-name file)) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1842 (setq file (file-name-nondirectory file)))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1843 (root (file-name-sans-extension file)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1844 (fspec (list (cons ?r (comint-quote-filename root)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1845 (cons ?f (comint-quote-filename file)))) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1846 (default (tex-compile-default fspec))) |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1847 (list default-directory |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1848 (completing-read |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1849 (format "Command [%s]: " (tex-summarize-command default)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1850 (mapcar (lambda (x) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1851 (list (format-spec (eval (car x)) fspec))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1852 tex-compile-commands) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1853 nil nil nil 'tex-compile-history default)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1854 (save-some-buffers (not compilation-ask-about-save) nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1855 (if (tex-shell-running) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1856 (tex-kill-job) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1857 (tex-start-shell)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1858 (tex-send-tex-command cmd dir)) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1859 |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1860 (defun tex-start-tex (command file &optional dir) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1861 "Start a TeX run, using COMMAND on FILE." |
23322 | 1862 (let* ((star (string-match "\\*" command)) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1863 (compile-command |
23322 | 1864 (if star |
1865 (concat (substring command 0 star) | |
1866 (comint-quote-filename file) | |
1867 (substring command (1+ star))) | |
1868 (concat command " " | |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1869 tex-start-options |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
1870 (if (< 0 (length tex-start-commands)) |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
1871 (concat |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
1872 (shell-quote-argument tex-start-commands) " ")) |
23322 | 1873 (comint-quote-filename file))))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1874 (tex-send-tex-command compile-command dir))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1875 |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1876 (defun tex-send-tex-command (cmd &optional dir) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1877 (unless (or (equal dir (let ((buf (tex-shell-buf-no-error))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1878 (and buf (with-current-buffer buf |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1879 default-directory)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1880 (not dir)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1881 (let (shell-dirtrack-verbose) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1882 (tex-send-command tex-shell-cd-command dir))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1883 (with-current-buffer (process-buffer (tex-send-command cmd)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1884 (setq compilation-last-buffer (current-buffer)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1885 (compilation-forget-errors) |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1886 ;; Don't parse previous compilations. |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1887 (set-marker compilation-parsing-end (1- (point-max)))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1888 (tex-display-shell) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1889 (setq tex-last-buffer-texed (current-buffer))) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1890 |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1891 (defvar tex-error-parse-syntax-table |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1892 (let ((st (make-syntax-table))) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1893 (modify-syntax-entry ?\( "()" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1894 (modify-syntax-entry ?\) ")(" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1895 (modify-syntax-entry ?\\ "\\" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1896 (modify-syntax-entry ?\{ "_" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1897 (modify-syntax-entry ?\} "_" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1898 (modify-syntax-entry ?\[ "_" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1899 (modify-syntax-entry ?\] "_" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1900 ;; Single quotations may appear in errors |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1901 (modify-syntax-entry ?\" "_" st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1902 st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1903 "Syntax-table used while parsing TeX error messages.") |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1904 |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1905 (defun tex-compilation-parse-errors (limit-search find-at-least) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1906 "Parse the current buffer as TeX error messages. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1907 See the variable `compilation-parse-errors-function' for the interface it uses. |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1908 |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1909 This function parses only the last TeX compilation. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1910 It works on TeX compilations only. It is necessary for that purpose, |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1911 since TeX does not put file names and line numbers on the same line as |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1912 for the error messages." |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1913 (require 'thingatpt) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1914 (setq compilation-error-list nil) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1915 (message "Parsing error messages...") |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1916 (let ((default-directory ; Perhaps dir has changed meanwhile. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1917 (file-name-directory (buffer-file-name tex-last-buffer-texed))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1918 found-desired (num-errors-found 0) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1919 last-filename last-linenum last-position |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1920 begin-of-error end-of-error) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1921 ;; Don't reparse messages already seen at last parse. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1922 (goto-char compilation-parsing-end) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1923 ;; Parse messages. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1924 (while (and (not (or found-desired (eobp))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1925 (prog1 (re-search-forward "^! " nil 'move) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1926 (setq begin-of-error (match-beginning 0) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1927 end-of-error (match-end 0))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1928 (re-search-forward |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1929 "^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\)?\\(.*\\)$" nil 'move)) |
54423
802a91a2e43a
(tex-shell): Set error parsing function here.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53489
diff
changeset
|
1930 (let* ((this-error (copy-marker begin-of-error)) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1931 (linenum (string-to-int (match-string 1))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1932 (error-text (regexp-quote (match-string 3))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1933 (filename |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1934 (save-excursion |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1935 (with-syntax-table tex-error-parse-syntax-table |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1936 (backward-up-list 1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1937 (skip-syntax-forward "(_") |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1938 (while (not (file-readable-p (thing-at-point 'filename))) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1939 (skip-syntax-backward "(_") |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1940 (backward-up-list 1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1941 (skip-syntax-forward "(_")) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1942 (thing-at-point 'filename)))) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1943 (new-file |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1944 (or (null last-filename) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1945 (not (string-equal last-filename filename)))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1946 (error-location |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1947 (save-excursion |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1948 (if (equal filename (concat tex-zap-file ".tex")) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1949 (set-buffer tex-last-buffer-texed) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1950 (set-buffer (find-file-noselect filename))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1951 (if new-file |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1952 (progn (goto-line linenum) (setq last-position nil)) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1953 (goto-char last-position) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1954 (forward-line (- linenum last-linenum))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1955 ;; first try a forward search for the error text, |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1956 ;; then a backward search limited by the last error. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1957 (let ((starting-point (point))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1958 (or (re-search-forward error-text nil t) |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
1959 (re-search-backward error-text last-position t) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1960 (goto-char starting-point))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1961 (point-marker)))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1962 (goto-char this-error) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1963 (if (and compilation-error-list |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1964 (or (and find-at-least |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1965 (>= num-errors-found |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1966 find-at-least)) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1967 (and limit-search |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1968 (>= end-of-error limit-search))) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1969 new-file) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1970 (setq found-desired t) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1971 (setq num-errors-found (1+ num-errors-found) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1972 last-filename filename |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1973 last-linenum linenum |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1974 last-position error-location |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1975 compilation-error-list ; Add the new error |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1976 (cons (cons this-error error-location) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1977 compilation-error-list)) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1978 (goto-char end-of-error))))) |
25414
7c4808c6804b
(tex-compilation-parse-errors):
Richard M. Stallman <rms@gnu.org>
parents:
24527
diff
changeset
|
1979 (set-marker compilation-parsing-end (point)) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
1980 (setq compilation-error-list (nreverse compilation-error-list)) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1981 (message "Parsing error messages...done")) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1982 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1983 ;;; The commands: |
85 | 1984 |
1985 (defun tex-region (beg end) | |
1986 "Run TeX on the current region, via a temporary file. | |
1987 The file's name comes from the variable `tex-zap-file' and the | |
1988 variable `tex-directory' says where to put it. | |
1989 | |
1990 If the buffer has a header, the header is given to TeX before the | |
1991 region itself. The buffer's header is all lines between the strings | |
1992 defined by `tex-start-of-header' and `tex-end-of-header' inclusive. | |
1993 The header must start in the first 100 lines of the buffer. | |
1994 | |
1995 The value of `tex-trailer' is given to TeX as input after the region. | |
1996 | |
1997 The value of `tex-command' specifies the command to use to run TeX." | |
1998 (interactive "r") | |
1999 (if (tex-shell-running) | |
2000 (tex-kill-job) | |
2001 (tex-start-shell)) | |
2002 (or tex-zap-file | |
2003 (setq tex-zap-file (tex-generate-zap-file-name))) | |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2004 ;; Temp file will be written and TeX will be run in zap-directory. |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2005 ;; If the TEXINPUTS file has relative directories or if the region has |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2006 ;; \input of files, this must be the same directory as the file for |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2007 ;; TeX to access the correct inputs. That's why it's safest if |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2008 ;; tex-directory is ".". |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2009 (let* ((zap-directory |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2010 (file-name-as-directory (expand-file-name tex-directory))) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2011 (tex-out-file (expand-file-name (concat tex-zap-file ".tex") |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2012 zap-directory))) |
9450
af39d29d1386
(compare-windows-whitespace): Eliminate initial value.
Richard M. Stallman <rms@gnu.org>
parents:
8890
diff
changeset
|
2013 ;; Don't delete temp files if we do the same buffer twice in a row. |
af39d29d1386
(compare-windows-whitespace): Eliminate initial value.
Richard M. Stallman <rms@gnu.org>
parents:
8890
diff
changeset
|
2014 (or (eq (current-buffer) tex-last-buffer-texed) |
af39d29d1386
(compare-windows-whitespace): Eliminate initial value.
Richard M. Stallman <rms@gnu.org>
parents:
8890
diff
changeset
|
2015 (tex-delete-last-temp-files t)) |
85 | 2016 ;; Write the new temp file. |
2017 (save-excursion | |
2018 (save-restriction | |
2019 (widen) | |
2020 (goto-char (point-min)) | |
2021 (forward-line 100) | |
2022 (let ((search-end (point)) | |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2023 (default-directory zap-directory) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2024 (already-output 0)) |
85 | 2025 (goto-char (point-min)) |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2026 |
16777
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
2027 ;; Maybe copy first line, such as `\input texinfo', to temp file. |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
2028 (and tex-first-line-header-regexp |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
2029 (looking-at tex-first-line-header-regexp) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2030 (write-region (point) |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2031 (progn (forward-line 1) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2032 (setq already-output (point))) |
16777
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
2033 tex-out-file nil nil)) |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
2034 |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2035 ;; Write out the header, if there is one, |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2036 ;; and any of the specified region which extends before it. |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2037 ;; But don't repeat anything already written. |
13248
a7e83f7eb499
(tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents:
12704
diff
changeset
|
2038 (if (re-search-forward tex-start-of-header search-end t) |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2039 (let (hbeg) |
85 | 2040 (beginning-of-line) |
2041 (setq hbeg (point)) ;mark beginning of header | |
13248
a7e83f7eb499
(tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents:
12704
diff
changeset
|
2042 (if (re-search-forward tex-end-of-header nil t) |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2043 (let (hend) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2044 (forward-line 1) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2045 (setq hend (point)) ;mark end of header |
16807
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2046 (write-region (max (min hbeg beg) already-output) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2047 hend |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2048 tex-out-file |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2049 (not (zerop already-output)) nil) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2050 (setq already-output hend))))) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2051 |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2052 ;; Write out the specified region |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2053 ;; (but don't repeat anything already written). |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2054 (write-region (max beg already-output) end |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2055 tex-out-file |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2056 (not (zerop already-output)) nil)) |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2057 ;; Write the trailer, if any. |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2058 ;; Precede it with a newline to make sure it |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2059 ;; is not hidden in a comment. |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2060 (if tex-trailer |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2061 (write-region (concat "\n" tex-trailer) nil |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2062 tex-out-file t nil)))) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2063 ;; Record the file name to be deleted afterward. |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2064 (setq tex-last-temp-file tex-out-file) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2065 ;; Use a relative file name here because (1) the proper dir |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2066 ;; is already current, and (2) the abs file name is sometimes |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2067 ;; too long and can make tex crash. |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2068 (tex-start-tex tex-command (concat tex-zap-file ".tex") zap-directory) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2069 (setq tex-print-file tex-out-file))) |
85 | 2070 |
2071 (defun tex-buffer () | |
2072 "Run TeX on current buffer. See \\[tex-region] for more information. | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2073 Does not save the buffer, so it's useful for trying experimental versions. |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2074 See \\[tex-file] for an alternative." |
85 | 2075 (interactive) |
2076 (tex-region (point-min) (point-max))) | |
2077 | |
2078 (defun tex-file () | |
2079 "Prompt to save all buffers and run TeX (or LaTeX) on current buffer's file. | |
2080 This function is more useful than \\[tex-buffer] when you need the | |
2081 `.aux' file of LaTeX to have the correct name." | |
2082 (interactive) | |
46120
7177a47bc557
(tex-file): call `save-some-buffers' before `tex-main-file'
Sam Steingold <sds@gnu.org>
parents:
45055
diff
changeset
|
2083 (when tex-offer-save |
7177a47bc557
(tex-file): call `save-some-buffers' before `tex-main-file'
Sam Steingold <sds@gnu.org>
parents:
45055
diff
changeset
|
2084 (save-some-buffers)) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2085 (let* ((source-file (tex-main-file)) |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
2086 (file-dir (file-name-directory (expand-file-name source-file)))) |
85 | 2087 (if (tex-shell-running) |
2088 (tex-kill-job) | |
2089 (tex-start-shell)) | |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2090 (tex-start-tex tex-command source-file file-dir) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2091 (setq tex-print-file (expand-file-name source-file)))) |
85 | 2092 |
2093 (defun tex-generate-zap-file-name () | |
2094 "Generate a unique name suitable for use as a file name." | |
2095 ;; Include the shell process number and host name | |
2096 ;; in case there are multiple shells (for same or different user). | |
23849
1f014e9d0768
(tex-generate-zap-file-name): Don't start the name with #.
Karl Heuer <kwzh@gnu.org>
parents:
23761
diff
changeset
|
2097 ;; Dec 1998: There is a report that some versions of xdvi |
1f014e9d0768
(tex-generate-zap-file-name): Don't start the name with #.
Karl Heuer <kwzh@gnu.org>
parents:
23761
diff
changeset
|
2098 ;; don't work with file names that start with #. |
24109
e1e1bb544d84
(latex-run-command): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
23849
diff
changeset
|
2099 (format "_TZ_%d-%s" |
85 | 2100 (process-id (get-buffer-process "*tex-shell*")) |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
2101 (subst-char-in-string ?. ?- (system-name)))) |
85 | 2102 |
2103 ;; This will perhaps be useful for modifying TEXINPUTS. | |
2104 ;; Expand each file name, separated by colons, in the string S. | |
2105 (defun tex-expand-files (s) | |
2106 (let (elts (start 0)) | |
2107 (while (string-match ":" s start) | |
2108 (setq elts (cons (substring s start (match-beginning 0)) elts)) | |
2109 (setq start (match-end 0))) | |
2110 (or (= start 0) | |
2111 (setq elts (cons (substring s start) elts))) | |
30888
e559f0aa6b2d
Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26270
diff
changeset
|
2112 (mapconcat (lambda (elt) |
e559f0aa6b2d
Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26270
diff
changeset
|
2113 (if (= (length elt) 0) elt (expand-file-name elt))) |
24109
e1e1bb544d84
(latex-run-command): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
23849
diff
changeset
|
2114 (nreverse elts) ":"))) |
85 | 2115 |
2116 (defun tex-shell-running () | |
36105
595ee2f062cf
tex-shell-running: Check the process buffer too
Sam Steingold <sds@gnu.org>
parents:
34139
diff
changeset
|
2117 (let ((proc (get-process "tex-shell"))) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2118 (when proc |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2119 (if (and (eq (process-status proc) 'run) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2120 (buffer-live-p (process-buffer proc))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2121 ;; return the TeX process on success |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2122 proc |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2123 ;; get rid of the process permanently |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2124 ;; this should get rid of the annoying w32 problem with |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2125 ;; dead tex-shell buffer and live process |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2126 (delete-process proc))))) |
85 | 2127 |
2128 (defun tex-kill-job () | |
2129 "Kill the currently running TeX job." | |
2130 (interactive) | |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2131 ;; `quit-process' leads to core dumps of the tex process (except if |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2132 ;; coredumpsize has limit 0kb as on many environments). One would |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2133 ;; like to use (kill-process proc 'lambda), however that construct |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2134 ;; does not work on some systems and kills the shell itself. |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2135 (let ((proc (get-process "tex-shell"))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2136 (when proc (quit-process proc t)))) |
85 | 2137 |
2138 (defun tex-recenter-output-buffer (linenum) | |
2139 "Redisplay buffer of TeX job output so that most recent output can be seen. | |
2140 The last line of the buffer is displayed on | |
2141 line LINE of the window, or centered if LINE is nil." | |
2142 (interactive "P") | |
2143 (let ((tex-shell (get-buffer "*tex-shell*")) | |
16493
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2144 (window)) |
85 | 2145 (if (null tex-shell) |
2146 (message "No TeX output buffer") | |
16493
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2147 (setq window (display-buffer tex-shell)) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2148 (save-selected-window |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2149 (select-window window) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2150 (bury-buffer tex-shell) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2151 (goto-char (point-max)) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2152 (recenter (if linenum |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2153 (prefix-numeric-value linenum) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2154 (/ (window-height) 2))))))) |
85 | 2155 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2156 (defun tex-print (&optional alt) |
85 | 2157 "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file]. |
1577 | 2158 Runs the shell command defined by `tex-dvi-print-command'. If prefix argument |
2159 is provided, use the alternative command, `tex-alt-dvi-print-command'." | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2160 (interactive "P") |
85 | 2161 (let ((print-file-name-dvi (tex-append tex-print-file ".dvi")) |
2162 test-name) | |
2163 (if (and (not (equal (current-buffer) tex-last-buffer-texed)) | |
10341
f27bcd1faf07
(tex-print): Better check for when to print current
Richard M. Stallman <rms@gnu.org>
parents:
10325
diff
changeset
|
2164 (buffer-file-name) |
f27bcd1faf07
(tex-print): Better check for when to print current
Richard M. Stallman <rms@gnu.org>
parents:
10325
diff
changeset
|
2165 ;; Check that this buffer's printed file is up to date. |
85 | 2166 (file-newer-than-file-p |
2167 (setq test-name (tex-append (buffer-file-name) ".dvi")) | |
10341
f27bcd1faf07
(tex-print): Better check for when to print current
Richard M. Stallman <rms@gnu.org>
parents:
10325
diff
changeset
|
2168 (buffer-file-name))) |
85 | 2169 (setq print-file-name-dvi test-name)) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2170 (if (not (file-exists-p print-file-name-dvi)) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2171 (error "No appropriate `.dvi' file could be found") |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2172 (if (tex-shell-running) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2173 (tex-kill-job) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2174 (tex-start-shell)) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2175 (tex-send-command |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2176 (if alt tex-alt-dvi-print-command tex-dvi-print-command) |
48931
0af848ed2cae
(tex-print): Call shell-quote-argument on the file name.
Richard M. Stallman <rms@gnu.org>
parents:
48222
diff
changeset
|
2177 (shell-quote-argument |
0af848ed2cae
(tex-print): Call shell-quote-argument on the file name.
Richard M. Stallman <rms@gnu.org>
parents:
48222
diff
changeset
|
2178 print-file-name-dvi) |
0af848ed2cae
(tex-print): Call shell-quote-argument on the file name.
Richard M. Stallman <rms@gnu.org>
parents:
48222
diff
changeset
|
2179 t)))) |
85 | 2180 |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2181 (defun tex-alt-print () |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2182 "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file]. |
10296
c58e6bb97038
(tex-mode-map): Add BibTeX File menu item.
Richard M. Stallman <rms@gnu.org>
parents:
10215
diff
changeset
|
2183 Runs the shell command defined by `tex-alt-dvi-print-command'." |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2184 (interactive) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2185 (tex-print t)) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2186 |
85 | 2187 (defun tex-view () |
2188 "Preview the last `.dvi' file made by running TeX under Emacs. | |
2189 This means, made using \\[tex-region], \\[tex-buffer] or \\[tex-file]. | |
11617
9eaeed5c8a40
(tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2190 The variable `tex-dvi-view-command' specifies the shell command for preview. |
9eaeed5c8a40
(tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2191 You must set that variable yourself before using this command, |
9eaeed5c8a40
(tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2192 because there is no standard value that would generally work." |
85 | 2193 (interactive) |
11617
9eaeed5c8a40
(tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2194 (or tex-dvi-view-command |
9eaeed5c8a40
(tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2195 (error "You must set `tex-dvi-view-command'")) |
48170
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
2196 (let ((tex-dvi-print-command (eval tex-dvi-view-command))) |
85 | 2197 (tex-print))) |
2198 | |
2199 (defun tex-append (file-name suffix) | |
2200 "Append to FILENAME the suffix SUFFIX, using same algorithm TeX uses. | |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2201 Pascal-based TeX scans for the first period, C TeX uses the last. |
85 | 2202 No period is retained immediately before SUFFIX, |
2203 so normally SUFFIX starts with one." | |
2204 (if (stringp file-name) | |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2205 (let ((file (file-name-nondirectory file-name)) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2206 trial-name) |
14383
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
2207 ;; Try splitting on last period. |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2208 ;; The first-period split can get fooled when two files |
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2209 ;; named a.tex and a.b.tex are both tex'd; |
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2210 ;; the last-period split must be right if it matches at all. |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2211 (setq trial-name |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2212 (concat (file-name-directory file-name) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2213 (substring file 0 |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2214 (string-match "\\.[^.]*$" file)) |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2215 suffix)) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2216 (if (or (file-exists-p trial-name) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2217 (file-exists-p (concat trial-name ".aux"))) ;for BibTeX files |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2218 trial-name |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2219 ;; Not found, so split on first period. |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2220 (concat (file-name-directory file-name) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2221 (substring file 0 |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2222 (string-match "\\." file)) |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2223 suffix))) |
85 | 2224 " ")) |
2225 | |
2226 (defun tex-show-print-queue () | |
2227 "Show the print queue that \\[tex-print] put your job on. | |
1577 | 2228 Runs the shell command defined by `tex-show-queue-command'." |
85 | 2229 (interactive) |
2230 (if (tex-shell-running) | |
2231 (tex-kill-job) | |
2232 (tex-start-shell)) | |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
2233 (tex-send-command tex-show-queue-command) |
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
2234 (tex-display-shell)) |
85 | 2235 |
2236 (defun tex-bibtex-file () | |
2237 "Run BibTeX on the current buffer's file." | |
2238 (interactive) | |
2239 (if (tex-shell-running) | |
2240 (tex-kill-job) | |
2241 (tex-start-shell)) | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
2242 (let (shell-dirtrack-verbose |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
2243 (tex-out-file |
85 | 2244 (tex-append (file-name-nondirectory (buffer-file-name)) "")) |
2245 (file-dir (file-name-directory (buffer-file-name)))) | |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2246 (tex-send-command tex-shell-cd-command file-dir) |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
2247 (tex-send-command tex-bibtex-command tex-out-file)) |
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
2248 (tex-display-shell)) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2249 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2250 ;;;; |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2251 ;;;; LaTeX indentation |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2252 ;;;; |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2253 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2254 (defvar tex-indent-allhanging t) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2255 (defvar tex-indent-arg 4) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2256 (defvar tex-indent-basic 2) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2257 (defvar tex-indent-item tex-indent-basic) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2258 (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>") |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2259 |
51525
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2260 (defvar tex-latex-indent-syntax-table |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2261 (let ((st (make-syntax-table tex-mode-syntax-table))) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2262 (modify-syntax-entry ?$ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2263 (modify-syntax-entry ?\( "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2264 (modify-syntax-entry ?\) "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2265 st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2266 "Syntax table used while computing indentation.") |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2267 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2268 (defun latex-indent (&optional arg) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2269 (if (and (eq (get-text-property (line-beginning-position) 'face) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2270 tex-verbatim-face)) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2271 'noindent |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2272 (with-syntax-table tex-latex-indent-syntax-table |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2273 ;; TODO: Rather than ignore $, we should try to be more clever about it. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2274 (let ((indent |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2275 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2276 (beginning-of-line) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2277 (latex-find-indent)))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2278 (if (< indent 0) (setq indent 0)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2279 (if (<= (current-column) (current-indentation)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2280 (indent-line-to indent) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2281 (save-excursion (indent-line-to indent))))))) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2282 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2283 (defun latex-find-indent (&optional virtual) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2284 "Find the proper indentation of text after point. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2285 VIRTUAL if non-nil indicates that we're only trying to find the indentation |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2286 in order to determine the indentation of something else. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2287 There might be text before point." |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2288 (save-excursion |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2289 (skip-chars-forward " \t") |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2290 (or |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2291 ;; Stick the first line at column 0. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2292 (and (= (point-min) (line-beginning-position)) 0) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2293 ;; Trust the current indentation, if such info is applicable. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2294 (and virtual (save-excursion (skip-chars-backward " \t&") (bolp)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2295 (current-column)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2296 ;; Stick verbatim environments to the left margin. |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2297 (and (looking-at "\\\\\\(begin\\|end\\) *{\\([^\n}]+\\)") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2298 (member (match-string 2) tex-verbatim-environments) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2299 0) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2300 ;; Put leading close-paren where the matching open brace would be. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2301 (and (eq (latex-syntax-after) ?\)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2302 (ignore-errors |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2303 (save-excursion |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2304 (latex-skip-close-parens) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2305 (latex-backward-sexp-1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2306 (latex-find-indent 'virtual)))) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2307 ;; Default (maybe an argument) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2308 (let ((pos (point)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2309 (char (char-after)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2310 ;; Outdent \item if necessary. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2311 (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2312 up-list-pos) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2313 ;; Find the previous point which determines our current indentation. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2314 (condition-case err |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2315 (progn |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2316 (latex-backward-sexp-1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2317 (while (> (current-column) (current-indentation)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2318 (latex-backward-sexp-1))) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2319 (scan-error |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2320 (setq up-list-pos (nth 2 err)))) |
37952
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2321 (cond |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2322 ((= (point-min) pos) 0) ; We're really just indenting the first line. |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2323 ((integerp up-list-pos) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2324 ;; Have to indent relative to the open-paren. |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2325 (goto-char up-list-pos) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2326 (if (and (not tex-indent-allhanging) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2327 (> pos (progn (latex-down-list) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2328 (forward-comment (point-max)) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2329 (point)))) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2330 ;; Align with the first element after the open-paren. |
37952
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2331 (current-column) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2332 ;; We're the first element after a hanging brace. |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2333 (goto-char up-list-pos) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2334 (+ indent tex-indent-basic (latex-find-indent 'virtual)))) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2335 ;; We're now at the "beginning" of a line. |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2336 ((not (and (not virtual) (eq (char-after) ?\\))) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2337 ;; Nothing particular here: just keep the same indentation. |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2338 (+ indent (current-column))) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2339 ;; We're now looking at a macro call. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2340 ((looking-at tex-indent-item-re) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2341 ;; Indenting relative to an item, have to re-add the outdenting. |
37952
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2342 (+ indent (current-column) tex-indent-item)) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2343 (t |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2344 (let ((col (current-column))) |
53489
e7d6a284bd5a
(latex-find-indent): Avoid error at end of buf.
Richard M. Stallman <rms@gnu.org>
parents:
53185
diff
changeset
|
2345 (if (or (null char) (not (eq (char-syntax char) ?\())) |
37952
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2346 ;; If the first char was not an open-paren, there's |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2347 ;; a risk that this is really not an argument to the |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2348 ;; macro at all. |
53489
e7d6a284bd5a
(latex-find-indent): Avoid error at end of buf.
Richard M. Stallman <rms@gnu.org>
parents:
53185
diff
changeset
|
2349 (+ indent col) |
e7d6a284bd5a
(latex-find-indent): Avoid error at end of buf.
Richard M. Stallman <rms@gnu.org>
parents:
53185
diff
changeset
|
2350 (forward-sexp 1) |
e7d6a284bd5a
(latex-find-indent): Avoid error at end of buf.
Richard M. Stallman <rms@gnu.org>
parents:
53185
diff
changeset
|
2351 (if (< (line-end-position) |
e7d6a284bd5a
(latex-find-indent): Avoid error at end of buf.
Richard M. Stallman <rms@gnu.org>
parents:
53185
diff
changeset
|
2352 (save-excursion (forward-comment (point-max)) |
e7d6a284bd5a
(latex-find-indent): Avoid error at end of buf.
Richard M. Stallman <rms@gnu.org>
parents:
53185
diff
changeset
|
2353 (point))) |
37952
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2354 ;; we're indenting the first argument. |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2355 (min (current-column) (+ tex-indent-arg col)) |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2356 (skip-syntax-forward " ") |
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2357 (current-column)))))))))) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2358 ;;; DocTeX support |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2359 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2360 (defun doctex-font-lock-^^A () |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2361 (if (eq (char-after (line-beginning-position)) ?\%) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2362 (progn |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2363 (put-text-property |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2364 (1- (match-beginning 1)) (match-beginning 1) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2365 'syntax-table |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2366 (if (= (1+ (line-beginning-position)) (match-beginning 1)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2367 ;; The `%' is a single-char comment, which Emacs |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2368 ;; syntax-table can't deal with. We could turn it |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2369 ;; into a non-comment, or use `\n%' or `%^' as the comment. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2370 ;; Instead, we include it in the ^^A comment. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2371 (eval-when-compile (string-to-syntax "< b")) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2372 (eval-when-compile (string-to-syntax ">")))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2373 (let ((end (line-end-position))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2374 (if (< end (point-max)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2375 (put-text-property |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2376 end (1+ end) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2377 'syntax-table |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2378 (eval-when-compile (string-to-syntax "> b"))))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2379 (eval-when-compile (string-to-syntax "< b"))))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2380 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2381 (defun doctex-font-lock-syntactic-face-function (state) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2382 ;; Mark DocTeX documentation, which is parsed as a style A comment |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2383 ;; starting in column 0. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2384 (if (or (nth 3 state) (nth 7 state) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2385 (not (memq (char-before (nth 8 state)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2386 '(?\n nil)))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2387 ;; Anything else is just as for LaTeX. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2388 (tex-font-lock-syntactic-face-function state) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2389 font-lock-doc-face)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2390 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2391 (defvar doctex-font-lock-syntactic-keywords |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2392 (append |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2393 tex-font-lock-syntactic-keywords |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2394 ;; For DocTeX comment-in-doc. |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2395 `(("\\(\\^\\)\\^A" (1 (doctex-font-lock-^^A)))))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2396 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2397 (defvar doctex-font-lock-keywords |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2398 (append tex-font-lock-keywords |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2399 '(("^%<[^>]*>" (0 font-lock-preprocessor-face t))))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2400 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2401 ;;;###autoload |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2402 (define-derived-mode doctex-mode latex-mode "DocTeX" |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2403 "Major mode to edit DocTeX files." |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2404 (setq font-lock-defaults |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2405 (cons (append (car font-lock-defaults) '(doctex-font-lock-keywords)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2406 (mapcar |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2407 (lambda (x) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2408 (case (car-safe x) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2409 (font-lock-syntactic-keywords |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2410 (cons (car x) 'doctex-font-lock-syntactic-keywords)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2411 (font-lock-syntactic-face-function |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2412 (cons (car x) 'doctex-font-lock-syntactic-face-function)) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2413 (t x))) |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2414 (cdr font-lock-defaults))))) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2415 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2416 (run-hooks 'tex-mode-load-hook) |
85 | 2417 |
584 | 2418 (provide 'tex-mode) |
2419 | |
52401 | 2420 ;;; arch-tag: c0a680b1-63aa-4547-84b9-4193c29c0080 |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2421 ;;; tex-mode.el ends here |