Mercurial > emacs
annotate lisp/textmodes/tex-mode.el @ 112453:06719a229a46 default tip
* calc/calc.el (calc-default-power-reference-level)
(calc-default-field-reference-level): New variables.
* calc/calc-units.el (math-standard-units): Add dB and Np.
(math-logunits): New variable.
(math-extract-logunits, math-logcombine, calcFunc-luplus)
(calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level)
(calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New
functions.
(math-find-base-units-rec): Add entry for ln(10).
* calc/calc-help.el (calc-u-prefix-help): Add logarithmic help.
(calc-ul-prefix-help): New function.
* calc/calc-ext.el (calc-init-extensions): Autoload new units
functions. Add keybindings for new units functions.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sun, 23 Jan 2011 23:08:04 -0600 |
parents | d89c2a0d1b12 |
children |
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 |
84674 | 3 ;; Copyright (C) 1985, 1986, 1989, 1992, 1994, 1995, 1996, 1997, 1998 |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
107919
diff
changeset
|
4 ;; 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
84674 | 5 ;; Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
6 |
10215 | 7 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
8 ;; Keywords: tex |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
9 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
10 ;; Contributions over the years by William F. Schelter, Dick King, |
10215 | 11 ;; 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
|
12 |
85 | 13 ;; This file is part of GNU Emacs. |
14 | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92491
diff
changeset
|
15 ;; GNU Emacs is free software: you can redistribute it and/or modify |
85 | 16 ;; it under the terms of the GNU General Public License as published by |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92491
diff
changeset
|
17 ;; the Free Software Foundation, either version 3 of the License, or |
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92491
diff
changeset
|
18 ;; (at your option) any later version. |
85 | 19 |
20 ;; GNU Emacs is distributed in the hope that it will be useful, | |
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 ;; GNU General Public License for more details. | |
24 | |
25 ;; You should have received a copy of the GNU General Public License | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92491
diff
changeset
|
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
85 | 27 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
38083
diff
changeset
|
28 ;;; Commentary: |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
38083
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
30 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
758
diff
changeset
|
31 |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
32 ;; Pacify the byte-compiler |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
33 (eval-when-compile |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
34 (require 'compare-w) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
35 (require 'cl) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
36 (require 'skeleton)) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
37 |
65267
1b1d0bcb5670
(font-lock-comment-face, font-lock-doc-face): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65048
diff
changeset
|
38 (defvar font-lock-comment-face) |
1b1d0bcb5670
(font-lock-comment-face, font-lock-doc-face): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65048
diff
changeset
|
39 (defvar font-lock-doc-face) |
1b1d0bcb5670
(font-lock-comment-face, font-lock-doc-face): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65048
diff
changeset
|
40 |
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
|
41 (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
|
42 (require 'compile) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
43 |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
44 (defgroup tex-file nil |
64060
fa1dc4af6eee
(tex-file, tex-run, tex-view): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63228
diff
changeset
|
45 "TeX files and directories." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
46 :prefix "tex-" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
47 :group 'tex) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
48 |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
49 (defgroup tex-run nil |
64060
fa1dc4af6eee
(tex-file, tex-run, tex-view): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63228
diff
changeset
|
50 "Running external commands from TeX mode." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
51 :prefix "tex-" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
52 :group 'tex) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
53 |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
54 (defgroup tex-view nil |
64060
fa1dc4af6eee
(tex-file, tex-run, tex-view): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63228
diff
changeset
|
55 "Viewing and printing TeX files." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
56 :prefix "tex-" |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
57 :group 'tex) |
85 | 58 |
957 | 59 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
60 (defcustom tex-shell-file-name nil |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
61 "If non-nil, the shell file name to run in the subshell used to run TeX." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
62 :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
|
63 string) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
64 :group 'tex-run) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
65 |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
66 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
67 (defcustom tex-directory (purecopy ".") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
68 "Directory in which temporary files are written. |
7285 | 69 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
|
70 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
|
71 `\\input' commands with relative directories." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
72 :type 'directory |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
73 :group 'tex-file) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
74 |
957 | 75 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
76 (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
|
77 "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
|
78 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
|
79 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
|
80 `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
|
81 :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
|
82 regexp) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
83 :group 'tex-file) |
16777
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
84 |
b655268ba44f
(tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16493
diff
changeset
|
85 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
86 (defcustom tex-main-file nil |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
87 "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
|
88 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
|
89 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
|
90 :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
|
91 file) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
92 :group 'tex-file) |
15916
61e90a3e66aa
(tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15644
diff
changeset
|
93 |
61e90a3e66aa
(tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15644
diff
changeset
|
94 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
95 (defcustom tex-offer-save t |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
96 "If non-nil, ask about saving modified buffers before \\[tex-file] is run." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
97 :type 'boolean |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
98 :group 'tex-file) |
85 | 99 |
957 | 100 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
101 (defcustom tex-run-command (purecopy "tex") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
102 "Command used to run TeX subjob. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
103 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
|
104 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
|
105 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
106 :group 'tex-run) |
85 | 107 |
957 | 108 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
109 (defcustom latex-run-command (purecopy "latex") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
110 "Command used to run LaTeX subjob. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
111 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
|
112 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
|
113 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
114 :group 'tex-run) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
115 |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
116 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
117 (defcustom slitex-run-command (purecopy "slitex") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
118 "Command used to run SliTeX subjob. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
119 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
|
120 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
|
121 :type 'string |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
122 :group 'tex-run) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
123 |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
124 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
125 (defcustom tex-start-options (purecopy "") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
126 "TeX options to use when starting TeX. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 :type 'string |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
131 :group 'tex-run |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59603
diff
changeset
|
132 :version "22.1") |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
133 |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
134 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
135 (defcustom tex-start-commands (purecopy "\\nonstopmode\\input") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
136 "TeX commands to use when starting TeX. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
137 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
|
138 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
|
139 :type '(radio (const :tag "Interactive \(nil\)" nil) |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
140 (const :tag "Nonstop \(\"\\nonstopmode\\input\"\)" |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
141 "\\nonstopmode\\input") |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
142 (string :tag "String at your choice")) |
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
143 :group 'tex-run |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59603
diff
changeset
|
144 :version "22.1") |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
145 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
146 (defvar latex-standard-block-names |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
147 '("abstract" "array" "center" "description" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
148 "displaymath" "document" "enumerate" "eqnarray" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
149 "eqnarray*" "equation" "figure" "figure*" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
150 "flushleft" "flushright" "itemize" "letter" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
151 "list" "minipage" "picture" "quotation" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
152 "quote" "slide" "sloppypar" "tabbing" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
153 "table" "table*" "tabular" "tabular*" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
154 "thebibliography" "theindex*" "titlepage" "trivlist" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
155 "verbatim" "verbatim*" "verse" "math") |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
156 "Standard LaTeX block names.") |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
157 |
957 | 158 ;;;###autoload |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
159 (defcustom latex-block-names nil |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
160 "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
|
161 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
|
162 :type '(repeat string) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
163 :group 'tex-run) |
85 | 164 |
957 | 165 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
166 (defcustom tex-bibtex-command (purecopy "bibtex") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
167 "Command used by `tex-bibtex-file' to gather bibliographic data. |
7285 | 168 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
|
169 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
|
170 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
171 :group 'tex-run) |
85 | 172 |
957 | 173 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
174 (defcustom tex-dvi-print-command (purecopy "lpr -d") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
175 "Command used by \\[tex-print] to print a .dvi file. |
7285 | 176 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
|
177 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
|
178 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
179 :group 'tex-view) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
180 |
957 | 181 ;;;###autoload |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105821
diff
changeset
|
182 (defcustom tex-alt-dvi-print-command (purecopy "lpr -d") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
183 "Command used by \\[tex-print] with a prefix arg to print a .dvi file. |
7285 | 184 If this string contains an asterisk (`*'), that is replaced by the file name; |
185 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
|
186 |
7285 | 187 If two printers are not enough of a choice, you can set the variable |
188 `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
|
189 for example, |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
190 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
191 (setq tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
192 '(format \"lpr -P%s\" (read-string \"Use printer: \"))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
193 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
194 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
|
195 use." |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
196 :type '(choice (string :tag "Command") |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
197 (sexp :tag "Expression")) |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
198 :group 'tex-view) |
85 | 199 |
957 | 200 ;;;###autoload |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
201 (defcustom tex-dvi-view-command |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
202 `(cond |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
203 ((eq window-system 'x) ,(purecopy "xdvi")) |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
204 ((eq window-system 'w32) ,(purecopy "yap")) |
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
205 (t ,(purecopy "dvi2tty * | cat -s"))) |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
206 "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
|
207 If it is a string, that specifies the command directly. |
7285 | 208 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
|
209 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
|
210 |
48170
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
211 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
|
212 :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
|
213 :group 'tex-view) |
85 | 214 |
957 | 215 ;;;###autoload |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
216 (defcustom tex-show-queue-command (purecopy "lpq") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
217 "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
|
218 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
|
219 :type 'string |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
220 :group 'tex-view) |
85 | 221 |
957 | 222 ;;;###autoload |
26270
14dbec3a82b4
(tex-default-mode): Changed to latex-mode.
Gerd Moellmann <gerd@gnu.org>
parents:
25414
diff
changeset
|
223 (defcustom tex-default-mode 'latex-mode |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
224 "Mode to enter for a new file that might be either TeX or LaTeX. |
85 | 225 This variable is used when it can't be determined whether the file |
226 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
|
227 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
|
228 :type 'function |
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
229 :group 'tex) |
85 | 230 |
957 | 231 ;;;###autoload |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
232 (defcustom tex-open-quote (purecopy "``") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
233 "String inserted by typing \\[tex-insert-quote] to open a quotation." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
234 :type 'string |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
235 :options '("``" "\"<" "\"`" "<<" "«") |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
236 :group 'tex) |
85 | 237 |
957 | 238 ;;;###autoload |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105372
diff
changeset
|
239 (defcustom tex-close-quote (purecopy "''") |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
240 "String inserted by typing \\[tex-insert-quote] to close a quotation." |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
241 :type 'string |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
242 :options '("''" "\">" "\"'" ">>" "»") |
17435
b104a6fb7fa3
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16807
diff
changeset
|
243 :group 'tex) |
85 | 244 |
81776 | 245 (defcustom tex-fontify-script t |
246 "If non-nil, fontify subscript and superscript strings." | |
247 :type 'boolean | |
84964
66630159c742
(tex-fontify-script, tex-font-script-display): Add :version tag.
Glenn Morris <rgm@gnu.org>
parents:
84958
diff
changeset
|
248 :group 'tex |
66630159c742
(tex-fontify-script, tex-font-script-display): Add :version tag.
Glenn Morris <rgm@gnu.org>
parents:
84958
diff
changeset
|
249 :version "23.1") |
81776 | 250 (put 'tex-fontify-script 'safe-local-variable 'booleanp) |
251 | |
82341
13d9a34c970a
(tex-font-lock-unfontify-region): Take tex-font-script-display into account.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
252 (defcustom tex-font-script-display '(-0.2 0.2) |
84847
d74a2df235a9
(tex-font-script-display): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84756
diff
changeset
|
253 "How much to lower and raise subscript and superscript content. |
d74a2df235a9
(tex-font-script-display): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84756
diff
changeset
|
254 This is a list of two floats. The first is negative and |
d74a2df235a9
(tex-font-script-display): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84756
diff
changeset
|
255 specifies how much subscript is lowered, the second is positive |
d74a2df235a9
(tex-font-script-display): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84756
diff
changeset
|
256 and specifies how much superscript is raised. Heights are |
d74a2df235a9
(tex-font-script-display): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84756
diff
changeset
|
257 measured relative to that of the normal text." |
81776 | 258 :group 'tex |
82341
13d9a34c970a
(tex-font-lock-unfontify-region): Take tex-font-script-display into account.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
259 :type '(list (float :tag "Subscript") |
84964
66630159c742
(tex-fontify-script, tex-font-script-display): Add :version tag.
Glenn Morris <rgm@gnu.org>
parents:
84958
diff
changeset
|
260 (float :tag "Superscript")) |
66630159c742
(tex-fontify-script, tex-font-script-display): Add :version tag.
Glenn Morris <rgm@gnu.org>
parents:
84958
diff
changeset
|
261 :version "23.1") |
81776 | 262 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
263 (defvar tex-last-temp-file nil |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
264 "Latest temporary file generated by \\[tex-region] and \\[tex-buffer]. |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
265 Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the |
7285 | 266 tex shell terminates.") |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
267 |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
268 (defvar tex-command "tex" |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
269 "*Command to run TeX. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
270 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
|
271 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
|
272 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
|
273 with blanks as separators. |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
274 |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
275 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
|
276 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
|
277 current buffer.") |
85 | 278 |
279 (defvar tex-trailer nil | |
280 "String appended after the end of a region sent to TeX by \\[tex-region].") | |
281 | |
282 (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
|
283 "Regular expression used by \\[tex-region] to find start of file's header.") |
85 | 284 |
285 (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
|
286 "Regular expression used by \\[tex-region] to find end of file's header.") |
85 | 287 |
288 (defvar tex-shell-cd-command "cd" | |
289 "Command to give to shell running TeX to change directory. | |
7285 | 290 The value of `tex-directory' is appended to this, separated by a space.") |
85 | 291 |
292 (defvar tex-zap-file nil | |
293 "Temporary file name used for text being sent as input to TeX. | |
294 Should be a simple file name with no extension or directory specification.") | |
295 | |
296 (defvar tex-last-buffer-texed nil | |
297 "Buffer which was last TeXed.") | |
298 | |
299 (defvar tex-print-file nil | |
300 "File name that \\[tex-print] prints. | |
301 Set by \\[tex-region], \\[tex-buffer], and \\[tex-file].") | |
302 | |
51525
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
303 (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
|
304 (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
|
305 (modify-syntax-entry ?% "<" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
306 (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
|
307 (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
|
308 (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
|
309 (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
|
310 (modify-syntax-entry ?@ "_" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
311 (modify-syntax-entry ?* "_" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
312 (modify-syntax-entry ?\t " " st) |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
313 ;; ~ 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
|
314 ;; 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
|
315 (modify-syntax-entry ?~ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
316 (modify-syntax-entry ?$ "$$" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
317 (modify-syntax-entry ?\\ "/" st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
318 (modify-syntax-entry ?\" "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
319 (modify-syntax-entry ?& "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
320 (modify-syntax-entry ?_ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
321 (modify-syntax-entry ?^ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
322 st) |
85 | 323 "Syntax table used while in TeX mode.") |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
324 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
325 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
326 ;;;; Imenu support |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
327 ;;;; |
85 | 328 |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
329 (defcustom latex-imenu-indent-string ". " |
110494
7c4da622f181
Remove leading `*' from docs of some defcustoms etc.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
330 "String to add repeated in front of nested sectional units for Imenu. |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
331 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
|
332 :type 'string |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
333 :group 'tex) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
334 |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
335 (defvar latex-section-alist |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
336 '(("part" . 0) ("chapter" . 1) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
337 ("section" . 2) ("subsection" . 3) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
338 ("subsubsection" . 4) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
339 ("paragraph" . 5) ("subparagraph" . 6))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
340 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
341 (defvar latex-metasection-list |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
342 '("documentstyle" "documentclass" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
343 "begin{document}" "end{document}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
344 "appendix" "frontmatter" "mainmatter" "backmatter")) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
345 |
15240
21998d33460f
(latex-imenu-create-index):
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
346 (defun latex-imenu-create-index () |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
347 "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
|
348 (let ((section-regexp |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
349 (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
|
350 "\\*?[ \t]*{")) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
351 (metasection-regexp |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
352 (concat "\\\\" (regexp-opt latex-metasection-list t))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
353 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
|
354 (save-excursion |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
355 ;; 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
|
356 ;; 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
|
357 (goto-char (point-min)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
358 (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
|
359 (setq i0 0) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
360 (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
|
361 (setq i0 1) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
362 (setq i0 2))) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
363 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
364 ;; Look for chapters and sections. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
365 (goto-char (point-min)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
366 (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
|
367 (let ((start (match-beginning 0)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
368 (here (point)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
369 (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
|
370 (match-beginning 1) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
371 (match-end 1)) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
372 latex-section-alist)))) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
373 (backward-char 1) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
374 (condition-case err |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
375 (progn |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
376 ;; 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
|
377 ;; titles. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
378 (forward-sexp 1) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
379 (push (cons (concat (apply 'concat |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
380 (make-list |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
381 (max 0 (- i i0)) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
382 latex-imenu-indent-string)) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
383 (buffer-substring-no-properties |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
384 here (1- (point)))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
385 start) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
386 menu)) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
387 (error nil)))) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
388 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
389 ;; Look for included material. |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
390 (goto-char (point-min)) |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
391 (while (search-forward-regexp |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
392 "\\\\\\(include\\|input\\|verbatiminput\\|bibliography\\)\ |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
393 \[ \t]*{\\([^}\n]+\\)}" |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
394 nil t) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
395 (push (cons (concat "<<" (buffer-substring-no-properties |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
396 (match-beginning 2) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
397 (match-end 2)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
398 (if (= (char-after (match-beginning 1)) ?b) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
399 ".bbl" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
400 ".tex")) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
401 (match-beginning 0)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
402 menu)) |
18393
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
403 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
404 ;; 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
|
405 (goto-char (point-min)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
406 (while (search-forward-regexp metasection-regexp nil t) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
407 (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
|
408 |
f34e9defc58c
(latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents:
17435
diff
changeset
|
409 ;; 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
|
410 (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
|
411 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
412 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
413 ;;;; Outline support |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
414 ;;;; |
12704
0b36e50fb5af
(latex-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
11617
diff
changeset
|
415 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
416 (defvar latex-outline-regexp |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
417 (concat "\\\\" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
418 (regexp-opt (append latex-metasection-list |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
419 (mapcar 'car latex-section-alist)) t))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
420 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
421 (defun latex-outline-level () |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
422 (if (looking-at latex-outline-regexp) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
423 (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
|
424 1000)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
425 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
426 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
427 ;;;; Font-Lock support |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
428 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
429 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
430 ;(defvar tex-font-lock-keywords |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
431 ; ;; 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
|
432 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
433 ; 2 font-lock-function-name-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
434 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
435 ; 2 font-lock-constant-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
436 ; ;; 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
|
437 ; ;; not be able to display those fonts. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
438 ; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
439 ; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
440 ; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
441 ; ("^[ \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
|
442 ; ;; 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
|
443 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
444 ; 2 font-lock-function-name-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
445 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
446 ; 2 font-lock-constant-face) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
447 ; ("^[ \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
|
448 ; "\\\\\\([a-zA-Z@]+\\|.\\)" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
449 ; ;; 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
|
450 ; ;; not be able to display those fonts. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
451 ; ;; LaTeX2e: \emph{This is emphasized}. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
452 ; ("\\\\emph{\\([^}]+\\)}" 1 'italic keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
453 ; ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...} |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
454 ; ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
455 ; 3 (if (match-beginning 2) 'bold 'italic) keep) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
456 ; ;; 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
|
457 ; ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
458 ; 3 (if (match-beginning 2) 'bold 'italic) keep)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
459 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
460 ;; 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
|
461 (defconst tex-font-lock-keywords-1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
462 (eval-when-compile |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
463 (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
|
464 (headings (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
465 '("title" "begin" "end" "chapter" "part" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
466 "section" "subsection" "subsubsection" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
467 "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
|
468 "newcommand" "renewcommand" "providecommand" |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
469 "newenvironment" "renewenvironment" |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
470 "newtheorem" "renewtheorem") |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
471 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
472 (variables (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
473 '("newcounter" "newcounter*" "setcounter" "addtocounter" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
474 "setlength" "addtolength" "settowidth") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
475 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
476 (includes (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
477 '("input" "include" "includeonly" "bibliography" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
478 "epsfig" "psfig" "epsf" "nofiles" "usepackage" |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
479 "documentstyle" "documentclass" "verbatiminput" |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
480 "includegraphics" "includegraphics*" |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
481 "url" "nolinkurl") |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
482 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
483 ;; Miscellany. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
484 (slash "\\\\") |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
485 (opt " *\\(\\[[^]]*\\] *\\)*") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
486 ;; This would allow highlighting \newcommand\CMD but requires |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
487 ;; adapting subgroup numbers below. |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
488 ;; (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
|
489 (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)")) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
490 (list |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
491 ;; display $$ math $$ |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
492 ;; 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
|
493 ;; 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
|
494 ;; 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
|
495 ;; 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
|
496 (list "\\$\\$\\([^$]+\\)\\$\\$" 1 'tex-math-face) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
497 ;; Heading args. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
498 (list (concat slash headings "\\*?" opt arg) |
98146 | 499 ;; If ARG ends up matching too much (if the {} don't match, e.g.) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
500 ;; 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
|
501 ;; 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
|
502 ;; 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
|
503 ;; 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
|
504 ;; 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
|
505 ;; 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
|
506 ;; 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
|
507 ;; 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
|
508 ;; 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
|
509 ;; 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
|
510 ;; have a comment in ARG. |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
511 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
|
512 (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
|
513 1 'font-lock-function-name-face 'keep) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
514 ;; Variable args. |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
515 (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
|
516 ;; Include args. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
517 (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
|
518 ;; Definitions. I think. |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
519 '("^[ \t]*\\\\def *\\\\\\(\\(\\w\\|@\\)+\\)" |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
520 1 font-lock-function-name-face)))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
521 "Subdued expressions to highlight in TeX modes.") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
522 |
57415
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
523 (defun tex-font-lock-append-prop (prop) |
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
524 (unless (memq (get-text-property (match-end 1) 'face) |
65683
b8bdecc9aa11
(tex-font-lock-append-prop, tex-font-lock-suscript, tex-insert-quote)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65315
diff
changeset
|
525 '(font-lock-comment-face tex-verbatim)) |
57415
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
526 prop)) |
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
527 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
528 (defconst tex-font-lock-keywords-2 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
529 (append tex-font-lock-keywords-1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
530 (eval-when-compile |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
531 (let* (;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
532 ;; 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
|
533 (bold (regexp-opt '("textbf" "textsc" "textup" |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
534 "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
|
535 (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
|
536 ;; 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
|
537 ;; (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
|
538 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
539 ;; 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
|
540 (citations (regexp-opt |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
541 '("label" "ref" "pageref" "vref" "eqref" |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
542 "cite" "nocite" "index" "glossary" "bibitem" |
80888
4005ed72ef83
(tex-font-lock-keywords-2): Add citet and citep
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
543 ;; natbib's two variants of \cite: |
4005ed72ef83
(tex-font-lock-keywords-2): Add citet and citep
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
544 "citep" "citet" |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
545 ;; 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
|
546 ;; "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
|
547 ) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
548 t)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
549 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
550 ;; 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
|
551 (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
|
552 (specials-2 (regexp-opt |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
553 '("linebreak" "nolinebreak" "pagebreak" "nopagebreak" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
554 "newline" "newpage" "clearpage" "cleardoublepage" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
555 "displaybreak" "allowdisplaybreaks" |
7acf4e4617be
(tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents:
38412
diff
changeset
|
556 "enlargethispage") t)) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
557 (general "\\([a-zA-Z@]+\\**\\|[^ \t\n]\\)") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
558 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
559 ;; Miscellany. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
560 (slash "\\\\") |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
561 (opt " *\\(\\[[^]]*\\] *\\)*") |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
562 (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
|
563 (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)")) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
564 (list |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
565 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
566 ;; Citation args. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
567 (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
|
568 ;; |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
569 ;; Text between `` quotes ''. |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
570 (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
|
571 "[^'\">{]+" ;a bit pessimistic |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
572 (regexp-opt `("''" "\">" "\"'" ">>" "»") t)) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
573 'font-lock-string-face) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
574 ;; |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
575 ;; 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
|
576 (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
|
577 (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
|
578 1 'font-lock-warning-face) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
579 (concat slash general) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
580 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
581 ;; 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
|
582 ;; since we might not be able to display those fonts. |
57415
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
583 (list (concat slash bold " *" arg) 2 |
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
584 '(tex-font-lock-append-prop 'bold) 'append) |
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
585 (list (concat slash italic " *" arg) 2 |
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
586 '(tex-font-lock-append-prop '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
|
587 ;; (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
|
588 ;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
589 ;; 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
|
590 (list (concat "\\\\\\(em\\|it\\|sl\\)\\>" args) |
57415
fdd8f0d7c67d
(tex-font-lock-append-prop): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57304
diff
changeset
|
591 2 '(tex-font-lock-append-prop 'italic) 'append) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
592 ;; 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
|
593 ;; {\em foo {\bf bar} bla} where both match. |
66154
cdd77b8367b9
(tex-font-lock-keywords-2): Undo prev change.
Richard M. Stallman <rms@gnu.org>
parents:
66097
diff
changeset
|
594 (list (concat "\\\\\\(bf\\(series\\)?\\)\\>" args) |
65969
cd4113a86403
(tex-font-lock-keywords-2): Adjust match number.
Andreas Schwab <schwab@suse.de>
parents:
65839
diff
changeset
|
595 3 '(tex-font-lock-append-prop 'bold) 'append))))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
596 "Gaudy expressions to highlight in TeX modes.") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
597 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
598 (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
|
599 (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
|
600 '(font-lock-constant-face font-lock-builtin-face |
65683
b8bdecc9aa11
(tex-font-lock-append-prop, tex-font-lock-suscript, tex-insert-quote)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65315
diff
changeset
|
601 font-lock-comment-face tex-verbatim)) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
602 ;; 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
|
603 (let ((odd nil) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
604 (pos pos)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
605 (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
|
606 (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
|
607 odd)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
608 (if (eq (char-after pos) ?_) |
81776 | 609 `(face subscript display (raise ,(car tex-font-script-display))) |
82341
13d9a34c970a
(tex-font-lock-unfontify-region): Take tex-font-script-display into account.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
610 `(face superscript display (raise ,(cadr tex-font-script-display)))))) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
611 |
70048
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
612 (defun tex-font-lock-match-suscript (limit) |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
613 "Match subscript and superscript patterns up to LIMIT." |
81776 | 614 (when (and tex-fontify-script |
615 (re-search-forward "[_^] *\\([^\n\\{}]\\|\ | |
616 \\\\\\([a-zA-Z@]+\\|[^ \t\n]\\)\\|\\({\\)\\)" limit t)) | |
70048
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
617 (when (match-end 3) |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
618 (let ((beg (match-beginning 3)) |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
619 (end (save-restriction |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
620 (narrow-to-region (point-min) limit) |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
621 (condition-case nil (scan-lists (point) 1 1) (error nil))))) |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
622 (store-match-data (if end |
70050
5fd821256f0d
(tex-font-lock-match-suscript): Paren typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70048
diff
changeset
|
623 (list (match-beginning 0) end beg end) |
5fd821256f0d
(tex-font-lock-match-suscript): Paren typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70048
diff
changeset
|
624 (list beg beg beg beg))))) |
70048
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
625 t)) |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
626 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
627 (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
|
628 (append tex-font-lock-keywords-2 |
70048
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
629 '((tex-font-lock-match-suscript |
80049d479c75
(tex-font-lock-match-suscript): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68648
diff
changeset
|
630 (1 (tex-font-lock-suscript (match-beginning 0)) append)))) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
631 "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
|
632 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
633 (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
|
634 "Default expressions to highlight in TeX modes.") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
635 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
636 (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
|
637 '("verbatim" "verbatim*")) |
81912
82e8a862c00b
(tex-verbatim-environments): Add safe-local-variable property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81776
diff
changeset
|
638 (put 'tex-verbatim-environments 'safe-local-variable |
84627
2b86b3a54870
(tex-verbatim-environments): Eliminate CL dependency.
Richard M. Stallman <rms@gnu.org>
parents:
84620
diff
changeset
|
639 (lambda (x) (null (delq t (mapcar 'stringp x))))) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
640 |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
641 (eval-when-compile |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
642 (defconst tex-syntax-propertize-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
643 (syntax-propertize-precompile-rules |
81912
82e8a862c00b
(tex-verbatim-environments): Add safe-local-variable property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81776
diff
changeset
|
644 ("\\\\verb\\**\\([^a-z@*]\\)" |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
645 (1 (prog1 "\"" |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
646 (tex-font-lock-verb |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
647 (match-beginning 0) (char-after (match-beginning 1)))))))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
648 |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
649 (defconst latex-syntax-propertize-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
650 (syntax-propertize-precompile-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
651 tex-syntax-propertize-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
652 ("\\\\\\(?:end\\|begin\\) *\\({[^\n{}]*}\\)" |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
653 (1 (ignore |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
654 (tex-env-mark (match-beginning 0) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
655 (match-beginning 1) (match-end 1)))))))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
656 |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
657 (defun tex-env-mark (cmd start end) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
658 (when (= cmd (line-beginning-position)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
659 (let ((arg (buffer-substring-no-properties (1+ start) (1- end)))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
660 (when (member arg tex-verbatim-environments) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
661 (if (eq ?b (char-after (1+ cmd))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
662 ;; \begin |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
663 (put-text-property (line-end-position) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
664 (line-beginning-position 2) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
665 'syntax-table (string-to-syntax "< c")) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
666 ;; In the case of an empty verbatim env, the \n after the \begin is |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
667 ;; the same as the \n before the \end. Lucky for us, the "> c" |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
668 ;; property associated to the \end will be placed afterwards, so it |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
669 ;; will override the "< c". |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
670 (put-text-property (1- cmd) cmd |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
671 'syntax-table (string-to-syntax "> c")) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
672 ;; The text between \end{verbatim} and \n is ignored, so we'll treat |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
673 ;; it as a comment. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
674 (put-text-property end (min (1+ end) (line-end-position)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
675 'syntax-table (string-to-syntax "<")))))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
676 ;; Mark env args for possible electric pairing. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
677 (unless (get-char-property (1+ start) 'text-clones) ;Already paired-up. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
678 (put-text-property start end 'latex-env-pair t))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
679 |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
680 (define-minor-mode latex-electric-env-pair-mode |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
681 "Automatically update the \\end arg when editing the \\begin one. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
682 And vice-versa." |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
683 :lighter "/e" |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
684 (if latex-electric-env-pair-mode |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
685 (add-hook 'before-change-functions |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
686 #'latex-env-before-change nil 'local) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
687 (remove-hook 'before-change-functions |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
688 #'latex-env-before-change 'local))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
689 |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
690 (defun latex-env-before-change (start end) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
691 (when (get-text-property start 'latex-env-pair) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
692 (condition-case err |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
693 (with-silent-modifications |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
694 ;; Remove properties even if don't find a pair. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
695 (remove-text-properties |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
696 (previous-single-property-change (1+ start) 'latex-env-pair) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
697 (next-single-property-change start 'latex-env-pair) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
698 '(latex-env-pair)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
699 (unless (or (get-char-property start 'text-clones) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
700 (get-char-property (1+ start) 'text-clones) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
701 (save-excursion |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
702 (goto-char start) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
703 (not (re-search-backward |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
704 "\\\\\\(?:end\\|begi\\(n\\)\\) *{" |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
705 (line-beginning-position) t)))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
706 (let ((cmd-start (match-beginning 0)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
707 (type (match-end 1)) ;nil for \end, else \begin. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
708 (arg-start (1- (match-end 0)))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
709 (save-excursion |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
710 (goto-char (match-end 0)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
711 (when (and (looking-at "[^\n{}]*}") |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
712 (> (match-end 0) end)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
713 (let ((arg-end (match-end 0))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
714 (if (null type) ;\end |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
715 (progn (goto-char arg-end) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
716 (latex-forward-sexp -1) (forward-word 1)) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
717 (goto-char cmd-start) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
718 (latex-forward-sexp 1) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
719 (let (forward-sexp-function) (backward-sexp))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
720 (when (looking-at |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
721 (regexp-quote (buffer-substring arg-start arg-end))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
722 (text-clone-create arg-start arg-end)))))))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
723 (scan-error nil) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
724 (error (message "Error in latex-env-before-change: %s" err))))) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
725 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
726 (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
|
727 (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
|
728 (while (< beg end) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
729 (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
|
730 (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
|
731 (if (and (eq (car-safe prop) 'raise) |
82341
13d9a34c970a
(tex-font-lock-unfontify-region): Take tex-font-script-display into account.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
732 (member (car-safe (cdr prop)) tex-font-script-display) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
733 (null (cddr prop))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
734 (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
|
735 (setq beg next)))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
736 |
84958
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
737 (defcustom tex-suscript-height-ratio 0.8 |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
738 "Ratio of subscript/superscript height to that of the preceding text. |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
739 In nested subscript/superscript, this factor is applied repeatedly, |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
740 subject to the limit set by `tex-suscript-height-minimum'." |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
741 :type 'float |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
742 :group 'tex |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
743 :version "23.1") |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
744 |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
745 (defcustom tex-suscript-height-minimum 0.0 |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
746 "Integer or float limiting the minimum size of subscript/superscript text. |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
747 An integer is an absolute height in units of 1/10 point, a float |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
748 is a height relative to that of the default font. Zero means no minimum." |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
749 :type '(choice (integer :tag "Integer height in 1/10 point units") |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
750 (float :tag "Fraction of default font height")) |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
751 :group 'tex |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
752 :version "23.1") |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
753 |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
754 (defun tex-suscript-height (height) |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
755 "Return the integer height of subscript/superscript font in 1/10 points. |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
756 Not smaller than the value set by `tex-suscript-height-minimum'." |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
757 (ceiling (max (if (integerp tex-suscript-height-minimum) |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
758 tex-suscript-height-minimum |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
759 ;; For bootstrapping. |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
760 (condition-case nil |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
761 (* tex-suscript-height-minimum |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
762 (face-attribute 'default :height)) |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
763 (error 0))) |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
764 ;; NB assumes height is integer. |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
765 (* height tex-suscript-height-ratio)))) |
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
766 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
767 (defface superscript |
84958
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
768 '((t :height tex-suscript-height)) ;; :raise 0.2 |
62811
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
769 "Face used for superscripts." |
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
770 :group 'tex) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
771 (defface subscript |
84958
ca3cf0871ecb
(tex-suscript-height-ratio, tex-suscript-height-minimum): New
Glenn Morris <rgm@gnu.org>
parents:
84847
diff
changeset
|
772 '((t :height tex-suscript-height)) ;; :raise -0.2 |
62811
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
773 "Face used for subscripts." |
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
774 :group 'tex) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
775 |
63228
1cde198ddda6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392
Miles Bader <miles@gnu.org>
parents:
63101
diff
changeset
|
776 (defface tex-math |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
777 '((t :inherit font-lock-string-face)) |
62811
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
778 "Face used to highlight TeX math expressions." |
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
779 :group 'tex) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104543
diff
changeset
|
780 (define-obsolete-face-alias 'tex-math-face 'tex-math "22.1") |
63228
1cde198ddda6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392
Miles Bader <miles@gnu.org>
parents:
63101
diff
changeset
|
781 (defvar tex-math-face 'tex-math) |
1cde198ddda6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392
Miles Bader <miles@gnu.org>
parents:
63101
diff
changeset
|
782 |
1cde198ddda6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392
Miles Bader <miles@gnu.org>
parents:
63101
diff
changeset
|
783 (defface tex-verbatim |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
784 ;; '((t :inherit font-lock-string-face)) |
99144
b7eb74a4d86b
* faces.el (face-font-family-alternatives): Add "CMU Typewriter Text"
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
98341
diff
changeset
|
785 '((t :family "courier")) |
62811
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
786 "Face used to highlight TeX verbatim environments." |
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
787 :group 'tex) |
104778
afa0e028ba97
Mark face aliases with "-face" suffix as obsolete.
Glenn Morris <rgm@gnu.org>
parents:
104543
diff
changeset
|
788 (define-obsolete-face-alias 'tex-verbatim-face 'tex-verbatim "22.1") |
63228
1cde198ddda6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392
Miles Bader <miles@gnu.org>
parents:
63101
diff
changeset
|
789 (defvar tex-verbatim-face 'tex-verbatim) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
790 |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
791 (defun tex-font-lock-verb (start delim) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
792 "Place syntax table properties on the \verb construct. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
793 START is the position of the \\ and DELIM is the delimiter char." |
112350
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
794 ;; Do nothing if the \verb construct is itself inside a comment or |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
795 ;; verbatim env. |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
796 (unless (nth 8 (save-excursion (syntax-ppss start))) |
112350
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
797 ;; Let's find the end and mark it. |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
798 (let ((afterdelim (point))) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
799 (skip-chars-forward (string ?^ delim) (line-end-position)) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
800 (if (eolp) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
801 ;; "LaTeX Error: \verb ended by end of line." |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
802 ;; Remove the syntax-table property we've just put on the |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
803 ;; start-delimiter, so it doesn't spill over subsequent lines. |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
804 (put-text-property (1- afterdelim) afterdelim |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
805 'syntax-table nil) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
806 (when (eq (char-syntax (preceding-char)) ?/) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
807 (put-text-property (1- (point)) (point) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
808 'syntax-table (string-to-syntax "."))) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
809 (put-text-property (point) (1+ (point)) |
d89c2a0d1b12
* lisp/textmodes/tex-mode.el (tex-font-lock-verb): Make sure \verb
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
112278
diff
changeset
|
810 'syntax-table (string-to-syntax "\"")))))) |
65839
8d9f98ffeae4
(tex-font-lock-syntactic-face-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65706
diff
changeset
|
811 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
812 ;; 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
|
813 (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
|
814 (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
|
815 (cond |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
816 ((not char) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
817 (if (eq 2 (nth 7 state)) tex-verbatim-face font-lock-comment-face)) |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
818 ((eq char ?$) tex-math-face) |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
819 ;; A \verb element. |
65839
8d9f98ffeae4
(tex-font-lock-syntactic-face-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65706
diff
changeset
|
820 (t tex-verbatim-face)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
821 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
822 |
85 | 823 (defun tex-define-common-keys (keymap) |
7285 | 824 "Define the keys that we want defined both in TeX mode and in the TeX shell." |
85 | 825 (define-key keymap "\C-c\C-k" 'tex-kill-job) |
826 (define-key keymap "\C-c\C-l" 'tex-recenter-output-buffer) | |
827 (define-key keymap "\C-c\C-q" 'tex-show-print-queue) | |
828 (define-key keymap "\C-c\C-p" 'tex-print) | |
829 (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
|
830 |
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
831 (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
|
832 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
833 (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
|
834 '(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
|
835 (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
|
836 '(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
|
837 :enable (get-buffer "*tex-shell*"))) |
4900
be43750c20d2
(tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents:
4768
diff
changeset
|
838 (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
|
839 '("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
|
840 (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
|
841 '(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
|
842 :enable (stringp tex-print-file))) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
843 (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
|
844 '(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
|
845 (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
|
846 '(menu-item "Tex View" tex-view :enable (stringp tex-print-file)))) |
85 | 847 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
848 (defvar tex-mode-map |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
849 (let ((map (make-sparse-keymap))) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
850 (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
|
851 (tex-define-common-keys map) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
852 (define-key map "\"" 'tex-insert-quote) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
853 (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
|
854 (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
|
855 (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
|
856 (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
|
857 (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
|
858 (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
|
859 (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
|
860 (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
|
861 (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
|
862 (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
|
863 (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
|
864 (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
|
865 (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
|
866 (define-key map "\C-c\C-o" 'latex-insert-block) |
108541
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
107919
diff
changeset
|
867 |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
107919
diff
changeset
|
868 ;; Redundant keybindings, for consistency with SGML mode. |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
107919
diff
changeset
|
869 (define-key map "\C-c\C-t" 'latex-insert-block) |
111128
d38d192ed185
Bind "C-c ]" to block-closing commands in several modes.
Chong Yidong <cyd@stupidchicken.com>
parents:
110494
diff
changeset
|
870 (define-key map "\C-c]" 'latex-close-block) |
108541
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
107919
diff
changeset
|
871 (define-key map "\C-c/" 'latex-close-block) |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
107919
diff
changeset
|
872 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
873 (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
|
874 (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
|
875 (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
|
876 (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
|
877 (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
|
878 '("BibTeX File" . tex-bibtex-file)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
879 (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
|
880 '(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
|
881 (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
|
882 '("Validate Buffer" . tex-validate-buffer)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
883 (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
|
884 '(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
|
885 (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
|
886 '("TeX Buffer" . tex-buffer)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
887 (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
|
888 map) |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
889 "Keymap shared by TeX modes.") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
890 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
891 (defvar latex-mode-map |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
892 (let ((map (make-sparse-keymap))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
893 (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
|
894 (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
|
895 map) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
896 "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
|
897 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
898 (defvar plain-tex-mode-map |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
899 (let ((map (make-sparse-keymap))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
900 (set-keymap-parent map tex-mode-map) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
901 map) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
902 "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
|
903 |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
904 (defvar tex-shell-map |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
905 (let ((m (make-sparse-keymap))) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
906 (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
|
907 (tex-define-common-keys m) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
908 m) |
7285 | 909 "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
|
910 Inherits `shell-mode-map' with a few additions.") |
85 | 911 |
14383
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
912 (defvar tex-face-alist |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
913 '((bold . "{\\bf ") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
914 (italic . "{\\it ") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
915 (bold-italic . "{\\bi ") ; hypothetical |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
916 (underline . "\\underline{") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
917 (default . "{\\rm ")) |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
918 "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
|
919 |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
920 (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
|
921 `((italic . "{\\em ") |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
922 ,@tex-face-alist) |
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
923 "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
|
924 |
105821
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
925 (defun tex-facemenu-add-face-function (face end) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
926 (or (cdr (assq face tex-face-alist)) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
927 (or (and (consp face) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
928 (consp (car face)) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
929 (null (cdr face)) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
930 (eq major-mode 'latex-mode) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
931 ;; This actually requires the `color' LaTeX package. |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
932 (cond ((eq (caar face) :foreground) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
933 (format "{\\color{%s} " (cadr (car face)))) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
934 ((eq (caar face) :background) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
935 (format "\\colorbox{%s}{" (cadr (car face)))))) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
936 (error "Face %s not configured for %s mode" face mode-name)))) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
937 |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
938 ;; 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
|
939 ;; 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
|
940 (defun tex-guess-mode () |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
941 (let ((mode tex-default-mode) slash comment) |
85 | 942 (save-excursion |
943 (goto-char (point-min)) | |
944 (while (and (setq slash (search-forward "\\" nil t)) | |
945 (setq comment (let ((search-end (point))) | |
946 (save-excursion | |
947 (beginning-of-line) | |
948 (search-forward "%" search-end t)))))) | |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
949 (when (and slash (not comment)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
950 (setq mode |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
951 (if (looking-at |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
952 (eval-when-compile |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
953 (concat |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
954 (regexp-opt '("documentstyle" "documentclass" |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
955 "begin" "subsection" "section" |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
956 "part" "chapter" "newcommand" |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
957 "renewcommand" "RequirePackage") 'words) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
958 "\\|NeedsTeXFormat{LaTeX"))) |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
959 (if (and (looking-at |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
960 "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}") |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
961 ;; SliTeX is almost never used any more nowadays. |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
962 (tex-executable-exists-p slitex-run-command)) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
963 'slitex-mode |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
964 'latex-mode) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
965 'plain-tex-mode)))) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
966 (funcall mode))) |
2598
2189edb30955
Removed spurious comment (obsoleted by ;;;###autoload).
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2588
diff
changeset
|
967 |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
968 ;; `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
|
969 ;; 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
|
970 ;; 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
|
971 ;; 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
|
972 (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
|
973 (tex-common-initialization)) |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
974 ;; 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
|
975 ;; 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
|
976 ;; `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
|
977 ;; 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
|
978 ;; proper docstring. |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
979 (defalias 'tex-mode-internal (symbol-function 'tex-mode)) |
92491
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
980 |
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
981 ;; Suppress the byte-compiler warning about multiple definitions. |
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
982 ;; This is a) ugly, and b) cheating, but this was the last |
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
983 ;; remaining warning from byte-compiling all of Emacs... |
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
984 (eval-when-compile |
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
985 (setq byte-compile-function-environment |
107155 | 986 (delq (assq 'tex-mode byte-compile-function-environment) |
987 byte-compile-function-environment))) | |
92491
55f5bb0c4d4e
(tex-mode): Suppress warning about multiple definitions when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92459
diff
changeset
|
988 |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
989 ;;;###autoload |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
990 (defun tex-mode () |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
991 "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
|
992 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
|
993 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
|
994 `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
|
995 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
|
996 says which mode to use." |
50943
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
997 (interactive) |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
998 (if delay-mode-hooks |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
999 ;; 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
|
1000 (tex-mode-internal) |
654c1513e74a
(tex-mode-syntax-table): ~ is not whitespace.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50592
diff
changeset
|
1001 (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
|
1002 |
61770
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1003 ;; The following three autoloaded aliases appear to conflict with |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1004 ;; AUCTeX. However, even though AUCTeX uses the mixed case variants |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1005 ;; for all mode relevant variables and hooks, the invocation function |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1006 ;; and setting of `major-mode' themselves need to be lowercase for |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1007 ;; AUCTeX to provide a fully functional user-level replacement. So |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1008 ;; these aliases should remain as they are, in particular since AUCTeX |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1009 ;; users are likely to use them. |
18224d5c1322
(TeX-mode, plain-TeX-mode, LaTeX-mode):
David Kastrup <dak@gnu.org>
parents:
61353
diff
changeset
|
1010 |
269 | 1011 ;;;###autoload |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
1012 (defalias 'TeX-mode 'tex-mode) |
269 | 1013 ;;;###autoload |
24330
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
1014 (defalias 'plain-TeX-mode 'plain-tex-mode) |
fee8d10bbb21
(tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents:
24273
diff
changeset
|
1015 ;;;###autoload |
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
1016 (defalias 'LaTeX-mode 'latex-mode) |
85 | 1017 |
256 | 1018 ;;;###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
|
1019 (define-derived-mode plain-tex-mode tex-mode "TeX" |
85 | 1020 "Major mode for editing files of input for plain TeX. |
1021 Makes $ and } display the characters they match. | |
1022 Makes \" insert `` when it seems to be the beginning of a quotation, | |
1023 and '' when it appears to be the end; it inserts \" only after a \\. | |
1024 | |
1025 Use \\[tex-region] to run TeX on the current region, plus a \"header\" | |
1026 copied from the top of the file (containing macro definitions, etc.), | |
1027 running TeX under a special subshell. \\[tex-buffer] does the whole buffer. | |
1028 \\[tex-file] saves the buffer and then processes the file. | |
1029 \\[tex-print] prints the .dvi file made by any of these. | |
1030 \\[tex-view] previews the .dvi file made by any of these. | |
1031 \\[tex-bibtex-file] runs bibtex on the file of the current buffer. | |
1032 | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1033 Use \\[tex-validate-buffer] to check buffer for paragraphs containing |
85 | 1034 mismatched $'s or braces. |
1035 | |
1036 Special commands: | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1037 \\{plain-tex-mode-map} |
85 | 1038 |
1039 Mode variables: | |
1040 tex-run-command | |
1041 Command string used by \\[tex-region] or \\[tex-buffer]. | |
1042 tex-directory | |
1043 Directory in which to create temporary files for TeX jobs | |
1044 run by \\[tex-region] or \\[tex-buffer]. | |
1045 tex-dvi-print-command | |
1046 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
|
1047 tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1048 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
|
1049 argument) to print a .dvi file. |
85 | 1050 tex-dvi-view-command |
1051 Command string used by \\[tex-view] to preview a .dvi file. | |
1052 tex-show-queue-command | |
1053 Command string used by \\[tex-show-print-queue] to show the print | |
1054 queue that \\[tex-print] put your job on. | |
1055 | |
7285 | 1056 Entering Plain-tex mode runs the hook `text-mode-hook', then the hook |
1057 `tex-mode-hook', and finally the hook `plain-tex-mode-hook'. When the | |
1058 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
|
1059 (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
|
1060 (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
|
1061 (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
|
1062 (set (make-local-variable 'tex-trailer) "\\bye\n")) |
85 | 1063 |
256 | 1064 ;;;###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
|
1065 (define-derived-mode latex-mode tex-mode "LaTeX" |
85 | 1066 "Major mode for editing files of input for LaTeX. |
1067 Makes $ and } display the characters they match. | |
1068 Makes \" insert `` when it seems to be the beginning of a quotation, | |
1069 and '' when it appears to be the end; it inserts \" only after a \\. | |
1070 | |
1071 Use \\[tex-region] to run LaTeX on the current region, plus the preamble | |
1072 copied from the top of the file (containing \\documentstyle, etc.), | |
1073 running LaTeX under a special subshell. \\[tex-buffer] does the whole buffer. | |
1074 \\[tex-file] saves the buffer and then processes the file. | |
1075 \\[tex-print] prints the .dvi file made by any of these. | |
1076 \\[tex-view] previews the .dvi file made by any of these. | |
1077 \\[tex-bibtex-file] runs bibtex on the file of the current buffer. | |
1078 | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1079 Use \\[tex-validate-buffer] to check buffer for paragraphs containing |
85 | 1080 mismatched $'s or braces. |
1081 | |
1082 Special commands: | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1083 \\{latex-mode-map} |
85 | 1084 |
1085 Mode variables: | |
1086 latex-run-command | |
1087 Command string used by \\[tex-region] or \\[tex-buffer]. | |
1088 tex-directory | |
1089 Directory in which to create temporary files for LaTeX jobs | |
1090 run by \\[tex-region] or \\[tex-buffer]. | |
1091 tex-dvi-print-command | |
1092 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
|
1093 tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1094 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
|
1095 argument) to print a .dvi file. |
85 | 1096 tex-dvi-view-command |
1097 Command string used by \\[tex-view] to preview a .dvi file. | |
1098 tex-show-queue-command | |
1099 Command string used by \\[tex-show-print-queue] to show the print | |
1100 queue that \\[tex-print] put your job on. | |
1101 | |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1102 Entering Latex mode runs the hook `text-mode-hook', then |
7285 | 1103 `tex-mode-hook', and finally `latex-mode-hook'. When the special |
1104 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
|
1105 (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
|
1106 (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
|
1107 "\\\\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
|
1108 (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
|
1109 (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
|
1110 ;; 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
|
1111 ;; 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
|
1112 ;; 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
|
1113 (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
|
1114 (concat "[ \t]*\\(\\$\\$\\|" |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1115 "\\\\[][]\\|" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1116 "\\\\" (regexp-opt (append |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1117 (mapcar 'car latex-section-alist) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1118 '("begin" "label" "end" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1119 "item" "bibitem" "newline" "noindent" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1120 "newpage" "footnote" "marginpar" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1121 "parbox" "caption")) t) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1122 "\\>\\|\\\\[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
|
1123 "\\>\\)")) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1124 (setq paragraph-separate |
107919
335c3f4127c4
Revert 2008-03-03 change (Bug#5821).
Chong Yidong <cyd@stupidchicken.com>
parents:
107155
diff
changeset
|
1125 (concat "[\f%]\\|[ \t]*\\($\\|" |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1126 "\\\\[][]\\|" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1127 "\\\\" (regexp-opt (append |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1128 (mapcar 'car latex-section-alist) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1129 '("begin" "label" "end" )) t) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1130 "\\>\\|\\\\\\(" (regexp-opt '("item" "bibitem" "newline" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1131 "noindent" "newpage" "footnote" |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1132 "marginpar" "parbox" "caption")) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1133 "\\|\\$\\$\\|[a-z]*\\(space\\|skip\\|page[a-z]*\\)" |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1134 "\\>\\)[ \t]*\\($\\|%\\)\\)")) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1135 (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
|
1136 'latex-imenu-create-index) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1137 (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
|
1138 (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
|
1139 (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
|
1140 (set (make-local-variable 'fill-indent-according-to-mode) t) |
106484
fbf8c0853c94
(latex-complete, latex-indent-or-complete): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106134
diff
changeset
|
1141 (add-hook 'completion-at-point-functions |
fbf8c0853c94
(latex-complete, latex-indent-or-complete): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106134
diff
changeset
|
1142 'latex-complete-data nil 'local) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1143 (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
|
1144 (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
|
1145 (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
|
1146 (set (make-local-variable 'skeleton-end-hook) nil)) |
85 | 1147 |
4768
9d84105b1248
(slitex-mode): Add ###autoload magic cookie.
Brian Fox <bfox@gnu.org>
parents:
4376
diff
changeset
|
1148 ;;;###autoload |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1149 (define-derived-mode slitex-mode latex-mode "SliTeX" |
85 | 1150 "Major mode for editing files of input for SliTeX. |
1151 Makes $ and } display the characters they match. | |
1152 Makes \" insert `` when it seems to be the beginning of a quotation, | |
1153 and '' when it appears to be the end; it inserts \" only after a \\. | |
1154 | |
1155 Use \\[tex-region] to run SliTeX on the current region, plus the preamble | |
1156 copied from the top of the file (containing \\documentstyle, etc.), | |
1157 running SliTeX under a special subshell. \\[tex-buffer] does the whole buffer. | |
1158 \\[tex-file] saves the buffer and then processes the file. | |
1159 \\[tex-print] prints the .dvi file made by any of these. | |
1160 \\[tex-view] previews the .dvi file made by any of these. | |
1161 \\[tex-bibtex-file] runs bibtex on the file of the current buffer. | |
1162 | |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1163 Use \\[tex-validate-buffer] to check buffer for paragraphs containing |
85 | 1164 mismatched $'s or braces. |
1165 | |
1166 Special commands: | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1167 \\{slitex-mode-map} |
85 | 1168 |
1169 Mode variables: | |
1170 slitex-run-command | |
1171 Command string used by \\[tex-region] or \\[tex-buffer]. | |
1172 tex-directory | |
1173 Directory in which to create temporary files for SliTeX jobs | |
1174 run by \\[tex-region] or \\[tex-buffer]. | |
1175 tex-dvi-print-command | |
1176 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
|
1177 tex-alt-dvi-print-command |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1178 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
|
1179 argument) to print a .dvi file. |
85 | 1180 tex-dvi-view-command |
1181 Command string used by \\[tex-view] to preview a .dvi file. | |
1182 tex-show-queue-command | |
1183 Command string used by \\[tex-show-print-queue] to show the print | |
1184 queue that \\[tex-print] put your job on. | |
1185 | |
7285 | 1186 Entering SliTeX mode runs the hook `text-mode-hook', then the hook |
1187 `tex-mode-hook', then the hook `latex-mode-hook', and finally the hook | |
1188 `slitex-mode-hook'. When the special subshell is initiated, the hook | |
1189 `tex-shell-hook' is run." | |
85 | 1190 (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
|
1191 (setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}")) |
85 | 1192 |
1193 (defun tex-common-initialization () | |
18587
3290767e31d8
(tex-common-initialization):
Richard M. Stallman <rms@gnu.org>
parents:
18393
diff
changeset
|
1194 ;; 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
|
1195 (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
|
1196 ;; 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
|
1197 (set (make-local-variable 'paragraph-start) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1198 "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$") |
5425
3dd5ff54e1cd
(slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents:
5262
diff
changeset
|
1199 ;; 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
|
1200 ;; 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
|
1201 (set (make-local-variable 'paragraph-separate) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1202 "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$") |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1203 (set (make-local-variable 'comment-start) "%") |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1204 (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
|
1205 (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
|
1206 "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+ *\\)") |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1207 (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
|
1208 (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
|
1209 'tex-categorize-whitespace) |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1210 (set (make-local-variable 'facemenu-add-face-function) |
105821
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105813
diff
changeset
|
1211 'tex-facemenu-add-face-function) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1212 (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
|
1213 (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
|
1214 (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
|
1215 '((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
|
1216 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
|
1217 nil nil ((?$ . "\"")) nil |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1218 ;; Who ever uses that anyway ??? |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1219 (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
|
1220 (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
|
1221 . 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
|
1222 (font-lock-unfontify-region-function |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
1223 . tex-font-lock-unfontify-region))) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
1224 (set (make-local-variable 'syntax-propertize-function) |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
1225 (syntax-propertize-rules latex-syntax-propertize-rules)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1226 ;; 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
|
1227 (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
|
1228 ;; Other vars that should be buffer-local. |
85 | 1229 (make-local-variable 'tex-command) |
1230 (make-local-variable 'tex-start-of-header) | |
1231 (make-local-variable 'tex-end-of-header) | |
1232 (make-local-variable 'tex-trailer)) | |
1233 | |
1234 (defun tex-categorize-whitespace (backward-limit) | |
1235 ;; compare-windows-whitespace is set to this. | |
1236 ;; This is basically a finite-state machine. | |
1237 ;; Returns a symbol telling how TeX would treat | |
1238 ;; the whitespace we are looking at: null, space, or par. | |
1239 (let ((category 'null) | |
1240 (not-finished t)) | |
1241 (skip-chars-backward " \t\n\f" backward-limit) | |
1242 (while not-finished | |
1243 (cond ((looking-at "[ \t]+") | |
1244 (goto-char (match-end 0)) | |
18931
43b52e6a35c2
(tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents:
18587
diff
changeset
|
1245 (if (eq category 'null) |
85 | 1246 (setq category 'space))) |
1247 ((looking-at "\n") | |
18931
43b52e6a35c2
(tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents:
18587
diff
changeset
|
1248 (cond ((eq category 'newline) |
85 | 1249 (setq category 'par) |
1250 (setq not-finished nil)) | |
1251 (t | |
1252 (setq category 'newline) ;a strictly internal state | |
1253 (goto-char (match-end 0))))) | |
1254 ((looking-at "\f+") | |
1255 (setq category 'par) | |
1256 (setq not-finished nil)) | |
1257 (t | |
1258 (setq not-finished nil)))) | |
1259 (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
|
1260 (if (eq category 'newline) |
85 | 1261 'space ;TeX doesn't distinguish |
1262 category))) | |
1263 | |
1264 (defun tex-insert-quote (arg) | |
1265 "Insert the appropriate quote marks for TeX. | |
2836
d95acb2243f9
(tex-insert-quote): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2598
diff
changeset
|
1266 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
|
1267 \(normally '') depending on the context. With prefix argument, always |
85 | 1268 inserts \" characters." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1269 (interactive "*P") |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1270 (if (or arg (memq (char-syntax (preceding-char)) '(?/ ?\\)) |
65706
183bad3fad1f
(tex-insert-quote, latex-indent): Quote face names.
Juanma Barranquero <lekktu@gmail.com>
parents:
65683
diff
changeset
|
1271 (eq (get-text-property (point) 'face) 'tex-verbatim) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1272 (save-excursion |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1273 (backward-char (length tex-open-quote)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1274 (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
|
1275 (looking-at (regexp-quote tex-close-quote))) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1276 (delete-char (length tex-open-quote)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1277 t))) |
85 | 1278 (self-insert-command (prefix-numeric-value arg)) |
64060
fa1dc4af6eee
(tex-file, tex-run, tex-view): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63228
diff
changeset
|
1279 (insert (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\s)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1280 tex-open-quote tex-close-quote)))) |
85 | 1281 |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1282 (defun tex-validate-buffer () |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1283 "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
|
1284 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
|
1285 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
|
1286 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
|
1287 on the line for the invalidity you want to see." |
85 | 1288 (interactive) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1289 (let ((buffer (current-buffer)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1290 (prevpos (point-min)) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1291 (linenum nil) |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1292 (num-matches 0)) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1293 (with-output-to-temp-buffer "*Occur*" |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1294 (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
|
1295 (with-current-buffer standard-output |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1296 (occur-mode) |
45055
b9c9078b245d
(tex-validate-buffer): Use `occur-revert-arguments' instead of setting
Colin Walters <walters@gnu.org>
parents:
44884
diff
changeset
|
1297 ;; 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
|
1298 ;; 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
|
1299 (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
|
1300 (save-excursion |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1301 (goto-char (point-max)) |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1302 ;; Do a little shimmy to place point at the end of the last |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1303 ;; "real" paragraph. Need to avoid validating across an \end, |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1304 ;; because that blows up latex-forward-sexp. |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1305 (backward-paragraph) |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1306 (forward-paragraph) |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1307 (while (not (bobp)) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1308 ;; Scan the previous paragraph for invalidities. |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1309 (backward-paragraph) |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1310 (save-excursion |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1311 (or (tex-validate-region (point) (save-excursion |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1312 (forward-paragraph) |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1313 (point))) |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1314 (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
|
1315 start tem) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1316 (beginning-of-line) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1317 (setq start (point)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1318 ;; 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
|
1319 ;; in a cumulative fashion. |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1320 (if linenum |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1321 (setq linenum (- linenum |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1322 (count-lines prevpos (point)))) |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1323 (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
|
1324 (setq prevpos (point)) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1325 ;; Mention this mismatch in *Occur*. |
4376
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1326 ;; 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
|
1327 ;; 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
|
1328 (save-excursion |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1329 (setq tem (point-marker)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1330 (set-buffer standard-output) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1331 (goto-char (point-min)) |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1332 ;; Skip "Mismatches:" header line. |
109294166e68
(validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1333 (forward-line 1) |
24222
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1334 (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
|
1335 (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
|
1336 (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
|
1337 (forward-char (- start end)) |
8b2cecc76fe3
(tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents:
24173
diff
changeset
|
1338 (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
|
1339 (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
|
1340 (add-text-properties |
745b05b3e5ed
(tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents:
37952
diff
changeset
|
1341 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
|
1342 '(mouse-face highlight |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1343 help-echo |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1344 "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
|
1345 (put-text-property text-beg (- text-end 1) |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1346 'occur-target tem)))))))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1347 (with-current-buffer standard-output |
56792
db21eaa33109
(tex-validate-buffer): Distinguish between 0, 1, and many mismatches.
John Paul Wallington <jpw@pobox.com>
parents:
55677
diff
changeset
|
1348 (let ((no-matches (zerop num-matches))) |
db21eaa33109
(tex-validate-buffer): Distinguish between 0, 1, and many mismatches.
John Paul Wallington <jpw@pobox.com>
parents:
55677
diff
changeset
|
1349 (if no-matches |
db21eaa33109
(tex-validate-buffer): Distinguish between 0, 1, and many mismatches.
John Paul Wallington <jpw@pobox.com>
parents:
55677
diff
changeset
|
1350 (insert "None!\n")) |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
104778
diff
changeset
|
1351 (if (called-interactively-p 'interactive) |
56843
4520af567a84
(tex-validate-buffer): Use distinct strings rather than
John Paul Wallington <jpw@pobox.com>
parents:
56792
diff
changeset
|
1352 (message (cond (no-matches "No mismatches found") |
4520af567a84
(tex-validate-buffer): Use distinct strings rather than
John Paul Wallington <jpw@pobox.com>
parents:
56792
diff
changeset
|
1353 ((= num-matches 1) "1 mismatch found") |
4520af567a84
(tex-validate-buffer): Use distinct strings rather than
John Paul Wallington <jpw@pobox.com>
parents:
56792
diff
changeset
|
1354 (t "%d mismatches found")) |
4520af567a84
(tex-validate-buffer): Use distinct strings rather than
John Paul Wallington <jpw@pobox.com>
parents:
56792
diff
changeset
|
1355 num-matches))))))) |
85 | 1356 |
1357 (defun tex-validate-region (start end) | |
1358 "Check for mismatched braces or $'s in region. | |
1359 Returns t if no mismatches. Returns nil and moves point to suspect | |
1360 area if a mismatch is found." | |
1361 (interactive "r") | |
1362 (let ((failure-point nil) (max-possible-sexps (- end start))) | |
1363 (save-excursion | |
1364 (condition-case () | |
1365 (save-restriction | |
1366 (narrow-to-region start end) | |
20203
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1367 ;; First check that the open and close parens balance in numbers. |
85 | 1368 (goto-char start) |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1369 (while (and (not (eobp)) |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1370 (<= 0 (setq max-possible-sexps |
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1371 (1- max-possible-sexps)))) |
20203
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1372 (forward-sexp 1)) |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1373 ;; Now check that like matches like. |
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1374 (goto-char start) |
58753
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1375 (while (re-search-forward "\\s(" nil t) |
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1376 (save-excursion |
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1377 (let ((pos (match-beginning 0))) |
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1378 (goto-char pos) |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1379 (skip-chars-backward "\\\\") ; escaped parens |
20203
f1a4588c8075
(tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents:
18931
diff
changeset
|
1380 (forward-sexp 1) |
58753
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1381 (or (eq (preceding-char) (cdr (syntax-after pos))) |
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1382 (eq (char-after pos) (cdr (syntax-after (1- (point))))) |
b854b191862d
(tex-validate-region): Obey syntax-table text properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58696
diff
changeset
|
1383 (error "Mismatched parentheses")))))) |
85 | 1384 (error |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1385 (skip-syntax-forward " .>") |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1386 (setq failure-point (point))))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1387 (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
|
1388 (not failure-point))) |
85 | 1389 |
1390 (defun tex-terminate-paragraph (inhibit-validation) | |
1391 "Insert two newlines, breaking a paragraph for TeX. | |
7285 | 1392 Check for mismatched braces or $s in paragraph being terminated. |
85 | 1393 A prefix arg inhibits the checking." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1394 (interactive "*P") |
85 | 1395 (or inhibit-validation |
1396 (save-excursion | |
78830
f4f2cb314448
(tex-terminate-paragraph): Use backward-paragraph.
Glenn Morris <rgm@gnu.org>
parents:
78818
diff
changeset
|
1397 ;; For the purposes of this, a "paragraph" is a block of text |
f4f2cb314448
(tex-terminate-paragraph): Use backward-paragraph.
Glenn Morris <rgm@gnu.org>
parents:
78818
diff
changeset
|
1398 ;; wherein all the brackets etc are expected to be balanced. It |
f4f2cb314448
(tex-terminate-paragraph): Use backward-paragraph.
Glenn Morris <rgm@gnu.org>
parents:
78818
diff
changeset
|
1399 ;; may start after a blank line (ie a "proper" paragraph), or |
f4f2cb314448
(tex-terminate-paragraph): Use backward-paragraph.
Glenn Morris <rgm@gnu.org>
parents:
78818
diff
changeset
|
1400 ;; a begin{} or end{} block, etc. |
85 | 1401 (tex-validate-region |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1402 (save-excursion |
78830
f4f2cb314448
(tex-terminate-paragraph): Use backward-paragraph.
Glenn Morris <rgm@gnu.org>
parents:
78818
diff
changeset
|
1403 (backward-paragraph) |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1404 (point)) |
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
1405 (point))) |
85 | 1406 (message "Paragraph being closed appears to contain a mismatch")) |
1407 (insert "\n\n")) | |
1408 | |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1409 (define-skeleton tex-insert-braces |
85 | 1410 "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
|
1411 nil |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1412 ?\{ _ ?}) |
85 | 1413 |
21121
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1414 ;; 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
|
1415 ;; 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
|
1416 ;; of a \verb construct. |
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1417 (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
|
1418 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1419 (skip-chars-backward " ") |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1420 ;; 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
|
1421 (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
|
1422 (let ((opoint (point)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1423 inside) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1424 (beginning-of-line) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1425 (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
|
1426 (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
|
1427 (setq inside t))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1428 inside)))) |
21121
dd5c2baa6674
(latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents:
20203
diff
changeset
|
1429 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1430 (defvar latex-block-default "enumerate") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1431 |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1432 (defvar latex-block-args-alist |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1433 '(("array" nil ?\{ (skeleton-read "Format: ") ?\}) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1434 ("tabular" nil ?\{ (skeleton-read "Format: ") ?\}) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1435 ("minipage" nil ?\{ (skeleton-read "Size: ") ?\}) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1436 ("picture" nil ?\( (skeleton-read "SizeX,SizeY: ") ?\)) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1437 ;; FIXME: This is right for Prosper, but not for seminar. |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1438 ;; ("slide" nil ?\{ (skeleton-read "Title: ") ?\}) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1439 ) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1440 "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
|
1441 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
|
1442 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
|
1443 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
|
1444 |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1445 (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
|
1446 '(("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
|
1447 ("itemize" nil '(latex-insert-item) > _) |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1448 ("table" nil "\\caption{" > (skeleton-read "Caption: ") "}" > \n |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1449 '(if (and (boundp 'reftex-mode) reftex-mode) (reftex-label "table")) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1450 \n _) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1451 ("figure" nil > _ \n "\\caption{" > (skeleton-read "Caption: ") "}" > \n |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1452 '(if (and (boundp 'reftex-mode) reftex-mode) (reftex-label "table")))) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1453 "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
|
1454 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
|
1455 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
|
1456 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
|
1457 |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1458 ;; 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
|
1459 (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
|
1460 (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
|
1461 "Create a matching pair of lines \\begin{NAME} and \\end{NAME} at point. |
85 | 1462 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
|
1463 (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
|
1464 latex-block-default) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1465 (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
|
1466 latex-standard-block-names) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1467 nil nil nil nil latex-block-default))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1468 (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
|
1469 (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
|
1470 (member choice latex-block-names)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1471 ;; Remember new block names for later completion. |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1472 (push choice latex-block-names)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1473 choice) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1474 \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
|
1475 (cdr (assoc str latex-block-args-alist)) |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1476 > \n (or (cdr (assoc str latex-block-body-alist)) '(nil > _)) |
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1477 (unless (bolp) '\n) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1478 "\\end{" str "}" > \n) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1479 |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1480 (define-skeleton latex-insert-item |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1481 "Insert a \item macro." |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1482 nil |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1483 \n "\\item " >) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1484 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1485 |
106134
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1486 ;;;; LaTeX completion. |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1487 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1488 (defvar latex-complete-bibtex-cache nil) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1489 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1490 (defun latex-string-prefix-p (str1 str2) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1491 (eq t (compare-strings str1 nil nil str2 0 (length str1)))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1492 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1493 (defvar bibtex-reference-key) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1494 (declare-function reftex-get-bibfile-list "reftex-cite.el" ()) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1495 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1496 (defun latex-complete-bibtex-keys () |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1497 (when (bound-and-true-p reftex-mode) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1498 (lambda (key pred action) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1499 (let ((re (concat "^[ \t]*@\\([a-zA-Z]+\\)[ \t\n]*\\([{(][ \t\n]*\\)" |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1500 (regexp-quote key))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1501 (files (reftex-get-bibfile-list)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1502 keys) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1503 (if (and (eq (car latex-complete-bibtex-cache) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1504 (reftex-get-bibfile-list)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1505 (latex-string-prefix-p (nth 1 latex-complete-bibtex-cache) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1506 key)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1507 ;; Use the cache. |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1508 (setq keys (nth 2 latex-complete-bibtex-cache)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1509 (dolist (file files) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1510 (with-current-buffer (find-file-noselect file) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1511 (goto-char (point-min)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1512 (while (re-search-forward re nil t) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1513 (goto-char (match-end 2)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1514 (when (and (not (member-ignore-case (match-string 1) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1515 '("c" "comment" "string"))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1516 (looking-at bibtex-reference-key)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1517 (push (match-string-no-properties 0) keys))))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1518 ;; Fill the cache. |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1519 (set (make-local-variable 'latex-complete-bibtex-cache) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1520 (list files key keys))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1521 (complete-with-action action keys key pred))))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1522 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1523 (defun latex-complete-envnames () |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1524 (append latex-block-names latex-standard-block-names)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1525 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1526 (defun latex-complete-refkeys () |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1527 (when (boundp 'reftex-docstruct-symbol) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1528 (symbol-value reftex-docstruct-symbol))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1529 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1530 (defvar latex-complete-alist |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1531 ;; TODO: Add \begin, \end, \ref, ... |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1532 '(("\\`\\\\\\(short\\)?cite\\'" . latex-complete-bibtex-keys) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1533 ("\\`\\\\\\(begin\\|end\\)\\'" . latex-complete-envnames) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1534 ("\\`\\\\[vf]?ref\\'" . latex-complete-refkeys))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1535 |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1536 (defun latex-complete-data () |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1537 "Get completion-data at point." |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1538 (save-excursion |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1539 (let ((pt (point))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1540 (skip-chars-backward "^ {}\n\t\\\\") |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1541 (case (char-before) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1542 ((nil ?\s ?\n ?\t ?\}) nil) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1543 (?\\ |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1544 ;; TODO: Complete commands. |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1545 nil) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1546 (?\{ |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1547 ;; Complete args to commands. |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1548 (let* ((cmd |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1549 (save-excursion |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1550 (forward-char -1) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1551 (skip-chars-backward " \n") |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1552 (buffer-substring (point) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1553 (progn |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1554 (skip-chars-backward "a-zA-Z@*") |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1555 (let ((n (skip-chars-backward "\\\\"))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1556 (forward-char (* 2 (/ n 2)))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1557 (point))))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1558 (start (point)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1559 (_ (progn (goto-char pt) (skip-chars-backward "^," start))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1560 (comp-beg (point)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1561 (_ (progn (goto-char pt) (skip-chars-forward "^, {}\n\t\\\\"))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1562 (comp-end (point)) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1563 (table |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1564 (funcall |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1565 (let ((f (lambda () t))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1566 (dolist (comp latex-complete-alist) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1567 (if (string-match (car comp) cmd) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1568 (setq f (cdr comp)))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1569 f)))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1570 (if (eq table t) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1571 ;; Unknown command. |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1572 nil |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1573 (list comp-beg comp-end table)))))))) |
cff2b8b6d64e
(latex-complete-bibtex-cache, latex-complete-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105870
diff
changeset
|
1574 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1575 ;;;; |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1576 ;;;; LaTeX syntax navigation |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1577 ;;;; |
85 | 1578 |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1579 (defmacro tex-search-noncomment (&rest body) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1580 "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
|
1581 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
|
1582 (declare (debug t)) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1583 (let ((res-sym (make-symbol "result"))) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1584 `(let (,res-sym) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1585 (while |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1586 (and (setq ,res-sym (progn ,@body)) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1587 (save-excursion (skip-chars-backward "^\n%") (not (bolp))))) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1588 ,res-sym))) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1589 |
85 | 1590 (defun tex-last-unended-begin () |
7285 | 1591 "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
|
1592 (condition-case nil |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1593 (while (and (tex-search-noncomment |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1594 (re-search-backward "\\\\\\(begin\\|end\\)\\s *{")) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1595 (looking-at "\\\\end")) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1596 (tex-last-unended-begin)) |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1597 (search-failed (error "Couldn't find unended \\begin")))) |
85 | 1598 |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1599 (defun tex-next-unmatched-end () |
78842
675e2e2bd67c
(tex-validate-buffer): Use paragraph motion functions, rather than
Glenn Morris <rgm@gnu.org>
parents:
78830
diff
changeset
|
1600 "Leave point at the end of the next `\\end' that is unmatched." |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1601 (while (and (tex-search-noncomment |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
1602 (re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}")) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1603 (save-excursion (goto-char (match-beginning 0)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1604 (looking-at "\\\\begin"))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1605 (tex-next-unmatched-end))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1606 |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1607 (defun tex-next-unmatched-eparen (otype) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1608 "Leave point after the next unmatched escaped closing parenthesis. |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1609 The string OTYPE is an opening parenthesis type: `(', `{', or `['." |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1610 (condition-case nil |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1611 (let ((ctype (char-to-string (cdr (aref (syntax-table) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1612 (string-to-char otype)))))) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1613 (while (and (tex-search-noncomment |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1614 (re-search-forward (format "\\\\[%s%s]" ctype otype))) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1615 (save-excursion |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1616 (goto-char (match-beginning 0)) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1617 (looking-at (format "\\\\%s" (regexp-quote otype))))) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1618 (tex-next-unmatched-eparen otype))) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1619 (wrong-type-argument (error "Unknown opening parenthesis type: %s" otype)) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1620 (search-failed (error "Couldn't find closing escaped paren")))) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1621 |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1622 (defun tex-last-unended-eparen (ctype) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1623 "Leave point at the start of the last unended escaped opening parenthesis. |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1624 The string CTYPE is a closing parenthesis type: `)', `}', or `]'." |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1625 (condition-case nil |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1626 (let ((otype (char-to-string (cdr (aref (syntax-table) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1627 (string-to-char ctype)))))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1628 (while (and (tex-search-noncomment |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1629 (re-search-backward (format "\\\\[%s%s]" ctype otype))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1630 (looking-at (format "\\\\%s" (regexp-quote ctype)))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1631 (tex-last-unended-eparen ctype))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1632 (wrong-type-argument (error "Unknown opening parenthesis type: %s" ctype)) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1633 (search-failed (error "Couldn't find unended escaped paren")))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1634 |
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
|
1635 (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
|
1636 "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
|
1637 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
|
1638 (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
|
1639 (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
|
1640 (save-excursion |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
1641 (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
|
1642 (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
|
1643 (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
|
1644 (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
|
1645 |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1646 (defvar latex-handle-escaped-parens t) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1647 |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1648 ;; Don't think this one actually _needs_ (for the purposes of |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1649 ;; tex-mode) to handle escaped parens. |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1650 ;; Does not handle escaped parens when latex-handle-escaped-parens is nil. |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1651 (defun latex-backward-sexp-1 () |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1652 "Like (backward-sexp 1) but aware of multi-char elements and escaped parens." |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1653 (let ((pos (point)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1654 (forward-sexp-function)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1655 (backward-sexp 1) |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1656 (cond ((looking-at |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1657 (if latex-handle-escaped-parens |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1658 "\\\\\\(begin\\>\\|[[({]\\)" |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1659 "\\\\begin\\>")) |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1660 (signal 'scan-error |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1661 (list "Containing expression ends prematurely" |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1662 (point) (prog1 (point) (goto-char pos))))) |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1663 ((and latex-handle-escaped-parens |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1664 (looking-at "\\\\\\([])}]\\)")) |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1665 (tex-last-unended-eparen (match-string 1))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1666 ((eq (char-after) ?{) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1667 (let ((newpos (point))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1668 (when (ignore-errors (backward-sexp 1) t) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1669 (if (or (looking-at "\\\\end\\>") |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1670 ;; In case the \\ ends a verbatim section. |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1671 (and (looking-at "end\\>") (eq (char-before) ?\\))) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1672 (tex-last-unended-begin) |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1673 (goto-char newpos)))))))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1674 |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1675 ;; Note this does not handle things like mismatched brackets inside |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1676 ;; begin/end blocks. |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1677 ;; Needs to handle escaped parens for tex-validate-*. |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1678 ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-09/msg00038.html |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1679 ;; Does not handle escaped parens when latex-handle-escaped-parens is nil. |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1680 (defun latex-forward-sexp-1 () |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1681 "Like (forward-sexp 1) but aware of multi-char elements and escaped parens." |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1682 (let ((pos (point)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1683 (forward-sexp-function)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1684 (forward-sexp 1) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1685 (let ((newpos (point))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1686 (skip-syntax-backward "/w") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1687 (cond |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1688 ((looking-at "\\\\end\\>") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1689 (signal 'scan-error |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1690 (list "Containing expression ends prematurely" |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1691 (point) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1692 (prog1 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1693 (progn (ignore-errors (forward-sexp 2)) (point)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1694 (goto-char pos))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1695 ((looking-at "\\\\begin\\>") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1696 (goto-char (match-end 0)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1697 (tex-next-unmatched-end)) |
84756
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1698 ;; A better way to handle this, \( .. \) etc, is probably to |
7056747df1a9
(tex-next-unmatched-eparen): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
84711
diff
changeset
|
1699 ;; temporarily change the syntax of the \ in \( to punctuation. |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1700 ((and latex-handle-escaped-parens |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1701 (looking-back "\\\\[])}]")) |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1702 (signal 'scan-error |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1703 (list "Containing expression ends prematurely" |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1704 (- (point) 2) (prog1 (point) |
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1705 (goto-char pos))))) |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1706 ((and latex-handle-escaped-parens |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
1707 (looking-back "\\\\\\([({[]\\)")) |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1708 (tex-next-unmatched-eparen (match-string 1))) |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1709 (t (goto-char newpos)))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1710 |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1711 (defun latex-forward-sexp (&optional arg) |
84711
f5f984f1f04b
(tex-validate-region): Handle escaped parens.
Glenn Morris <rgm@gnu.org>
parents:
84674
diff
changeset
|
1712 "Like `forward-sexp' but aware of multi-char elements and escaped parens." |
32045
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1713 (interactive "P") |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1714 (unless arg (setq arg 1)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1715 (let ((pos (point))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1716 (condition-case err |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1717 (while (/= arg 0) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1718 (setq arg |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1719 (if (> arg 0) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1720 (progn (latex-forward-sexp-1) (1- arg)) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1721 (progn (latex-backward-sexp-1) (1+ arg))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1722 (scan-error |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1723 (goto-char pos) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1724 (signal (car err) (cdr err)))))) |
74db1ffe4fe8
(latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31990
diff
changeset
|
1725 |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1726 (defun latex-syntax-after () |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1727 "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
|
1728 (if (looking-at "\\\\end\\>") ?\) (char-syntax (following-char)))) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1729 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1730 (defun latex-skip-close-parens () |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1731 "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
|
1732 (let ((forward-sexp-function nil)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1733 (while (progn (skip-syntax-forward " )") |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1734 (looking-at "\\\\end\\>")) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1735 (forward-sexp 2)))) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1736 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1737 (defun latex-down-list () |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1738 "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
|
1739 (forward-comment (point-max)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1740 (let ((forward-sexp-function nil)) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1741 (if (not (looking-at "\\\\begin\\>")) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1742 (down-list 1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1743 (forward-sexp 1) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1744 ;; Skip arguments. |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1745 (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
|
1746 (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
|
1747 (forward-sexp)))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1748 |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1749 (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
|
1750 (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
|
1751 "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
|
1752 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1753 (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
|
1754 (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
|
1755 (match-string 1))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1756 \n "\\end" str > \n) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
1757 |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1758 (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
|
1759 "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
|
1760 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1761 (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
|
1762 (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
|
1763 (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
|
1764 (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
|
1765 (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
|
1766 (progn |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1767 (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
|
1768 (forward-sexp 1)) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1769 (point))))))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
1770 \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
|
1771 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1772 (defconst tex-discount-args-cmds |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1773 '("begin" "end" "input" "special" "cite" "ref" "include" "includeonly" |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1774 "documentclass" "usepackage" "label") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1775 "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
|
1776 |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1777 (defun tex-count-words (begin end) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1778 "Count the number of words in the buffer." |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1779 (interactive |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1780 (if (and transient-mark-mode mark-active) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1781 (list (region-beginning) (region-end)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1782 (list (point-min) (point-max)))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1783 ;; 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
|
1784 (save-excursion |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1785 (goto-char begin) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1786 (let ((count 0)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1787 (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
|
1788 (if (not (eq (char-syntax (preceding-char)) ?/)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1789 (progn |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1790 ;; Don't count single-char words. |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1791 (unless (looking-at ".\\>") (incf count)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1792 (forward-char 1)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1793 (let ((cmd |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1794 (buffer-substring-no-properties |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1795 (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
|
1796 (forward-char 1)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1797 (point))))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1798 (when (member cmd tex-discount-args-cmds) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1799 (skip-chars-forward "*") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1800 (forward-comment (point-max)) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1801 (when (looking-at "\\[") |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1802 (forward-sexp 1) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1803 (forward-comment (point-max))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1804 (if (not (looking-at "{")) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1805 (forward-char 1) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1806 (forward-sexp 1)))))) |
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1807 (message "%s words" count)))) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1808 |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1809 |
85 | 1810 |
1811 ;;; Invoking TeX in an inferior shell. | |
1812 | |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1813 ;; 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
|
1814 ;; gets stuck, the user can switch to the shell window and type at it. |
85 | 1815 |
37896
5cc52d5c2f2b
(tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36105
diff
changeset
|
1816 ;; The utility functions: |
85 | 1817 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1818 (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
|
1819 (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
|
1820 'tex-compilation-parse-errors) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1821 (compilation-shell-minor-mode t)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1822 |
7834
fc1c95bf734b
(tex-start-shell): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
7827
diff
changeset
|
1823 ;;;###autoload |
85 | 1824 (defun tex-start-shell () |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1825 (with-current-buffer |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1826 (make-comint |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
1827 "tex-shell" |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
1828 (or tex-shell-file-name (getenv "ESHELL") shell-file-name) |
59599
81cffebb04a5
* textmodes/tex-mode.el (tex-start-shell): Adding -i to the
Steven Tamm <steventamm@mac.com>
parents:
58898
diff
changeset
|
1829 nil |
59603 | 1830 ;; Specify an interactive shell, to make sure it prompts. |
59599
81cffebb04a5
* textmodes/tex-mode.el (tex-start-shell): Adding -i to the
Steven Tamm <steventamm@mac.com>
parents:
58898
diff
changeset
|
1831 "-i") |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1832 (let ((proc (get-process "tex-shell"))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1833 (set-process-sentinel proc 'tex-shell-sentinel) |
56792
db21eaa33109
(tex-validate-buffer): Distinguish between 0, 1, and many mismatches.
John Paul Wallington <jpw@pobox.com>
parents:
55677
diff
changeset
|
1834 (set-process-query-on-exit-flag proc nil) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1835 (tex-shell) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1836 (while (zerop (buffer-size)) |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1837 (sleep-for 1))))) |
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1838 |
23761
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1839 (defun tex-feed-input () |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1840 "Send input to the tex shell process. |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1841 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
|
1842 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
|
1843 (interactive) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1844 (set-buffer (tex-shell-buf)) |
23761
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1845 (comint-send-input) |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1846 (tex-recenter-output-buffer nil)) |
a99c30431979
(tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents:
23642
diff
changeset
|
1847 |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1848 (defun tex-display-shell () |
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
1849 "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
|
1850 (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
|
1851 (tex-recenter-output-buffer nil)) |
85 | 1852 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1853 (defun tex-shell-sentinel (proc msg) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1854 (cond ((null (buffer-name (process-buffer proc))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1855 ;; buffer killed |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1856 (set-process-buffer proc nil) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1857 (tex-delete-last-temp-files)) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1858 ((memq (process-status proc) '(signal exit)) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1859 (tex-delete-last-temp-files)))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1860 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1861 (defun tex-set-buffer-directory (buffer directory) |
85 | 1862 "Set BUFFER's default directory to be DIRECTORY." |
1863 (setq directory (file-name-as-directory (expand-file-name directory))) | |
1864 (if (not (file-directory-p directory)) | |
1865 (error "%s is not a directory" directory) | |
105813
df4934f25eef
* textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105765
diff
changeset
|
1866 (with-current-buffer buffer |
85 | 1867 (setq default-directory directory)))) |
1868 | |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1869 (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
|
1870 (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
|
1871 |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1872 (defun tex-shell-proc () |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1873 (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
|
1874 (defun tex-shell-buf () |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1875 (process-buffer (tex-shell-proc))) |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1876 (defun tex-shell-buf-no-error () |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1877 (let ((proc (tex-shell-running))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
1878 (and proc (process-buffer proc)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1879 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1880 (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
|
1881 "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
|
1882 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
|
1883 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
|
1884 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
|
1885 evaluates to a command string. |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1886 |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1887 Return the process in which TeX is running." |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1888 (save-excursion |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1889 (let* ((cmd (eval command)) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
1890 (proc (tex-shell-proc)) |
5262
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
1891 (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
|
1892 (star (string-match "\\*" cmd)) |
5087
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1893 (string |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1894 (concat |
65315
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1895 (if (null file) |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1896 cmd |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1897 (if (file-name-absolute-p file) |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1898 (setq file (convert-standard-filename file))) |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1899 (if star (concat (substring cmd 0 star) |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1900 (shell-quote-argument file) |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1901 (substring cmd (1+ star))) |
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
1902 (concat cmd " " (shell-quote-argument file)))) |
5087
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1903 (if background "&" "")))) |
5262
b3a689b41d39
(tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents:
5088
diff
changeset
|
1904 ;; 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
|
1905 (set-buffer buf) |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1906 ;; 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
|
1907 ;; 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
|
1908 (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
|
1909 (accept-process-output proc)) |
5087
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1910 (goto-char (process-mark proc)) |
a7b2df620d1a
(tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents:
4917
diff
changeset
|
1911 (insert string) |
5088
73a1b31b673f
(tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents:
5087
diff
changeset
|
1912 (comint-send-input) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
1913 (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
|
1914 proc))) |
85 | 1915 |
6479
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1916 (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
|
1917 "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
|
1918 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
|
1919 (if tex-last-temp-file |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1920 (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
|
1921 (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
|
1922 (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
|
1923 (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
|
1924 (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
|
1925 dir)))) |
7536
efecdee78026
(tex-delete-last-temp-files): Don't fail on non-existent directory.
Karl Heuer <kwzh@gnu.org>
parents:
7298
diff
changeset
|
1926 (while list |
6479
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1927 (if not-all |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1928 (and |
855f4f2d24da
(tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents:
5427
diff
changeset
|
1929 ;; 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
|
1930 (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
|
1931 (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
|
1932 (delete-file (concat dir (car list)))) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1933 (setq list (cdr list)))))) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
1934 |
741
587f7a98341d
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
739
diff
changeset
|
1935 (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
|
1936 |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1937 ;; |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1938 ;; 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
|
1939 ;; |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1940 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1941 (defvar tex-compile-history nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1942 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1943 (defvar tex-input-files-re |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1944 (eval-when-compile |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1945 (concat "\\." (regexp-opt '("tex" "texi" "texinfo" |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1946 "bbl" "ind" "sty" "cls") t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1947 ;; 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
|
1948 "\\'\\|\\`[^.]+\\'"))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1949 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1950 (defcustom tex-use-reftex t |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1951 "If non-nil, use RefTeX's list of files to determine what command to use." |
62811
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
1952 :type 'boolean |
ccc8869d7418
(superscript, subscript, tex-math-face)
Lute Kamstra <lute@gnu.org>
parents:
61770
diff
changeset
|
1953 :group 'tex) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1954 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1955 (defvar tex-compile-commands |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1956 '(((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
|
1957 " " (if (< 0 (length tex-start-commands)) |
62909
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
1958 (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
|
1959 t "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1960 ((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
|
1961 " " (if (< 0 (length tex-start-commands)) |
62909
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
1962 (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
|
1963 t "%r.dvi") |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
1964 ("xdvi %r &" "%r.dvi") |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
1965 ("\\doc-view \"%r.pdf\"" "%r.pdf") |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
1966 ("xpdf %r.pdf &" "%r.pdf") |
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
1967 ("gv %r.ps &" "%r.ps") |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1968 ("yap %r &" "%r.dvi") |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1969 ("advi %r &" "%r.dvi") |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
1970 ("gv %r.pdf &" "%r.pdf") |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1971 ("bibtex %r" "%r.aux" "%r.bbl") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1972 ("makeindex %r" "%r.idx" "%r.ind") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1973 ("texindex %r.??") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1974 ("dvipdfm %r" "%r.dvi" "%r.pdf") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1975 ("dvipdf %r" "%r.dvi" "%r.pdf") |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
1976 ("dvips -o %r.ps %r" "%r.dvi" "%r.ps") |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
1977 ("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
|
1978 ("lpr %r.ps" "%r.ps")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1979 "List of commands for `tex-compile'. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1980 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
|
1981 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
|
1982 - `%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
|
1983 - `%f' the main file name. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
1984 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
|
1985 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
|
1986 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
|
1987 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
|
1988 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
|
1989 |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
1990 ;; 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
|
1991 (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
|
1992 "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
|
1993 (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
|
1994 |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1995 (defun tex-guess-main-file (&optional all) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1996 "Find a likely `tex-main-file'. |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
1997 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
|
1998 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
|
1999 of the current buffer." |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2000 (let ((dir default-directory) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2001 (header-re tex-start-of-header)) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2002 (catch 'found |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2003 ;; 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
|
2004 (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
|
2005 (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
|
2006 (when (and (cond |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2007 ((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
|
2008 ((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
|
2009 (t)) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2010 (stringp tex-main-file)) |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2011 (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
|
2012 ;; 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
|
2013 (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
|
2014 (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
|
2015 (when (and (cond |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2016 ((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
|
2017 ((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
|
2018 (t)) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2019 buffer-file-name |
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2020 ;; (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
|
2021 ;; (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
|
2022 (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
|
2023 (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
|
2024 (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
|
2025 (goto-char (point-min)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
2026 (re-search-forward |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
2027 header-re (+ (point) 10000) t)))) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2028 (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
|
2029 |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
2030 (defun tex-main-file () |
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
2031 "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
|
2032 (let* ((file (or tex-main-file |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2033 ;; Compatibility with AUCTeX. |
51796
09e60f24d0c4
(tex-main-file): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51562
diff
changeset
|
2034 (with-no-warnings |
58696
35f8fcf3abca
(tex-main-file): Add a compatibility with AUCTeX.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
57698
diff
changeset
|
2035 (when (boundp 'TeX-master) |
35f8fcf3abca
(tex-main-file): Add a compatibility with AUCTeX.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
57698
diff
changeset
|
2036 (cond ((stringp TeX-master) |
35f8fcf3abca
(tex-main-file): Add a compatibility with AUCTeX.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
57698
diff
changeset
|
2037 (make-local-variable 'tex-main-file) |
35f8fcf3abca
(tex-main-file): Add a compatibility with AUCTeX.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
57698
diff
changeset
|
2038 (setq tex-main-file TeX-master)) |
35f8fcf3abca
(tex-main-file): Add a compatibility with AUCTeX.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
57698
diff
changeset
|
2039 ((and (eq TeX-master t) buffer-file-name) |
35f8fcf3abca
(tex-main-file): Add a compatibility with AUCTeX.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
57698
diff
changeset
|
2040 (file-relative-name buffer-file-name))))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2041 ;; Try to guess the main file. |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2042 (if (not buffer-file-name) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2043 (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
|
2044 (file-relative-name |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2045 (if (save-excursion |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2046 (goto-char (point-min)) |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
2047 (re-search-forward tex-start-of-header |
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
2048 (+ (point) 10000) t)) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2049 ;; This is the main file. |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2050 buffer-file-name |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2051 ;; 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
|
2052 (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
|
2053 (tex-guess-main-file 'sub) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2054 ;; (tex-guess-main-file t) |
34139
358adc86d127
(tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33789
diff
changeset
|
2055 buffer-file-name))))))) |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
2056 (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
|
2057 file (concat file ".tex")))) |
33363
1a5b4e0146bc
(standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33113
diff
changeset
|
2058 |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2059 (defun tex-summarize-command (cmd) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2060 (if (not (stringp cmd)) "" |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2061 (mapconcat 'identity |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2062 (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
|
2063 (split-string cmd "\\s-*\\(?:;\\|&&\\)\\s-*")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2064 "&"))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2065 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2066 (defun tex-uptodate-p (file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2067 "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
|
2068 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
|
2069 ;; 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
|
2070 (and |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2071 ;; Clearly, the target must exist. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2072 (file-exists-p file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2073 ;; 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
|
2074 ;; 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
|
2075 (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
|
2076 (when buf |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2077 (with-current-buffer buf |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2078 (save-excursion |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2079 (goto-char (point-max)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2080 (and (re-search-backward |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2081 (concat "(see the transcript file for additional information)" |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2082 "\\|^Output written on .*" |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2083 (regexp-quote (file-name-nondirectory file)) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2084 " (.*)\\.") |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2085 nil t) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2086 (> (save-excursion |
103268
fd266a506f8e
(tex-uptodate-p): Accept [1{/var/foo}] as a page number.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
2087 ;; Usually page numbers are output as [N], but |
fd266a506f8e
(tex-uptodate-p): Accept [1{/var/foo}] as a page number.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
2088 ;; I've already seen things like |
fd266a506f8e
(tex-uptodate-p): Accept [1{/var/foo}] as a page number.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
2089 ;; [1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] |
fd266a506f8e
(tex-uptodate-p): Accept [1{/var/foo}] as a page number.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
2090 (or (re-search-backward "\\[[0-9]+\\({[^}]*}\\)?\\]" |
fd266a506f8e
(tex-uptodate-p): Accept [1{/var/foo}] as a page number.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
2091 nil t) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2092 (point-min))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2093 (save-excursion |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2094 (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
|
2095 (point-min))))))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2096 ;; 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
|
2097 (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
|
2098 (fboundp 'reftex-scanning-info-available-p) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2099 (reftex-scanning-info-available-p)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2100 (reftex-all-document-files) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2101 (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
|
2102 (ignored-dirs-re |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2103 (concat |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2104 (regexp-opt |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2105 (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
|
2106 (substring s 0 (1- (length s))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2107 completion-ignored-extensions)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2108 t) "\\'")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2109 (uptodate t)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2110 (while (and files uptodate) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2111 (let ((f (pop files))) |
52957
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
2112 (if (and (file-directory-p f) |
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
2113 ;; Avoid infinite loops. |
a4241f6b64e7
(tex-compile-commands): Add `yap' and `ps2pdf'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
2114 (not (file-symlink-p f))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2115 (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
|
2116 (setq files (nconc |
79173
50711e81a122
(tex-uptodate-p): Don't signal an error if one
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78842
diff
changeset
|
2117 (ignore-errors ;Not readable or something. |
50711e81a122
(tex-uptodate-p): Don't signal an error if one
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78842
diff
changeset
|
2118 (directory-files f t tex-input-files-re)) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2119 files))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2120 (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
|
2121 (setq uptodate nil))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2122 uptodate))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59603
diff
changeset
|
2123 |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2124 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2125 (autoload 'format-spec "format-spec") |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2126 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2127 (defvar tex-executable-cache nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2128 (defun tex-executable-exists-p (name) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2129 "Like `executable-find' but with a cache." |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2130 (let ((f (and (string-match "^\\\\\\([^ \t\n]+\\)" name) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2131 (intern-soft (concat "tex-cmd-" (match-string 1 name)))))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2132 (if (fboundp f) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2133 f |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2134 (let ((cache (assoc name tex-executable-cache))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2135 (if cache (cdr cache) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2136 (let ((executable (executable-find name))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2137 (push (cons name executable) tex-executable-cache) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2138 executable)))))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2139 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2140 (defun tex-command-executable (cmd) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2141 (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
|
2142 (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
|
2143 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2144 (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
|
2145 "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
|
2146 (let ((in (nth 1 cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2147 (out (nth 2 cmd))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2148 (if (stringp in) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2149 (let ((file (format-spec in fspec))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2150 (when (file-exists-p file) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2151 (or (not out) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2152 (file-newer-than-file-p |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2153 file (format-spec out fspec))))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2154 (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
|
2155 (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
|
2156 |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2157 (defcustom tex-cmd-bibtex-args "--min-crossref=100" |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2158 "Extra args to pass to `bibtex' by default." |
92459
edefaec61bcf
(tex-cmd-bibtex-args): Add :version and :group.
Glenn Morris <rgm@gnu.org>
parents:
92449
diff
changeset
|
2159 :type 'string |
edefaec61bcf
(tex-cmd-bibtex-args): Add :version and :group.
Glenn Morris <rgm@gnu.org>
parents:
92449
diff
changeset
|
2160 :version "23.1" |
edefaec61bcf
(tex-cmd-bibtex-args): Add :version and :group.
Glenn Morris <rgm@gnu.org>
parents:
92449
diff
changeset
|
2161 :group 'tex-run) |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2162 |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2163 (defun tex-format-cmd (format fspec) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2164 "Like `format-spec' but adds user-specified args to the command. |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2165 Only applies the FSPEC to the args part of FORMAT." |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2166 (if (not (string-match "\\([^ /\\]+\\) " format)) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2167 (format-spec format fspec) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2168 (let* ((prefix (substring format 0 (match-beginning 0))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2169 (cmd (match-string 1 format)) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2170 (args (substring format (match-end 0))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2171 (sym (intern-soft (format "tex-cmd-%s-args" cmd))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2172 (extra-args (and sym (symbol-value sym)))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2173 (concat prefix cmd |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2174 (if extra-args (concat " " extra-args)) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2175 " " (format-spec args fspec))))) |
92459
edefaec61bcf
(tex-cmd-bibtex-args): Add :version and :group.
Glenn Morris <rgm@gnu.org>
parents:
92449
diff
changeset
|
2176 |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2177 (defun tex-compile-default (fspec) |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
2178 "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
|
2179 ;; TODO: Learn to do latex+dvips! |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2180 (let ((cmds nil) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2181 (unchanged-in nil)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2182 ;; Only consider active commands. |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2183 (dolist (cmd tex-compile-commands) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2184 (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
|
2185 (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
|
2186 (push cmd cmds) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2187 (push (nth 1 cmd) unchanged-in)))) |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
2188 ;; If no command seems to be applicable, arbitrarily pick the first one. |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
2189 (setq cmds (if cmds (nreverse cmds) (list (car tex-compile-commands)))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2190 ;; 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
|
2191 ;; 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
|
2192 ;; 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
|
2193 ;; is inexistent doesn't matter). |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2194 (let ((tmp nil)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2195 (dolist (cmd cmds) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2196 (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
|
2197 (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
|
2198 ;; Only remove if there's something left. |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
2199 (if tmp (setq cmds (nreverse tmp)))) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2200 ;; 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
|
2201 (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
|
2202 (tmp nil)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2203 (dolist (cmd cmds) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2204 (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
|
2205 (push cmd tmp))) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2206 ;; Only remove if there's something left. |
63101
3f08f5c8ef66
(tex-guess-mode): Add RequirePackage.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62909
diff
changeset
|
2207 (if tmp (setq cmds (nreverse tmp)))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2208 ;; 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
|
2209 (let ((latest (nth 1 (car cmds)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2210 (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
|
2211 (if (equal latest (nth 1 cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2212 (push cmd cmds) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2213 (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
|
2214 (if (or (not (stringp latest)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2215 (eq (nth 1 cmd) t) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2216 (and (stringp (nth 1 cmd)) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2217 (file-newer-than-file-p |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2218 (format-spec (nth 1 cmd) fspec) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2219 (format-spec latest fspec)))) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2220 (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
|
2221 ;; 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
|
2222 (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
|
2223 (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
|
2224 ;; 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
|
2225 (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
|
2226 re hist-cmd) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2227 (while hist |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2228 (setq hist-cmd (pop hist)) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2229 (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
|
2230 (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
|
2231 "\\([ \t]\\|\\'\\)")) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2232 (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
|
2233 ;; 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
|
2234 ;; 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
|
2235 (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
|
2236 (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
|
2237 (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
|
2238 hist-cmd)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2239 (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
|
2240 ;; Substitute and return. |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2241 (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
|
2242 (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
|
2243 "\\([;&' \t\"]\\|\\'\\)") hist-cmd)) |
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2244 ;; 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
|
2245 ;; 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
|
2246 hist-cmd |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2247 (if cmds (tex-format-cmd (caar cmds) fspec)))))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2248 |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2249 (defun tex-cmd-doc-view (file) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2250 (pop-to-buffer (find-file-noselect file))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2251 |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2252 (defun tex-compile (dir cmd) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2253 "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
|
2254 ;; 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
|
2255 (interactive |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2256 (let* ((file (tex-main-file)) |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
2257 (default-directory |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
2258 (prog1 (file-name-directory (expand-file-name file)) |
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
2259 (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
|
2260 (root (file-name-sans-extension file)) |
62909
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
2261 (fspec (list (cons ?r (shell-quote-argument root)) |
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
2262 (cons ?f (shell-quote-argument file)))) |
51336
c1252b2b2582
(latex-block-args-alist, latex-block-body-alist): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51005
diff
changeset
|
2263 (default (tex-compile-default fspec))) |
51533
fd5c388dd142
(tex-search-noncomment): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51525
diff
changeset
|
2264 (list default-directory |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2265 (completing-read |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2266 (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
|
2267 (mapcar (lambda (x) |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2268 (list (tex-format-cmd (eval (car x)) fspec))) |
51005
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2269 tex-compile-commands) |
aeb075459c1d
(tex-compile-history, tex-input-files-re)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50943
diff
changeset
|
2270 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
|
2271 (save-some-buffers (not compilation-ask-about-save) nil) |
92449
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2272 (let ((f (and (string-match "^\\\\\\([^ \t\n]+\\)" cmd) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2273 (intern-soft (concat "tex-cmd-" (match-string 1 cmd)))))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2274 (if (functionp f) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2275 (condition-case nil |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2276 (let ((default-directory dir)) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2277 (apply f (split-string-and-unquote |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2278 (substring cmd (match-end 0))))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2279 (wrong-number-of-arguments |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2280 (error "Wrong number of arguments to %s" |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2281 (substring (symbol-name f) 8)))) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2282 (if (tex-shell-running) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2283 (tex-kill-job) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2284 (tex-start-shell)) |
3db1228ead22
(latex-mode): Remove % from paragraph-separate so that M-q can fill comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
2285 (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
|
2286 |
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2287 (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
|
2288 "Start a TeX run, using COMMAND on FILE." |
23322 | 2289 (let* ((star (string-match "\\*" command)) |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2290 (compile-command |
23322 | 2291 (if star |
2292 (concat (substring command 0 star) | |
62909
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
2293 (shell-quote-argument file) |
23322 | 2294 (substring command (1+ star))) |
2295 (concat command " " | |
46367
56af7a7485ae
Set encoding to utf-8.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46120
diff
changeset
|
2296 tex-start-options |
44884
6c699f1e076c
(tex-start-options): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
43691
diff
changeset
|
2297 (if (< 0 (length tex-start-commands)) |
62909
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
2298 (concat |
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
2299 (shell-quote-argument tex-start-commands) " ")) |
86b398407446
(tex-compile-commands, tex-compile, tex-start-tex): Undo all but the last
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62846
diff
changeset
|
2300 (shell-quote-argument file))))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2301 (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
|
2302 |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2303 (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
|
2304 (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
|
2305 (and buf (with-current-buffer buf |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2306 default-directory)))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2307 (not dir)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2308 (let (shell-dirtrack-verbose) |
65315
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
2309 (tex-send-command tex-shell-cd-command dir))) |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2310 (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
|
2311 (setq compilation-last-buffer (current-buffer)) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2312 (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
|
2313 ;; Don't parse previous compilations. |
33472
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2314 (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
|
2315 (tex-display-shell) |
1de979dabe6f
(tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33363
diff
changeset
|
2316 (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
|
2317 |
33789
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
2318 (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
|
2319 (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
|
2320 (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
|
2321 (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
|
2322 (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
|
2323 (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
|
2324 (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
|
2325 (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
|
2326 (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
|
2327 ;; 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
|
2328 (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
|
2329 st) |
3cb3c23bbe84
(tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33477
diff
changeset
|
2330 "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
|
2331 |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2332 (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
|
2333 "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
|
2334 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
|
2335 |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2336 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
|
2337 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
|
2338 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
|
2339 for the error messages." |
21314
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2340 (require 'thingatpt) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2341 (setq compilation-error-list nil) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2342 (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
|
2343 (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
|
2344 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
|
2345 last-filename last-linenum last-position |
78818
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2346 begin-of-error end-of-error errfilename) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2347 ;; 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
|
2348 (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
|
2349 ;; Parse messages. |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2350 (while (and (not (or found-desired (eobp))) |
78818
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2351 ;; First alternative handles the newer --file-line-error style: |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2352 ;; ./test2.tex:14: Too many }'s. |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2353 ;; Second handles the old-style: |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2354 ;; ! Too many }'s. |
78816
b93f64a362b4
Joe Wells <jbw at macs.hw.ac.uk> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
78813
diff
changeset
|
2355 (prog1 (re-search-forward |
78818
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2356 "^\\(?:\\([^:\n]+\\):[[:digit:]]+:\\|!\\) " nil 'move) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2357 (setq begin-of-error (match-beginning 0) |
78818
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2358 end-of-error (match-end 0) |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2359 errfilename (match-string 1))) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2360 (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
|
2361 "^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\)?\\(.*\\)$" nil 'move)) |
54423
802a91a2e43a
(tex-shell): Set error parsing function here.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53489
diff
changeset
|
2362 (let* ((this-error (copy-marker begin-of-error)) |
56792
db21eaa33109
(tex-validate-buffer): Distinguish between 0, 1, and many mismatches.
John Paul Wallington <jpw@pobox.com>
parents:
55677
diff
changeset
|
2363 (linenum (string-to-number (match-string 1))) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2364 (error-text (regexp-quote (match-string 3))) |
97023
910ca036b4b6
(tex-compilation-parse-errors): Check for
Chong Yidong <cyd@stupidchicken.com>
parents:
96293
diff
changeset
|
2365 try-filename |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2366 (filename |
78818
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2367 ;; Prefer --file-liner-error filename if we have it. |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2368 (or errfilename |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2369 (save-excursion |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2370 (with-syntax-table tex-error-parse-syntax-table |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2371 (backward-up-list 1) |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2372 (skip-syntax-forward "(_") |
104543
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
103268
diff
changeset
|
2373 (while (not |
97023
910ca036b4b6
(tex-compilation-parse-errors): Check for
Chong Yidong <cyd@stupidchicken.com>
parents:
96293
diff
changeset
|
2374 (and (setq try-filename (thing-at-point |
910ca036b4b6
(tex-compilation-parse-errors): Check for
Chong Yidong <cyd@stupidchicken.com>
parents:
96293
diff
changeset
|
2375 'filename)) |
910ca036b4b6
(tex-compilation-parse-errors): Check for
Chong Yidong <cyd@stupidchicken.com>
parents:
96293
diff
changeset
|
2376 (not (string= "" try-filename)) |
910ca036b4b6
(tex-compilation-parse-errors): Check for
Chong Yidong <cyd@stupidchicken.com>
parents:
96293
diff
changeset
|
2377 (file-readable-p try-filename))) |
78818
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2378 (skip-syntax-backward "(_") |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2379 (backward-up-list 1) |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2380 (skip-syntax-forward "(_")) |
7f83f178a5ef
(tex-compilation-parse-errors): Prefer the filename from
Glenn Morris <rgm@gnu.org>
parents:
78816
diff
changeset
|
2381 (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
|
2382 (new-file |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2383 (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
|
2384 (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
|
2385 (error-location |
55677
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2386 (with-current-buffer |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2387 (if (equal filename (concat tex-zap-file ".tex")) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2388 tex-last-buffer-texed |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2389 (find-file-noselect filename)) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2390 (save-excursion |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2391 (if new-file |
104543
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
103268
diff
changeset
|
2392 (progn |
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
103268
diff
changeset
|
2393 (goto-char (point-min)) |
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
103268
diff
changeset
|
2394 (forward-line (1- linenum)) |
da8b3e61b182
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
103268
diff
changeset
|
2395 (setq last-position nil)) |
55677
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2396 (goto-char last-position) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2397 (forward-line (- linenum last-linenum))) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2398 ;; first try a forward search for the error text, |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2399 ;; then a backward search limited by the last error. |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2400 (let ((starting-point (point))) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2401 (or (re-search-forward error-text nil t) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2402 (re-search-backward error-text last-position t) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2403 (goto-char starting-point))) |
624ac8a21b21
(tex-compilation-parse-errors): Save excursion in source buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54423
diff
changeset
|
2404 (point-marker))))) |
24129
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2405 (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
|
2406 (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
|
2407 (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
|
2408 (>= 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
|
2409 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
|
2410 (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
|
2411 (>= 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
|
2412 new-file) |
18c751deec0d
(tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents:
24109
diff
changeset
|
2413 (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
|
2414 (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
|
2415 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
|
2416 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
|
2417 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
|
2418 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
|
2419 (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
|
2420 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
|
2421 (goto-char end-of-error))))) |
25414
7c4808c6804b
(tex-compilation-parse-errors):
Richard M. Stallman <rms@gnu.org>
parents:
24527
diff
changeset
|
2422 (set-marker compilation-parsing-end (point)) |
57639
7e77ec815f3a
(tex-compilation-parse-errors): Don't output messages.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57415
diff
changeset
|
2423 (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
|
2424 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2425 ;;; The commands: |
85 | 2426 |
2427 (defun tex-region (beg end) | |
2428 "Run TeX on the current region, via a temporary file. | |
2429 The file's name comes from the variable `tex-zap-file' and the | |
2430 variable `tex-directory' says where to put it. | |
2431 | |
2432 If the buffer has a header, the header is given to TeX before the | |
2433 region itself. The buffer's header is all lines between the strings | |
2434 defined by `tex-start-of-header' and `tex-end-of-header' inclusive. | |
2435 The header must start in the first 100 lines of the buffer. | |
2436 | |
2437 The value of `tex-trailer' is given to TeX as input after the region. | |
2438 | |
2439 The value of `tex-command' specifies the command to use to run TeX." | |
2440 (interactive "r") | |
2441 (if (tex-shell-running) | |
2442 (tex-kill-job) | |
2443 (tex-start-shell)) | |
2444 (or tex-zap-file | |
2445 (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
|
2446 ;; 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
|
2447 ;; 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
|
2448 ;; \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
|
2449 ;; 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
|
2450 ;; tex-directory is ".". |
f8d567e52662
(tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents:
16777
diff
changeset
|
2451 (let* ((zap-directory |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2452 (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
|
2453 (tex-out-file (expand-file-name (concat tex-zap-file ".tex") |
78801
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2454 zap-directory)) |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2455 (main-file (expand-file-name (tex-main-file))) |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2456 (ismain (string-equal main-file (buffer-file-name))) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2457 already-output) |
9450
af39d29d1386
(compare-windows-whitespace): Eliminate initial value.
Richard M. Stallman <rms@gnu.org>
parents:
8890
diff
changeset
|
2458 ;; 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
|
2459 (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
|
2460 (tex-delete-last-temp-files t)) |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2461 (let ((default-directory zap-directory)) ; why? |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2462 ;; We assume the header is fully contained in tex-main-file. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2463 ;; We use f-f-ns so we get prompted about any changes on disk. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2464 (with-current-buffer (find-file-noselect main-file) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2465 (setq already-output (tex-region-header tex-out-file |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2466 (and ismain beg)))) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2467 ;; Write out the specified region (but don't repeat anything |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2468 ;; already written in the header). |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2469 (write-region (if ismain |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2470 (max beg already-output) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2471 beg) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2472 end tex-out-file (not (zerop already-output))) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2473 ;; Write the trailer, if any. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2474 ;; Precede it with a newline to make sure it |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2475 ;; is not hidden in a comment. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2476 (if tex-trailer |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2477 (write-region (concat "\n" tex-trailer) nil |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2478 tex-out-file t))) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2479 ;; Record the file name to be deleted afterward. |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2480 (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
|
2481 ;; 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
|
2482 ;; 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
|
2483 ;; 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
|
2484 (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
|
2485 (setq tex-print-file tex-out-file))) |
85 | 2486 |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2487 (defun tex-region-header (file &optional beg) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2488 "If there is a TeX header in the current buffer, write it to FILE. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2489 Return point at the end of the region so written, or zero. If |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2490 the optional buffer position BEG is specified, then the region |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2491 written out starts at BEG, if this lies before the start of the header. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2492 |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2493 If the first line matches `tex-first-line-header-regexp', it is |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2494 also written out. The variables `tex-start-of-header' and |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2495 `tex-end-of-header' are used to locate the header. Note that the |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2496 start of the header is required to be within the first 100 lines." |
78801
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2497 (save-excursion |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2498 (save-restriction |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2499 (widen) |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2500 (goto-char (point-min)) |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2501 (let ((search-end (save-excursion |
84611
fb155376791a
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
84587
diff
changeset
|
2502 (forward-line 100) |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2503 (point))) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2504 (already-output 0) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2505 hbeg hend) |
78801
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2506 ;; Maybe copy first line, such as `\input texinfo', to temp file. |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2507 (and tex-first-line-header-regexp |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2508 (looking-at tex-first-line-header-regexp) |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2509 (write-region (point) |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2510 (progn (forward-line 1) |
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2511 (setq already-output (point))) |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2512 file)) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2513 ;; Write out the header, if there is one, and any of the |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2514 ;; specified region which extends before it. But don't repeat |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2515 ;; anything already written. |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2516 (and tex-start-of-header |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2517 (re-search-forward tex-start-of-header search-end t) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2518 (progn |
84611
fb155376791a
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
84587
diff
changeset
|
2519 (beginning-of-line) |
fb155376791a
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
84587
diff
changeset
|
2520 (setq hbeg (point)) ; mark beginning of header |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2521 (when (re-search-forward tex-end-of-header nil t) |
84611
fb155376791a
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
84587
diff
changeset
|
2522 (forward-line 1) |
fb155376791a
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
84587
diff
changeset
|
2523 (setq hend (point)) ; mark end of header |
78813
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2524 (write-region |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2525 (max (if beg |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2526 (min hbeg beg) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2527 hbeg) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2528 already-output) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2529 hend file (not (zerop already-output))) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2530 (setq already-output hend)))) |
776b9b17aed0
(tex-region): Simplify previous change,
Glenn Morris <rgm@gnu.org>
parents:
78801
diff
changeset
|
2531 already-output)))) |
78801
c72d88d40ef8
(tex-region): Handle the case where the region is not in
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
2532 |
85 | 2533 (defun tex-buffer () |
2534 "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
|
2535 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
|
2536 See \\[tex-file] for an alternative." |
85 | 2537 (interactive) |
2538 (tex-region (point-min) (point-max))) | |
2539 | |
2540 (defun tex-file () | |
2541 "Prompt to save all buffers and run TeX (or LaTeX) on current buffer's file. | |
2542 This function is more useful than \\[tex-buffer] when you need the | |
2543 `.aux' file of LaTeX to have the correct name." | |
2544 (interactive) | |
46120
7177a47bc557
(tex-file): call `save-some-buffers' before `tex-main-file'
Sam Steingold <sds@gnu.org>
parents:
45055
diff
changeset
|
2545 (when tex-offer-save |
7177a47bc557
(tex-file): call `save-some-buffers' before `tex-main-file'
Sam Steingold <sds@gnu.org>
parents:
45055
diff
changeset
|
2546 (save-some-buffers)) |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2547 (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
|
2548 (file-dir (file-name-directory (expand-file-name source-file)))) |
85 | 2549 (if (tex-shell-running) |
2550 (tex-kill-job) | |
2551 (tex-start-shell)) | |
31968
dc896c1b6a26
(latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30888
diff
changeset
|
2552 (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
|
2553 (setq tex-print-file (expand-file-name source-file)))) |
85 | 2554 |
2555 (defun tex-generate-zap-file-name () | |
2556 "Generate a unique name suitable for use as a file name." | |
2557 ;; Include the shell process number and host name | |
2558 ;; 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
|
2559 ;; 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
|
2560 ;; 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
|
2561 (format "_TZ_%d-%s" |
85 | 2562 (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
|
2563 (subst-char-in-string ?. ?- (system-name)))) |
85 | 2564 |
2565 ;; This will perhaps be useful for modifying TEXINPUTS. | |
2566 ;; Expand each file name, separated by colons, in the string S. | |
2567 (defun tex-expand-files (s) | |
2568 (let (elts (start 0)) | |
2569 (while (string-match ":" s start) | |
2570 (setq elts (cons (substring s start (match-beginning 0)) elts)) | |
2571 (setq start (match-end 0))) | |
2572 (or (= start 0) | |
2573 (setq elts (cons (substring s start) elts))) | |
30888
e559f0aa6b2d
Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26270
diff
changeset
|
2574 (mapconcat (lambda (elt) |
e559f0aa6b2d
Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26270
diff
changeset
|
2575 (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
|
2576 (nreverse elts) ":"))) |
85 | 2577 |
2578 (defun tex-shell-running () | |
36105
595ee2f062cf
tex-shell-running: Check the process buffer too
Sam Steingold <sds@gnu.org>
parents:
34139
diff
changeset
|
2579 (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
|
2580 (when proc |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2581 (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
|
2582 (buffer-live-p (process-buffer proc))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2583 ;; return the TeX process on success |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2584 proc |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2585 ;; get rid of the process permanently |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2586 ;; 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
|
2587 ;; 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
|
2588 (delete-process proc))))) |
85 | 2589 |
2590 (defun tex-kill-job () | |
2591 "Kill the currently running TeX job." | |
2592 (interactive) | |
37942
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2593 ;; `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
|
2594 ;; 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
|
2595 ;; 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
|
2596 ;; 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
|
2597 (let ((proc (get-process "tex-shell"))) |
0f57d8b106f1
fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents:
37896
diff
changeset
|
2598 (when proc (quit-process proc t)))) |
85 | 2599 |
2600 (defun tex-recenter-output-buffer (linenum) | |
2601 "Redisplay buffer of TeX job output so that most recent output can be seen. | |
2602 The last line of the buffer is displayed on | |
2603 line LINE of the window, or centered if LINE is nil." | |
2604 (interactive "P") | |
2605 (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
|
2606 (window)) |
85 | 2607 (if (null tex-shell) |
2608 (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
|
2609 (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
|
2610 (save-selected-window |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2611 (select-window window) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2612 (bury-buffer tex-shell) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2613 (goto-char (point-max)) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2614 (recenter (if linenum |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2615 (prefix-numeric-value linenum) |
bdca7f3626c0
(tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents:
16356
diff
changeset
|
2616 (/ (window-height) 2))))))) |
85 | 2617 |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2618 (defun tex-print (&optional alt) |
85 | 2619 "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file]. |
1577 | 2620 Runs the shell command defined by `tex-dvi-print-command'. If prefix argument |
2621 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
|
2622 (interactive "P") |
85 | 2623 (let ((print-file-name-dvi (tex-append tex-print-file ".dvi")) |
2624 test-name) | |
2625 (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
|
2626 (buffer-file-name) |
f27bcd1faf07
(tex-print): Better check for when to print current
Richard M. Stallman <rms@gnu.org>
parents:
10325
diff
changeset
|
2627 ;; Check that this buffer's printed file is up to date. |
85 | 2628 (file-newer-than-file-p |
2629 (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
|
2630 (buffer-file-name))) |
85 | 2631 (setq print-file-name-dvi test-name)) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2632 (if (not (file-exists-p print-file-name-dvi)) |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2633 (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
|
2634 (if (tex-shell-running) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2635 (tex-kill-job) |
7d4a55d38b2c
(tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents:
21121
diff
changeset
|
2636 (tex-start-shell)) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2637 (tex-send-command |
24273
803ec3bfa983
When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents:
24222
diff
changeset
|
2638 (if alt tex-alt-dvi-print-command tex-dvi-print-command) |
62846
93362151dd3a
remove extraneous calls to shell-quote-argument
Karl Berry <karl@gnu.org>
parents:
62811
diff
changeset
|
2639 print-file-name-dvi |
48931
0af848ed2cae
(tex-print): Call shell-quote-argument on the file name.
Richard M. Stallman <rms@gnu.org>
parents:
48222
diff
changeset
|
2640 t)))) |
85 | 2641 |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2642 (defun tex-alt-print () |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2643 "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
|
2644 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
|
2645 (interactive) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2646 (tex-print t)) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2647 |
85 | 2648 (defun tex-view () |
2649 "Preview the last `.dvi' file made by running TeX under Emacs. | |
2650 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
|
2651 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
|
2652 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
|
2653 because there is no standard value that would generally work." |
85 | 2654 (interactive) |
11617
9eaeed5c8a40
(tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
2655 (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
|
2656 (error "You must set `tex-dvi-view-command'")) |
60749
3b3b017d62ab
(tex-view): If tex-shell process is not running, restart it.
Eli Zaretskii <eliz@gnu.org>
parents:
60232
diff
changeset
|
2657 ;; Restart the TeX shell if necessary. |
3b3b017d62ab
(tex-view): If tex-shell process is not running, restart it.
Eli Zaretskii <eliz@gnu.org>
parents:
60232
diff
changeset
|
2658 (or (tex-shell-running) |
3b3b017d62ab
(tex-view): If tex-shell process is not running, restart it.
Eli Zaretskii <eliz@gnu.org>
parents:
60232
diff
changeset
|
2659 (tex-start-shell)) |
48170
a65d281d19f0
(tex-dvi-view-command): Value can be sexp.
Richard M. Stallman <rms@gnu.org>
parents:
48120
diff
changeset
|
2660 (let ((tex-dvi-print-command (eval tex-dvi-view-command))) |
85 | 2661 (tex-print))) |
2662 | |
2663 (defun tex-append (file-name suffix) | |
2664 "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
|
2665 Pascal-based TeX scans for the first period, C TeX uses the last. |
85 | 2666 No period is retained immediately before SUFFIX, |
2667 so normally SUFFIX starts with one." | |
2668 (if (stringp file-name) | |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2669 (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
|
2670 trial-name) |
14383
af281a43a3bb
(tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
13399
diff
changeset
|
2671 ;; 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
|
2672 ;; 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
|
2673 ;; 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
|
2674 ;; 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
|
2675 (setq trial-name |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2676 (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
|
2677 (substring file 0 |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2678 (string-match "\\.[^.]*$" file)) |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2679 suffix)) |
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2680 (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
|
2681 (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
|
2682 trial-name |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2683 ;; 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
|
2684 (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
|
2685 (substring file 0 |
10778
ace814499178
(tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents:
10572
diff
changeset
|
2686 (string-match "\\." file)) |
4917
550746214170
(tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents:
4908
diff
changeset
|
2687 suffix))) |
85 | 2688 " ")) |
2689 | |
2690 (defun tex-show-print-queue () | |
2691 "Show the print queue that \\[tex-print] put your job on. | |
1577 | 2692 Runs the shell command defined by `tex-show-queue-command'." |
85 | 2693 (interactive) |
2694 (if (tex-shell-running) | |
2695 (tex-kill-job) | |
2696 (tex-start-shell)) | |
10572
c8717227f621
(tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents:
10341
diff
changeset
|
2697 (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
|
2698 (tex-display-shell)) |
85 | 2699 |
2700 (defun tex-bibtex-file () | |
2701 "Run BibTeX on the current buffer's file." | |
2702 (interactive) | |
2703 (if (tex-shell-running) | |
2704 (tex-kill-job) | |
2705 (tex-start-shell)) | |
100677
e2eada3200aa
(tex-bibtex-file): Use tex-main-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
99144
diff
changeset
|
2706 (let* (shell-dirtrack-verbose |
107155 | 2707 (source-file (expand-file-name (tex-main-file))) |
100677
e2eada3200aa
(tex-bibtex-file): Use tex-main-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
99144
diff
changeset
|
2708 (tex-out-file |
e2eada3200aa
(tex-bibtex-file): Use tex-main-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
99144
diff
changeset
|
2709 (tex-append (file-name-nondirectory source-file) "")) |
e2eada3200aa
(tex-bibtex-file): Use tex-main-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
99144
diff
changeset
|
2710 (file-dir (file-name-directory source-file))) |
65315
af6b70a1bba9
(tex-send-tex-command, tex-bibtex-file): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65267
diff
changeset
|
2711 (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
|
2712 (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
|
2713 (tex-display-shell)) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2714 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2715 ;;;; |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2716 ;;;; LaTeX indentation |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2717 ;;;; |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2718 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2719 (defvar tex-indent-allhanging t) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2720 (defvar tex-indent-arg 4) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2721 (defvar tex-indent-basic 2) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2722 (defvar tex-indent-item tex-indent-basic) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2723 (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>") |
57304
8d5af2441eda
(tex-dvi-view-command): Use `yap' on w32.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56843
diff
changeset
|
2724 (defvar latex-noindent-environments '("document")) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2725 |
51525
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2726 (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
|
2727 (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
|
2728 (modify-syntax-entry ?$ "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2729 (modify-syntax-entry ?\( "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2730 (modify-syntax-entry ?\) "." st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2731 st) |
ebea7b586362
(tex-mode-syntax-table, tex-latex-indent-syntax-table):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51336
diff
changeset
|
2732 "Syntax table used while computing indentation.") |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2733 |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2734 (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
|
2735 (if (and (eq (get-text-property (line-beginning-position) 'face) |
65706
183bad3fad1f
(tex-insert-quote, latex-indent): Quote face names.
Juanma Barranquero <lekktu@gmail.com>
parents:
65683
diff
changeset
|
2736 'tex-verbatim)) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2737 'noindent |
48222
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2738 (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
|
2739 ;; 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
|
2740 (let ((indent |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2741 (save-excursion |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2742 (beginning-of-line) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2743 (latex-find-indent)))) |
14763abde487
(latex-standard-block-names): Rename from standard-latex-block-names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48170
diff
changeset
|
2744 (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
|
2745 (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
|
2746 (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
|
2747 (save-excursion (indent-line-to indent))))))) |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2748 |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2749 (defcustom latex-indent-within-escaped-parens nil |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2750 "Non-nil means add extra indent to text within escaped parens. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2751 When this is non-nil, text within matching pairs of escaped |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2752 parens is indented at the column following the open paren. The |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2753 default value does not add any extra indent thus providing the |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2754 behavior of Emacs 22 and earlier." |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2755 :type 'boolean |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2756 :group 'tex |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2757 :version "23.1") |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2758 |
32479
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2759 (defun latex-find-indent (&optional virtual) |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2760 "Find the proper indentation of text after point. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2761 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
|
2762 in order to determine the indentation of something else. |
783ed0889617
Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32045
diff
changeset
|
2763 There might be text before point." |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2764 (let ((latex-handle-escaped-parens latex-indent-within-escaped-parens)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2765 (save-excursion |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2766 (skip-chars-forward " \t") |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2767 (or |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2768 ;; Stick the first line at column 0. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2769 (and (= (point-min) (line-beginning-position)) 0) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2770 ;; Trust the current indentation, if such info is applicable. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2771 (and virtual (save-excursion (skip-chars-backward " \t&") (bolp)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2772 (current-column)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2773 ;; Stick verbatim environments to the left margin. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2774 (and (looking-at "\\\\\\(begin\\|end\\) *{\\([^\n}]+\\)") |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2775 (member (match-string 2) tex-verbatim-environments) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2776 0) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2777 ;; Put leading close-paren where the matching open paren would be. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2778 (let (escaped) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2779 (and (or (eq (latex-syntax-after) ?\)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2780 ;; Try to handle escaped close parens but keep |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2781 ;; original position if it doesn't work out. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2782 (and latex-handle-escaped-parens |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2783 (setq escaped (looking-at "\\\\\\([])}]\\)")))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2784 (ignore-errors |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2785 (save-excursion |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2786 (when escaped |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2787 (goto-char (match-beginning 1))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2788 (latex-skip-close-parens) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2789 (latex-backward-sexp-1) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2790 (latex-find-indent 'virtual))))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2791 ;; Default (maybe an argument) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2792 (let ((pos (point)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2793 ;; Outdent \item if necessary. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2794 (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2795 up-list-pos) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2796 ;; Find the previous point which determines our current indentation. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2797 (condition-case err |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2798 (progn |
98312
d8a3b46ba292
(latex-find-indent): ... and handle conjunction correctly this time.
Martin Rudalics <rudalics@gmx.at>
parents:
98309
diff
changeset
|
2799 (latex-backward-sexp-1) |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2800 (while (> (current-column) (current-indentation)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2801 (latex-backward-sexp-1))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2802 (scan-error |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2803 (setq up-list-pos (nth 2 err)))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2804 (cond |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2805 ((= (point-min) pos) 0) ; We're really just indenting the first line. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2806 ((integerp up-list-pos) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2807 ;; Have to indent relative to the open-paren. |
37952
4192225498c7
(latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37942
diff
changeset
|
2808 (goto-char up-list-pos) |
98341
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2809 (if (and (not tex-indent-allhanging) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2810 (save-excursion |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2811 ;; Make sure we're an argument to a macro and |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2812 ;; that the macro is at the beginning of a line. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2813 (condition-case nil |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2814 (progn |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2815 (while (eq (char-syntax (char-after)) ?\() |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2816 (forward-sexp -1)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2817 (and (eq (char-syntax (char-after)) ?/) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2818 (progn (skip-chars-backward " \t&") |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2819 (bolp)))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2820 (scan-error nil))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2821 (> pos (progn (latex-down-list) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2822 (forward-comment (point-max)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2823 (point)))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2824 ;; Align with the first element after the open-paren. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2825 (current-column) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2826 ;; We're the first element after a hanging brace. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2827 (goto-char up-list-pos) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2828 (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)") |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2829 (member (match-string 1) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2830 latex-noindent-environments)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2831 0 tex-indent-basic) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2832 indent (latex-find-indent 'virtual)))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2833 ;; We're now at the "beginning" of a line. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2834 ((not (and (not virtual) (eq (char-after) ?\\))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2835 ;; Nothing particular here: just keep the same indentation. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2836 (+ indent (current-column))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2837 ;; We're now looking at a macro call. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2838 ((looking-at tex-indent-item-re) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2839 ;; Indenting relative to an item, have to re-add the outdenting. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2840 (+ indent (current-column) tex-indent-item)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2841 (t |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2842 (let ((col (current-column))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2843 (if (or (not (eq (char-syntax (or (char-after pos) ?\s)) ?\()) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2844 ;; Can't be an arg if there's an empty line inbetween. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2845 (save-excursion (re-search-forward "^[ \t]*$" pos t))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2846 ;; If the first char was not an open-paren, there's |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2847 ;; a risk that this is really not an argument to the |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2848 ;; macro at all. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2849 (+ indent col) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2850 (forward-sexp 1) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2851 (if (< (line-end-position) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2852 (save-excursion (forward-comment (point-max)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2853 (point))) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2854 ;; we're indenting the first argument. |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2855 (min (current-column) (+ tex-indent-arg col)) |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2856 (skip-syntax-forward " ") |
6708b77f19bf
(latex-handle-escaped-parens): New variable.
Martin Rudalics <rudalics@gmx.at>
parents:
98312
diff
changeset
|
2857 (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
|
2858 ;;; 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
|
2859 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2860 (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
|
2861 (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
|
2862 (progn |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2863 (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
|
2864 (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
|
2865 '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
|
2866 (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
|
2867 ;; 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
|
2868 ;; 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
|
2869 ;; 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
|
2870 ;; Instead, we include it in the ^^A comment. |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2871 (string-to-syntax "< b") |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2872 (string-to-syntax ">"))) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2873 (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
|
2874 (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
|
2875 (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
|
2876 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
|
2877 'syntax-table |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2878 (string-to-syntax "> b")))) |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2879 (string-to-syntax "< b")))) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2880 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2881 (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
|
2882 ;; 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
|
2883 ;; 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
|
2884 (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
|
2885 (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
|
2886 '(?\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
|
2887 ;; 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
|
2888 (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
|
2889 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
|
2890 |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2891 (eval-when-compile |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2892 (defconst doctex-syntax-propertize-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2893 (syntax-propertize-precompile-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2894 latex-syntax-propertize-rules |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2895 ;; For DocTeX comment-in-doc. |
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2896 ("\\(\\^\\)\\^A" (1 (doctex-font-lock-^^A)))))) |
50592
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2897 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2898 (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
|
2899 (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
|
2900 '(("^%<[^>]*>" (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
|
2901 |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2902 ;;;###autoload |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2903 (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
|
2904 "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
|
2905 (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
|
2906 (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
|
2907 (mapcar |
73473fb92184
(latex-mode-map): Bind latex-split-block to C-c C-s.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48931
diff
changeset
|
2908 (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
|
2909 (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
|
2910 (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
|
2911 (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
|
2912 (t x))) |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
2913 (cdr font-lock-defaults)))) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
2914 (set (make-local-variable 'syntax-propertize-function) |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
2915 (syntax-propertize-rules doctex-syntax-propertize-rules))) |
739
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2916 |
0bb85f26b79c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
657
diff
changeset
|
2917 (run-hooks 'tex-mode-load-hook) |
85 | 2918 |
584 | 2919 (provide 'tex-mode) |
2920 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2921 ;;; tex-mode.el ends here |