annotate lisp/textmodes/tex-mode.el @ 44286:1d7ee8515c45

Add an explicit check for 'text syntax, to protect against future enhancements to sgml-lexical-context. Add sgml-empty-tag-p and sgml-unclosed-tag-p.
author Mike Williams <mdub@bigfoot.com>
date Mon, 01 Apr 2002 12:08:13 +0000
parents f8e3c1819848
children 6c699f1e076c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 38083
diff changeset
1 ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
43307
7acf4e4617be (tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents: 38412
diff changeset
3 ;; Copyright (C) 1985, 86, 89, 92, 94, 95, 96, 97, 98, 1999, 2002
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
4 ;; Free Software Foundation, Inc.
840
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
5
10215
7690653b9231 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 10204
diff changeset
6 ;; Maintainer: FSF
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
7 ;; Keywords: tex
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
8
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
9 ;; Contributions over the years by William F. Schelter, Dick King,
10215
7690653b9231 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 10204
diff changeset
10 ;; Stephen Gildea, Michael Prange, Jacob Gore, and Edward M. Reingold.
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
11
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
13
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
17 ;; any later version.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
18
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
22 ;; GNU General Public License for more details.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
23
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
14383
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
27 ;; Boston, MA 02111-1307, USA.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
28
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 38083
diff changeset
29 ;;; Commentary:
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 38083
diff changeset
30
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
31 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 758
diff changeset
32
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
33 ;; Pacify the byte-compiler
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
34 (eval-when-compile
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
35 (require 'compare-w)
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
36 (require 'cl)
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
37 (require 'skeleton))
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
38
6632
652dc23b83fd (tex-start-shell): Use shell-mode-map (instead of comint-mode-map) because
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 6479
diff changeset
39 (require 'shell)
2576
48318133e7a6 (tex-compilation-parse-errors): Added. At the moment, this would have
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2571
diff changeset
40 (require 'compile)
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
41
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
42 (defgroup tex-file nil
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
43 "TeX files and directories"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
44 :prefix "tex-"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
45 :group 'tex)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
46
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
47 (defgroup tex-run nil
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
48 "Running external commands from TeX mode"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
49 :prefix "tex-"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
50 :group 'tex)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
51
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
52 (defgroup tex-view nil
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
53 "Viewing and printing TeX files"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
54 :prefix "tex-"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
55 :group 'tex)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
56
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
57 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
58 (defcustom tex-shell-file-name nil
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
59 "*If non-nil, the shell file name to run in the subshell used to run TeX."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
60 :type '(choice (const :tag "None" nil)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
61 string)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
62 :group 'tex-run)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
63
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
64 ;;;###autoload
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
65 (defcustom tex-directory "."
15916
61e90a3e66aa (tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15644
diff changeset
66 "*Directory in which temporary files are written.
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
67 You can make this `/tmp' if your TEXINPUTS has no relative directories in it
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
68 and you don't try to apply \\[tex-region] or \\[tex-buffer] when there are
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
69 `\\input' commands with relative directories."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
70 :type 'directory
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
71 :group 'tex-file)
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
72
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
73 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
74 (defcustom tex-first-line-header-regexp nil
16777
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
75 "Regexp for matching a first line which `tex-region' should include.
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
76 If this is non-nil, it should be a regular expression string;
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
77 if it matches the first line of the file,
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
78 `tex-region' always includes the first line in the TeX run."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
79 :type '(choice (const :tag "None" nil)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
80 regexp)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
81 :group 'tex-file)
16777
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
82
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
83 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
84 (defcustom tex-main-file nil
15916
61e90a3e66aa (tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15644
diff changeset
85 "*The main TeX source file which includes this buffer's file.
22847
31924d388b84 (tex-main-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22707
diff changeset
86 The command `tex-file' runs TeX on the file specified by `tex-main-file'
31924d388b84 (tex-main-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22707
diff changeset
87 if the variable is non-nil."
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
88 :type '(choice (const :tag "None" nil)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
89 file)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
90 :group 'tex-file)
15916
61e90a3e66aa (tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15644
diff changeset
91
61e90a3e66aa (tex-main-file): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15644
diff changeset
92 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
93 (defcustom tex-offer-save t
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
94 "*If non-nil, ask about saving modified buffers before \\[tex-file] is run."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
95 :type 'boolean
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
96 :group 'tex-file)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
97
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
98 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
99 (defcustom tex-run-command "tex"
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
100 "*Command used to run TeX subjob.
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
101 TeX Mode sets `tex-command' to this string.
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
102 See the documentation of that variable."
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
103 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
104 :group 'tex-run)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
105
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
106 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
107 (defcustom latex-run-command "latex"
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
108 "*Command used to run LaTeX subjob.
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
109 LaTeX Mode sets `tex-command' to this string.
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
110 See the documentation of that variable."
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
111 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
112 :group 'tex-run)
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
113
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
114 ;;;###autoload
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
115 (defcustom slitex-run-command "slitex"
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
116 "*Command used to run SliTeX subjob.
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
117 SliTeX Mode sets `tex-command' to this string.
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
118 See the documentation of that variable."
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
119 :type 'string
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
120 :group 'tex-run)
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
121
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
122 ;;;###autoload
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
123 (defcustom tex-start-options-string "\\nonstopmode\\input"
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
124 "*TeX options to use when running TeX.
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
125 These precede the input file name. If nil, TeX runs without option.
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
126 See the documentation of `tex-command'."
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
127 :type '(radio (const :tag "Interactive \(nil\)" nil)
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
128 (const :tag "Nonstop \(\"\\nonstopmode\\input\"\)"
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
129 "\\nonstopmode\\input")
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
130 (string :tag "String at your choice"))
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
131 :group 'tex-run
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
132 :version "20.4")
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
133
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
134 (defvar standard-latex-block-names
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
135 '("abstract" "array" "center" "description"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
136 "displaymath" "document" "enumerate" "eqnarray"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
137 "eqnarray*" "equation" "figure" "figure*"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
138 "flushleft" "flushright" "itemize" "letter"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
139 "list" "minipage" "picture" "quotation"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
140 "quote" "slide" "sloppypar" "tabbing"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
141 "table" "table*" "tabular" "tabular*"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
142 "thebibliography" "theindex*" "titlepage" "trivlist"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
143 "verbatim" "verbatim*" "verse" "math")
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
144 "Standard LaTeX block names.")
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
145
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
146 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
147 (defcustom latex-block-names nil
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
148 "*User defined LaTeX block names.
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
149 Combined with `standard-latex-block-names' for minibuffer completion."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
150 :type '(repeat string)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
151 :group 'tex-run)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
152
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
153 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
154 (defcustom tex-bibtex-command "bibtex"
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
155 "*Command used by `tex-bibtex-file' to gather bibliographic data.
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
156 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
157 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
158 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
159 :group 'tex-run)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
160
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
161 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
162 (defcustom tex-dvi-print-command "lpr -d"
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
163 "*Command used by \\[tex-print] to print a .dvi file.
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
164 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
165 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
166 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
167 :group 'tex-view)
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
168
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
169 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
170 (defcustom tex-alt-dvi-print-command "lpr -d"
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
171 "*Command used by \\[tex-print] with a prefix arg to print a .dvi file.
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
172 If this string contains an asterisk (`*'), that is replaced by the file name;
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
173 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
174
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
175 If two printers are not enough of a choice, you can set the variable
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
176 `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
177 for example,
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
178
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
179 (setq tex-alt-dvi-print-command
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
180 '(format \"lpr -P%s\" (read-string \"Use printer: \")))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
181
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
182 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
183 use."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
184 :type '(choice (string :tag "Command")
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
185 (sexp :tag "Expression"))
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
186 :group 'tex-view)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
187
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
188 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
189 (defcustom tex-dvi-view-command nil
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
190 "*Command used by \\[tex-view] to display a `.dvi' file.
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
191 If this string contains an asterisk (`*'), that is replaced by the file name;
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
192 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
193
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
194 This can be set conditionally so that the previewer used is suitable for the
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
195 window system being used. For example,
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
196
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
197 (setq tex-dvi-view-command
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
198 (if (eq window-system 'x) \"xdvi\" \"dvi2tty * | cat -s\"))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
199
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
200 would tell \\[tex-view] to use xdvi under X windows and to use dvi2tty
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
201 otherwise."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
202 :type '(choice (const nil) string)
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
203 :group 'tex-view)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
204
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
205 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
206 (defcustom tex-show-queue-command "lpq"
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
207 "*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
208 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
209 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
210 :group 'tex-view)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
211
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
212 ;;;###autoload
26270
14dbec3a82b4 (tex-default-mode): Changed to latex-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 25414
diff changeset
213 (defcustom tex-default-mode 'latex-mode
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
214 "*Mode to enter for a new file that might be either TeX or LaTeX.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
215 This variable is used when it can't be determined whether the file
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
216 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
217 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
218 :type 'function
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
219 :group 'tex)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
220
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
221 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
222 (defcustom tex-open-quote "``"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
223 "*String inserted by typing \\[tex-insert-quote] to open a quotation."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
224 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
225 :group 'tex)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
226
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 870
diff changeset
227 ;;;###autoload
17435
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
228 (defcustom tex-close-quote "''"
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
229 "*String inserted by typing \\[tex-insert-quote] to close a quotation."
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
230 :type 'string
b104a6fb7fa3 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16807
diff changeset
231 :group 'tex)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
232
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
233 (defvar tex-last-temp-file nil
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
234 "Latest temporary file generated by \\[tex-region] and \\[tex-buffer].
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
235 Deleted when the \\[tex-region] or \\[tex-buffer] is next run, or when the
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
236 tex shell terminates.")
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
237
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
238 (defvar tex-command nil
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
239 "*Command to run TeX.
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
240 If this string contains an asterisk \(`*'\), that is replaced by the file name\;
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
241 otherwise the \(shell-quoted\) value of `tex-start-options-string' and
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
242 the file name are added at the end, with blanks as separators.
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
243
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
244 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
245 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
246 current buffer.")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
247
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
248 (defvar tex-trailer nil
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
249 "String appended after the end of a region sent to TeX by \\[tex-region].")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
250
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
251 (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
252 "Regular expression used by \\[tex-region] to find start of file's header.")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
253
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
254 (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
255 "Regular expression used by \\[tex-region] to find end of file's header.")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
256
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
257 (defvar tex-shell-cd-command "cd"
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
258 "Command to give to shell running TeX to change directory.
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
259 The value of `tex-directory' is appended to this, separated by a space.")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
260
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
261 (defvar tex-zap-file nil
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
262 "Temporary file name used for text being sent as input to TeX.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
263 Should be a simple file name with no extension or directory specification.")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
264
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
265 (defvar tex-last-buffer-texed nil
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
266 "Buffer which was last TeXed.")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
267
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
268 (defvar tex-print-file nil
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
269 "File name that \\[tex-print] prints.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
270 Set by \\[tex-region], \\[tex-buffer], and \\[tex-file].")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
271
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
272 (easy-mmode-defsyntax tex-mode-syntax-table
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
273 '((?% . "<")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
274 (?\n . ">")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
275 (?\f . ">")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
276 (?\C-@ . "w")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
277 (?' . "w")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
278 (?@ . "_")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
279 (?* . "_")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
280 (?\t . " ")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
281 (?~ . " ")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
282 (?$ . "$$")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
283 (?\\ . "/")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
284 (?\" . ".")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
285 (?& . ".")
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
286 (?_ . ".")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
287 (?^ . "."))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
288 "Syntax table used while in TeX mode.")
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
289
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
290 ;;;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
291 ;;;; Imenu support
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
292 ;;;;
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
293
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
294 (defcustom latex-imenu-indent-string ". "
18393
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
295 "*String to add repeated in front of nested sectional units for Imenu.
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
296 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
297 :type 'string
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
298 :group 'tex)
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
299
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
300 (defvar latex-section-alist
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
301 '(("part" . 0) ("chapter" . 1)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
302 ("section" . 2) ("subsection" . 3)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
303 ("subsubsection" . 4)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
304 ("paragraph" . 5) ("subparagraph" . 6)))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
305
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
306 (defvar latex-metasection-list
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
307 '("documentstyle" "documentclass"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
308 "begin{document}" "end{document}"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
309 "appendix" "frontmatter" "mainmatter" "backmatter"))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
310
15240
21998d33460f (latex-imenu-create-index):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
311 (defun latex-imenu-create-index ()
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
312 "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
313 (let ((section-regexp
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
314 (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
315 "\\*?[ \t]*{"))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
316 (metasection-regexp
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
317 (concat "\\\\" (regexp-opt latex-metasection-list t)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
318 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
319 (save-excursion
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
320 ;; 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
321 ;; 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
322 (goto-char (point-min))
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
323 (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
324 (setq i0 0)
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
325 (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
326 (setq i0 1)
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
327 (setq i0 2)))
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
328
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
329 ;; Look for chapters and sections.
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
330 (goto-char (point-min))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
331 (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
332 (let ((start (match-beginning 0))
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
333 (here (point))
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
334 (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
335 (match-beginning 1)
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
336 (match-end 1))
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
337 latex-section-alist))))
18393
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
338 (backward-char 1)
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
339 (condition-case err
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
340 (progn
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
341 ;; 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
342 ;; titles.
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
343 (forward-sexp 1)
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
344 (push (cons (concat (apply 'concat
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
345 (make-list
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
346 (max 0 (- i i0))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
347 latex-imenu-indent-string))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
348 (buffer-substring-no-properties
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
349 here (1- (point))))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
350 start)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
351 menu))
18393
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
352 (error nil))))
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
353
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
354 ;; Look for included material.
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
355 (goto-char (point-min))
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
356 (while (search-forward-regexp
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
357 "\\\\\\(include\\|input\\|verbatiminput\\|bibliography\\)\
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
358 \[ \t]*{\\([^}\n]+\\)}"
18393
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
359 nil t)
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
360 (push (cons (concat "<<" (buffer-substring-no-properties
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
361 (match-beginning 2)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
362 (match-end 2))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
363 (if (= (char-after (match-beginning 1)) ?b)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
364 ".bbl"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
365 ".tex"))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
366 (match-beginning 0))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
367 menu))
18393
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
368
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
369 ;; 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
370 (goto-char (point-min))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
371 (while (search-forward-regexp metasection-regexp nil t)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
372 (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
373
f34e9defc58c (latex-imenu-create-index): Make it much smarter.
Richard M. Stallman <rms@gnu.org>
parents: 17435
diff changeset
374 ;; 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
375 (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
376
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
377 ;;;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
378 ;;;; Outline support
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
379 ;;;;
12704
0b36e50fb5af (latex-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents: 11617
diff changeset
380
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
381 (defvar latex-outline-regexp
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
382 (concat "\\\\"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
383 (regexp-opt (append latex-metasection-list
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
384 (mapcar 'car latex-section-alist)) t)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
385
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
386 (defun latex-outline-level ()
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
387 (if (looking-at latex-outline-regexp)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
388 (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
389 1000))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
390
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
391 ;;;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
392 ;;;; Font-Lock support
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
393 ;;;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
394
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
395 ;(defvar tex-font-lock-keywords
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
396 ; ;; 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
397 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
398 ; 2 font-lock-function-name-face)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
399 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
400 ; 2 font-lock-constant-face)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
401 ; ;; 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
402 ; ;; not be able to display those fonts.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
403 ; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
404 ; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
405 ; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
406 ; ("^[ \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
407 ; ;; 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
408 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
409 ; 2 font-lock-function-name-face)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
410 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
411 ; 2 font-lock-constant-face)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
412 ; ("^[ \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
413 ; "\\\\\\([a-zA-Z@]+\\|.\\)"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
414 ; ;; 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
415 ; ;; not be able to display those fonts.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
416 ; ;; LaTeX2e: \emph{This is emphasized}.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
417 ; ("\\\\emph{\\([^}]+\\)}" 1 'italic keep)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
418 ; ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...}
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
419 ; ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
420 ; 3 (if (match-beginning 2) 'bold 'italic) keep)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
421 ; ;; 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
422 ; ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
423 ; 3 (if (match-beginning 2) 'bold 'italic) keep))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
424
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
425 ;; 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
426 (defconst tex-font-lock-keywords-1
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
427 (eval-when-compile
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
428 (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
429 (headings (regexp-opt
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
430 '("title" "begin" "end" "chapter" "part"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
431 "section" "subsection" "subsubsection"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
432 "paragraph" "subparagraph" "subsubparagraph"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
433 "newcommand" "renewcommand" "newenvironment"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
434 "newtheorem")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
435 t))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
436 (variables (regexp-opt
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
437 '("newcounter" "newcounter*" "setcounter" "addtocounter"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
438 "setlength" "addtolength" "settowidth")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
439 t))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
440 (includes (regexp-opt
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
441 '("input" "include" "includeonly" "bibliography"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
442 "epsfig" "psfig" "epsf" "nofiles" "usepackage"
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
443 "documentstyle" "documentclass" "verbatiminput"
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
444 "includegraphics" "includegraphics*")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
445 t))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
446 ;; Miscellany.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
447 (slash "\\\\")
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
448 (opt " *\\(\\[[^]]*\\] *\\)*")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
449 ;; This would allow highlighting \newcommand\CMD but requires
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
450 ;; adapting subgroup numbers below.
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
451 ;; (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
452 (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)"))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
453 (list
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
454 ;; Heading args.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
455 (list (concat slash headings "\\*?" opt arg)
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
456 ;; If ARG ends up matching too much (if the {} don't match, f.ex)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
457 ;; 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
458 ;; 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
459 ;; 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
460 ;; 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
461 ;; 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
462 ;; 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
463 ;; 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
464 ;; 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
465 ;; 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
466 ;; 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
467 ;; have a comment in ARG.
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
468 3 'font-lock-function-name-face 'keep)
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
469 (list (concat slash "\\(re\\)?newcommand\\** *\\(\\\\[A-Za-z@]+\\)")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
470 2 'font-lock-function-name-face 'keep)
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
471 ;; Variable args.
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
472 (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
473 ;; Include args.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
474 (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
475 ;; Definitions. I think.
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
476 '("^[ \t]*\\\\def *\\\\\\(\\(\\w\\|@\\)+\\)"
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
477 1 font-lock-function-name-face))))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
478 "Subdued expressions to highlight in TeX modes.")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
479
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
480 (defconst tex-font-lock-keywords-2
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
481 (append tex-font-lock-keywords-1
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
482 (eval-when-compile
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
483 (let* (;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
484 ;; 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
485 (bold (regexp-opt '("textbf" "textsc" "textup"
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
486 "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
487 (italic (regexp-opt '("textit" "textsl" "emph") t))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
488 (type (regexp-opt '("texttt" "textmd" "textrm" "textsf") t))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
489 ;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
490 ;; 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
491 (citations (regexp-opt
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
492 '("label" "ref" "pageref" "vref" "eqref"
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
493 "cite" "nocite" "index" "glossary" "bibitem"
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
494 ;; 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
495 ;; "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
496 )
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
497 t))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
498 ;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
499 ;; 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
500 (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
501 (specials-2 (regexp-opt
7acf4e4617be (tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents: 38412
diff changeset
502 '("linebreak" "nolinebreak" "pagebreak" "nopagebreak"
7acf4e4617be (tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents: 38412
diff changeset
503 "newline" "newpage" "clearpage" "cleardoublepage"
7acf4e4617be (tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents: 38412
diff changeset
504 "displaybreak" "allowdisplaybreaks"
7acf4e4617be (tex-font-lock-keywords-2): Require non-letter after specials.
Andreas Schwab <schwab@suse.de>
parents: 38412
diff changeset
505 "enlargethispage") t))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
506 (general "\\([a-zA-Z@]+\\**\\|[^ \t\n]\\)")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
507 ;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
508 ;; Miscellany.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
509 (slash "\\\\")
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
510 (opt " *\\(\\[[^]]*\\] *\\)*")
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
511 (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)"))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
512 (list
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
513 ;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
514 ;; Citation args.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
515 (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
516 ;;
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
517 ;; Text between `` quotes ''.
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
518 (cons (concat (regexp-opt `("``" "\"<" "\"`" "<<" "«") t)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
519 "[^'\">»]+" ;a bit pessimistic
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
520 (regexp-opt `("''" "\">" "\"'" ">>" "»") t))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
521 'font-lock-string-face)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
522 ;;
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
523 ;; 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
524 (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
525 (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
526 1 'font-lock-warning-face)
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
527 (concat slash general)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
528 ;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
529 ;; 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
530 ;; since we might not be able to display those fonts.
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
531 (list (concat slash bold " *" arg) 2 '(quote bold) 'append)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
532 (list (concat slash italic " *" arg) 2 '(quote italic) 'append)
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
533 ;; (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
534 ;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
535 ;; 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
536 (list (concat "\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
537 "\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)")
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
538 3 '(if (match-beginning 2) 'bold 'italic) 'append)))))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
539 "Gaudy expressions to highlight in TeX modes.")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
540
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
541 (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
542 "Default expressions to highlight in TeX modes.")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
543
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
544
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
545 (defface tex-math-face
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
546 '((t :inherit font-lock-string-face))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
547 "Face used to highlight TeX math expressions.")
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
548 (defvar tex-math-face 'tex-math-face)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
549
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
550 ;; 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
551 (defun tex-font-lock-syntactic-face-function (state)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
552 (if (nth 3 state) tex-math-face font-lock-comment-face))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
553
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
554
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
555 (defun tex-define-common-keys (keymap)
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
556 "Define the keys that we want defined both in TeX mode and in the TeX shell."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
557 (define-key keymap "\C-c\C-k" 'tex-kill-job)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
558 (define-key keymap "\C-c\C-l" 'tex-recenter-output-buffer)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
559 (define-key keymap "\C-c\C-q" 'tex-show-print-queue)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
560 (define-key keymap "\C-c\C-p" 'tex-print)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
561 (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
562
be43750c20d2 (tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents: 4768
diff changeset
563 (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
564
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
565 (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
566 '(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
567 (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
568 '(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
569 :enable (get-buffer "*tex-shell*")))
4900
be43750c20d2 (tex-define-common-keys): Define menu items.
Richard M. Stallman <rms@gnu.org>
parents: 4768
diff changeset
570 (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
571 '("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
572 (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
573 '(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
574 :enable (stringp tex-print-file)))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
575 (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
576 '(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
577 (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
578 '(menu-item "Tex View" tex-view :enable (stringp tex-print-file))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
579
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
580 (defvar tex-mode-map
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
581 (let ((map (make-sparse-keymap)))
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
582 (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
583 (tex-define-common-keys map)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
584 (define-key map "\"" 'tex-insert-quote)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
585 (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
586 (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
587 (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
588 (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
589 (define-key map "\n" 'tex-terminate-paragraph)
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
590 (define-key map "\t" 'indent-for-tab-command)
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
591 (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
592 (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
593 (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
594 (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
595 (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
596 (define-key map "\C-c\C-f" 'tex-file)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
597 (define-key map "\C-c\C-i" 'tex-bibtex-file)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
598 (define-key map "\C-c\C-o" 'tex-latex-block)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
599 (define-key map "\C-c\C-e" 'tex-close-latex-block)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
600 (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
601 (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
602 (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
603 (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
604 '("BibTeX File" . tex-bibtex-file))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
605 (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
606 '(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
607 (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
608 '("Validate Buffer" . tex-validate-buffer))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
609 (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
610 '(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
611 (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
612 '("TeX Buffer" . tex-buffer))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
613 (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
614 map)
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
615 "Keymap shared by TeX modes.")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
616
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
617 (defvar latex-mode-map
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
618 (let ((map (make-sparse-keymap)))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
619 (set-keymap-parent map tex-mode-map)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
620 map)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
621 "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
622
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
623 (defvar plain-tex-mode-map
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
624 (let ((map (make-sparse-keymap)))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
625 (set-keymap-parent map tex-mode-map)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
626 map)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
627 "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
628
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
629 (defvar tex-shell-map
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
630 (let ((m (make-sparse-keymap)))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
631 (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
632 (tex-define-common-keys m)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
633 m)
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
634 "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
635 Inherits `shell-mode-map' with a few additions.")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
636
14383
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
637 (defvar tex-face-alist
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
638 '((bold . "{\\bf ")
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
639 (italic . "{\\it ")
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
640 (bold-italic . "{\\bi ") ; hypothetical
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
641 (underline . "\\underline{")
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
642 (default . "{\\rm "))
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
643 "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
644
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
645 (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
646 `((italic . "{\\em ")
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
647 ,@tex-face-alist)
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
648 "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
649
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
650 ;; 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
651 ;; but then it would be too slow.
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 85
diff changeset
652 ;;;###autoload
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
653 (defun tex-mode ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
654 "Major mode for editing files of input for TeX, LaTeX, or SliTeX.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
655 Tries to determine (by looking at the beginning of the file) whether
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
656 this file is for plain TeX, LaTeX, or SliTeX and calls `plain-tex-mode',
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
657 `latex-mode', or `slitex-mode', respectively. If it cannot be determined,
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
658 such as if there are no commands in the file, the value of `tex-default-mode'
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
659 says which mode to use."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
660 (interactive)
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
661 (let ((mode tex-default-mode) slash comment)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
662 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
663 (goto-char (point-min))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
664 (while (and (setq slash (search-forward "\\" nil t))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
665 (setq comment (let ((search-end (point)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
666 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
667 (beginning-of-line)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
668 (search-forward "%" search-end t))))))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
669 (when (and slash (not comment))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
670 (setq mode
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
671 (if (looking-at
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
672 (eval-when-compile
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
673 (concat
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
674 (regexp-opt '("documentstyle" "documentclass"
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
675 "begin" "section" "part" "chapter") 'words)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
676 "\\|NeedsTeXFormat{LaTeX")))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
677 (if (looking-at
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
678 "document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
679 'slitex-mode
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
680 'latex-mode)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
681 'plain-tex-mode))))
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
682 (funcall mode)))
2598
2189edb30955 Removed spurious comment (obsoleted by ;;;###autoload).
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2588
diff changeset
683
269
2ca8cdb96a9f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
684 ;;;###autoload
2571
b65cf676a09b All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
685 (defalias 'TeX-mode 'tex-mode)
269
2ca8cdb96a9f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 256
diff changeset
686 ;;;###autoload
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
687 (defalias 'plain-TeX-mode 'plain-tex-mode)
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
688 ;;;###autoload
2571
b65cf676a09b All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
689 (defalias 'LaTeX-mode 'latex-mode)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
690
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 85
diff changeset
691 ;;;###autoload
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
692 (define-derived-mode plain-tex-mode text-mode "TeX"
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
693 "Major mode for editing files of input for plain TeX.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
694 Makes $ and } display the characters they match.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
695 Makes \" insert `` when it seems to be the beginning of a quotation,
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
696 and '' when it appears to be the end; it inserts \" only after a \\.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
697
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
698 Use \\[tex-region] to run TeX on the current region, plus a \"header\"
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
699 copied from the top of the file (containing macro definitions, etc.),
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
700 running TeX under a special subshell. \\[tex-buffer] does the whole buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
701 \\[tex-file] saves the buffer and then processes the file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
702 \\[tex-print] prints the .dvi file made by any of these.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
703 \\[tex-view] previews the .dvi file made by any of these.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
704 \\[tex-bibtex-file] runs bibtex on the file of the current buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
705
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
706 Use \\[tex-validate-buffer] to check buffer for paragraphs containing
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
707 mismatched $'s or braces.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
708
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
709 Special commands:
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
710 \\{plain-tex-mode-map}
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
711
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
712 Mode variables:
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
713 tex-run-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
714 Command string used by \\[tex-region] or \\[tex-buffer].
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
715 tex-directory
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
716 Directory in which to create temporary files for TeX jobs
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
717 run by \\[tex-region] or \\[tex-buffer].
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
718 tex-dvi-print-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
719 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
720 tex-alt-dvi-print-command
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
721 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
722 argument) to print a .dvi file.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
723 tex-dvi-view-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
724 Command string used by \\[tex-view] to preview a .dvi file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
725 tex-show-queue-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
726 Command string used by \\[tex-show-print-queue] to show the print
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
727 queue that \\[tex-print] put your job on.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
728
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
729 Entering Plain-tex mode runs the hook `text-mode-hook', then the hook
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
730 `tex-mode-hook', and finally the hook `plain-tex-mode-hook'. When the
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
731 special subshell is initiated, the hook `tex-shell-hook' is run."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
732 (tex-common-initialization)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
733 (setq tex-command tex-run-command)
13248
a7e83f7eb499 (tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents: 12704
diff changeset
734 (setq tex-start-of-header "%\\*\\*start of header")
a7e83f7eb499 (tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents: 12704
diff changeset
735 (setq tex-end-of-header "%\\*\\*end of header")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
736 (setq tex-trailer "\\bye\n")
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
737 (run-hooks 'tex-mode-hook))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
738
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 85
diff changeset
739 ;;;###autoload
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
740 (define-derived-mode latex-mode text-mode "LaTeX"
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
741 "Major mode for editing files of input for LaTeX.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
742 Makes $ and } display the characters they match.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
743 Makes \" insert `` when it seems to be the beginning of a quotation,
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
744 and '' when it appears to be the end; it inserts \" only after a \\.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
745
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
746 Use \\[tex-region] to run LaTeX on the current region, plus the preamble
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
747 copied from the top of the file (containing \\documentstyle, etc.),
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
748 running LaTeX under a special subshell. \\[tex-buffer] does the whole buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
749 \\[tex-file] saves the buffer and then processes the file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
750 \\[tex-print] prints the .dvi file made by any of these.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
751 \\[tex-view] previews the .dvi file made by any of these.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
752 \\[tex-bibtex-file] runs bibtex on the file of the current buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
753
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
754 Use \\[tex-validate-buffer] to check buffer for paragraphs containing
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
755 mismatched $'s or braces.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
756
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
757 Special commands:
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
758 \\{latex-mode-map}
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
759
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
760 Mode variables:
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
761 latex-run-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
762 Command string used by \\[tex-region] or \\[tex-buffer].
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
763 tex-directory
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
764 Directory in which to create temporary files for LaTeX jobs
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
765 run by \\[tex-region] or \\[tex-buffer].
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
766 tex-dvi-print-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
767 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
768 tex-alt-dvi-print-command
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
769 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
770 argument) to print a .dvi file.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
771 tex-dvi-view-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
772 Command string used by \\[tex-view] to preview a .dvi file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
773 tex-show-queue-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
774 Command string used by \\[tex-show-print-queue] to show the print
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
775 queue that \\[tex-print] put your job on.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
776
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
777 Entering Latex mode runs the hook `text-mode-hook', then
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
778 `tex-mode-hook', and finally `latex-mode-hook'. When the special
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
779 subshell is initiated, `tex-shell-hook' is run."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
780 (tex-common-initialization)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
781 (setq tex-command latex-run-command)
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
782 (setq tex-start-of-header "\\\\document\\(style\\|class\\)")
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
783 (setq tex-end-of-header "\\\\begin\\s-*{document}")
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
784 (setq tex-trailer "\\end\\s-*{document}\n")
5425
3dd5ff54e1cd (slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents: 5262
diff changeset
785 ;; 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
786 ;; 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
787 ;; 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
788 (setq paragraph-start
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
789 (concat "[\f%]\\|[ \t]*\\($\\|\\$\\$\\|"
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
790 "\\\\[][]\\|"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
791 "\\\\" (regexp-opt (append
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
792 (mapcar 'car latex-section-alist)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
793 '("begin" "label" "end"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
794 "item" "bibitem" "newline" "noindent"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
795 "newpage" "footnote" "marginpar"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
796 "parbox" "caption")) t)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
797 "\\>\\|\\\\[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
798 "\\>\\)"))
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
799 (setq paragraph-separate
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
800 (concat "[\f%]\\|[ \t]*\\($\\|"
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
801 "\\\\[][]\\|"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
802 "\\\\" (regexp-opt (append
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
803 (mapcar 'car latex-section-alist)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
804 '("begin" "label" "end" )) t)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
805 "\\>\\|\\\\\\(" (regexp-opt '("item" "bibitem" "newline"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
806 "noindent" "newpage" "footnote"
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
807 "marginpar" "parbox" "caption"))
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
808 "\\|\\$\\$\\|[a-z]*\\(space\\|skip\\|page[a-z]*\\)"
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
809 "\\>\\)[ \t]*\\($\\|%\\)\\)"))
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
810 (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
811 'latex-imenu-create-index)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
812 (set (make-local-variable 'tex-face-alist) tex-latex-face-alist)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
813 (set (make-local-variable 'fill-nobreak-predicate)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
814 'latex-fill-nobreak-predicate)
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
815 (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
816 (set (make-local-variable 'fill-indent-according-to-mode) t)
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
817 (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
818 (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
819 (set (make-local-variable 'forward-sexp-function) 'latex-forward-sexp)
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
820 (set (make-local-variable 'skeleton-end-hook) nil)
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
821 (run-hooks 'tex-mode-hook))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
822
4768
9d84105b1248 (slitex-mode): Add ###autoload magic cookie.
Brian Fox <bfox@gnu.org>
parents: 4376
diff changeset
823 ;;;###autoload
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
824 (define-derived-mode slitex-mode latex-mode "SliTeX"
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
825 "Major mode for editing files of input for SliTeX.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
826 Makes $ and } display the characters they match.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
827 Makes \" insert `` when it seems to be the beginning of a quotation,
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
828 and '' when it appears to be the end; it inserts \" only after a \\.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
829
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
830 Use \\[tex-region] to run SliTeX on the current region, plus the preamble
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
831 copied from the top of the file (containing \\documentstyle, etc.),
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
832 running SliTeX under a special subshell. \\[tex-buffer] does the whole buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
833 \\[tex-file] saves the buffer and then processes the file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
834 \\[tex-print] prints the .dvi file made by any of these.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
835 \\[tex-view] previews the .dvi file made by any of these.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
836 \\[tex-bibtex-file] runs bibtex on the file of the current buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
837
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
838 Use \\[tex-validate-buffer] to check buffer for paragraphs containing
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
839 mismatched $'s or braces.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
840
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
841 Special commands:
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
842 \\{slitex-mode-map}
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
843
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
844 Mode variables:
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
845 slitex-run-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
846 Command string used by \\[tex-region] or \\[tex-buffer].
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
847 tex-directory
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
848 Directory in which to create temporary files for SliTeX jobs
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
849 run by \\[tex-region] or \\[tex-buffer].
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
850 tex-dvi-print-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
851 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
852 tex-alt-dvi-print-command
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
853 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
854 argument) to print a .dvi file.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
855 tex-dvi-view-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
856 Command string used by \\[tex-view] to preview a .dvi file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
857 tex-show-queue-command
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
858 Command string used by \\[tex-show-print-queue] to show the print
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
859 queue that \\[tex-print] put your job on.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
860
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
861 Entering SliTeX mode runs the hook `text-mode-hook', then the hook
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
862 `tex-mode-hook', then the hook `latex-mode-hook', and finally the hook
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
863 `slitex-mode-hook'. When the special subshell is initiated, the hook
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
864 `tex-shell-hook' is run."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
865 (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
866 (setq tex-start-of-header "\\\\documentstyle{slides}\\|\\\\documentclass{slides}"))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
867
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
868 (defun tex-common-initialization ()
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
869 (set-syntax-table tex-mode-syntax-table)
18587
3290767e31d8 (tex-common-initialization):
Richard M. Stallman <rms@gnu.org>
parents: 18393
diff changeset
870 ;; 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
871 (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
872 ;; 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
873 (set (make-local-variable 'paragraph-start)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
874 "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$")
5425
3dd5ff54e1cd (slitex-mode, latex-mode): Set paragraph-start and
Richard M. Stallman <rms@gnu.org>
parents: 5262
diff changeset
875 ;; 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
876 ;; 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
877 (set (make-local-variable 'paragraph-separate)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
878 "[ \t]*$\\|[\f\\\\%]\\|[ \t]*\\$\\$[ \t]*$")
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
879 (set (make-local-variable 'comment-start) "%")
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
880 (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
881 (set (make-local-variable 'comment-start-skip)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
882 "\\(\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\)\\(%+ *\\)")
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
883 (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
884 (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
885 'tex-categorize-whitespace)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
886 (set (make-local-variable 'facemenu-add-face-function)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
887 (lambda (face end)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
888 (let ((face-text (cdr (assq face tex-face-alist))))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
889 (if face-text
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
890 face-text
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
891 (error "Face %s not configured for %s mode" face mode-name)))))
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
892 (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
893 (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
894 (set (make-local-variable 'font-lock-defaults)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
895 '((tex-font-lock-keywords
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
896 tex-font-lock-keywords-1 tex-font-lock-keywords-2)
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
897 nil nil ((?$ . "\"")) nil
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
898 ;; Who ever uses that anyway ???
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
899 (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
900 (font-lock-syntactic-face-function
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
901 . tex-font-lock-syntactic-face-function)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
902 (make-local-variable 'tex-command)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
903 (make-local-variable 'tex-start-of-header)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
904 (make-local-variable 'tex-end-of-header)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
905 (make-local-variable 'tex-trailer))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
906
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
907 (defun tex-categorize-whitespace (backward-limit)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
908 ;; compare-windows-whitespace is set to this.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
909 ;; This is basically a finite-state machine.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
910 ;; Returns a symbol telling how TeX would treat
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
911 ;; the whitespace we are looking at: null, space, or par.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
912 (let ((category 'null)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
913 (not-finished t))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
914 (skip-chars-backward " \t\n\f" backward-limit)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
915 (while not-finished
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
916 (cond ((looking-at "[ \t]+")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
917 (goto-char (match-end 0))
18931
43b52e6a35c2 (tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents: 18587
diff changeset
918 (if (eq category 'null)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
919 (setq category 'space)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
920 ((looking-at "\n")
18931
43b52e6a35c2 (tex-categorize-whitespace): Use eq, not eql.
Richard M. Stallman <rms@gnu.org>
parents: 18587
diff changeset
921 (cond ((eq category 'newline)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
922 (setq category 'par)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
923 (setq not-finished nil))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
924 (t
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
925 (setq category 'newline) ;a strictly internal state
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
926 (goto-char (match-end 0)))))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
927 ((looking-at "\f+")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
928 (setq category 'par)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
929 (setq not-finished nil))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
930 (t
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
931 (setq not-finished nil))))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
932 (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
933 (if (eq category 'newline)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
934 'space ;TeX doesn't distinguish
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
935 category)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
936
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
937 (defun tex-insert-quote (arg)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
938 "Insert the appropriate quote marks for TeX.
2836
d95acb2243f9 (tex-insert-quote): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 2598
diff changeset
939 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
940 \(normally '') depending on the context. With prefix argument, always
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
941 inserts \" characters."
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
942 (interactive "*P")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
943 (if arg
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
944 (self-insert-command (prefix-numeric-value arg))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
945 (insert
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
946 (cond ((= (preceding-char) ?\\) ?\")
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
947 ((memq (char-syntax (preceding-char)) '(?\( ?> ?\ )) tex-open-quote)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
948 (t tex-close-quote)))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
949
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
950 (defun tex-validate-buffer ()
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
951 "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
952 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
953 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
954 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
955 on the line for the invalidity you want to see."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
956 (interactive)
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
957 (let ((buffer (current-buffer))
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
958 (prevpos (point-min))
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
959 (linenum nil)
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
960 (num-matches 0))
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
961 (with-output-to-temp-buffer "*Occur*"
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
962 (princ "Mismatches:\n")
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
963 (save-excursion
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
964 (set-buffer standard-output)
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
965 (occur-mode)
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
966 (setq occur-buffer buffer)
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
967 (setq occur-nlines 0))
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
968 (save-excursion
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
969 (goto-char (point-max))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
970 (while (and (not (input-pending-p)) (not (bobp)))
15644
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
971 (let ((end (point))
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
972 prev-end)
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
973 ;; Scan the previous paragraph for invalidities.
15644
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
974 (if (search-backward "\n\n" nil t)
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
975 (progn
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
976 (setq prev-end (point))
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
977 (forward-char 2))
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
978 (goto-char (setq prev-end (point-min))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
979 (or (tex-validate-region (point) end)
15644
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
980 (let* ((oend end)
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
981 (end (save-excursion (forward-line 1) (point)))
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
982 start tem)
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
983 (beginning-of-line)
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
984 (setq start (point))
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
985 ;; 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
986 ;; in a cumulative fashion.
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
987 (if linenum
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
988 (setq linenum (- linenum (count-lines prevpos (point))))
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
989 (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
990 (setq prevpos (point))
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
991 ;; Mention this mismatch in *Occur*.
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
992 ;; 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
993 ;; 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
994 (save-excursion
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
995 (setq tem (point-marker))
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
996 (set-buffer standard-output)
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
997 (goto-char (point-min))
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
998 ;; Skip "Mismatches:" header line.
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
999 (forward-line 1)
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1000 (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
1001 (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
1002 (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
1003 (forward-char (- start end))
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1004 (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
1005 (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
1006 (add-text-properties
745b05b3e5ed (tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents: 37952
diff changeset
1007 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
1008 '(mouse-face highlight
745b05b3e5ed (tex-validate-buffer): Add help-echo to mouse-highlighted text.
Eli Zaretskii <eliz@gnu.org>
parents: 37952
diff changeset
1009 help-echo "mouse-2: go to this invalidity"))
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
1010 (put-text-property text-beg (- text-end 1)
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1011 'occur tem)))))
15644
3b4678aa4e9f (tex-validate-region): Skip fwd over whitespace
Karl Heuer <kwzh@gnu.org>
parents: 15513
diff changeset
1012 (goto-char prev-end))))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1013 (with-current-buffer standard-output
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1014 (if (eq num-matches 0)
4376
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1015 (insert "None!\n"))
109294166e68 (validate-tex-buffer): Record mismatches in *Occur*.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1016 (if (interactive-p)
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1017 (message "%d mismatches found" num-matches))))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1018
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1019 (defun tex-validate-region (start end)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1020 "Check for mismatched braces or $'s in region.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1021 Returns t if no mismatches. Returns nil and moves point to suspect
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1022 area if a mismatch is found."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1023 (interactive "r")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1024 (let ((failure-point nil) (max-possible-sexps (- end start)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1025 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1026 (condition-case ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1027 (save-restriction
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1028 (narrow-to-region start end)
20203
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1029 ;; First check that the open and close parens balance in numbers.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1030 (goto-char start)
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1031 (while (<= 0 (setq max-possible-sexps (1- max-possible-sexps)))
20203
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1032 (forward-sexp 1))
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1033 ;; Now check that like matches like.
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1034 (goto-char start)
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1035 (while (progn (skip-syntax-forward "^(")
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1036 (not (eobp)))
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1037 (let ((match (matching-paren (following-char))))
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1038 (save-excursion
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1039 (forward-sexp 1)
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1040 (or (= (preceding-char) match)
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1041 (error "Mismatched parentheses"))))
f1a4588c8075 (tex-validate-region): Really check
Karl Heuer <kwzh@gnu.org>
parents: 18931
diff changeset
1042 (forward-char 1)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1043 (error
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1044 (skip-syntax-forward " .>")
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1045 (setq failure-point (point)))))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1046 (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
1047 (not failure-point)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1048
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1049 (defun tex-terminate-paragraph (inhibit-validation)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1050 "Insert two newlines, breaking a paragraph for TeX.
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
1051 Check for mismatched braces or $s in paragraph being terminated.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1052 A prefix arg inhibits the checking."
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1053 (interactive "*P")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1054 (or inhibit-validation
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1055 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1056 (tex-validate-region
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1057 (save-excursion
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1058 (search-backward "\n\n" nil 'move)
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1059 (point))
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1060 (point)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1061 (message "Paragraph being closed appears to contain a mismatch"))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1062 (insert "\n\n"))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1063
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1064 (defun tex-insert-braces ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1065 "Make a pair of braces and be poised to type inside of them."
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1066 (interactive "*")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1067 (insert ?\{)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1068 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1069 (insert ?})))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1070
21121
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1071 ;; 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
1072 ;; 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
1073 ;; of a \verb construct.
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1074 (defun latex-fill-nobreak-predicate ()
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1075 (let ((opoint (point))
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1076 inside)
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1077 (save-excursion
21121
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1078 (save-restriction
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1079 (beginning-of-line)
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1080 (narrow-to-region (point) opoint)
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1081 (while (re-search-forward "\\\\verb\\(.\\)" nil t)
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1082 (unless (re-search-forward (regexp-quote (match-string 1)) nil t)
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1083 (setq inside t)))))
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1084 inside))
dd5c2baa6674 (latex-mode): Set fill-nobreak-predicate.
Richard M. Stallman <rms@gnu.org>
parents: 20203
diff changeset
1085
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1086 (defvar latex-block-default "enumerate")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1087
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1088 ;; Like tex-insert-braces, but for LaTeX.
15513
1252826f389b (tex-common-initialization): Set skeleton-further-elements.
Richard M. Stallman <rms@gnu.org>
parents: 15240
diff changeset
1089 (define-skeleton tex-latex-block
1252826f389b (tex-common-initialization): Set skeleton-further-elements.
Richard M. Stallman <rms@gnu.org>
parents: 15240
diff changeset
1090 "Create a matching pair of lines \\begin[OPT]{NAME} and \\end{NAME} at point.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1091 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
1092 (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
1093 latex-block-default)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1094 (mapcar 'list
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1095 (append standard-latex-block-names
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1096 latex-block-names))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1097 nil nil nil nil latex-block-default)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1098 (setq latex-block-default choice)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1099 (unless (or (member choice standard-latex-block-names)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1100 (member choice latex-block-names))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1101 ;; Remember new block names for later completion.
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1102 (push choice latex-block-names))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1103 choice)
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1104 \n "\\begin{" str ?\}
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1105 ?\[ (skeleton-read "[options]: ") & ?\] | -1
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1106 > \n _ \n
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1107 "\\end{" str ?\} > \n)
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1108
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1109 (define-skeleton latex-insert-item
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1110 "Insert a \item macro."
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1111 nil
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1112 \n "\\item " >)
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1113
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1114
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1115 ;;;;
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1116 ;;;; LaTeX syntax navigation
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1117 ;;;;
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1118
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1119 (defun tex-last-unended-begin ()
7285
27e6ef8494b2 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 6632
diff changeset
1120 "Leave point at the beginning of the last `\\begin{...}' that is unended."
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1121 (while (and (re-search-backward "\\\\\\(begin\\|end\\)\\s *{")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1122 (looking-at "\\\\end"))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1123 (tex-last-unended-begin)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1124
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1125 (defun tex-next-unmatched-end ()
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1126 "Leave point at the end of the next `\\end' that is unended."
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1127 (while (and (re-search-forward "\\\\\\(begin\\|end\\)\\s *{[^}]+}")
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1128 (save-excursion (goto-char (match-beginning 0))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1129 (looking-at "\\\\begin")))
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1130 (tex-next-unmatched-end)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1131
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
1132 (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
1133 "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
1134 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
1135 (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
1136 (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
1137 (save-excursion
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
1138 (condition-case nil
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
1139 (tex-last-unended-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
1140 (error (error "Couldn't find unended \\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
1141 (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
1142 (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
1143 (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
1144
32045
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1145 (defun latex-backward-sexp-1 ()
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1146 "Like (backward-sexp 1) but aware of multi-char elements."
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1147 (let ((pos (point))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1148 (forward-sexp-function))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1149 (backward-sexp 1)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1150 (if (looking-at "\\\\begin\\>")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1151 (signal 'scan-error
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1152 (list "Containing expression ends prematurely"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1153 (point) (prog1 (point) (goto-char pos))))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1154 (when (eq (char-after) ?{)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1155 (let ((newpos (point)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1156 (when (ignore-errors (backward-sexp 1) t)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1157 (if (looking-at "\\\\end\\>")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1158 (tex-last-unended-begin)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1159 (goto-char newpos))))))))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1160
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1161 (defun latex-forward-sexp-1 ()
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1162 "Like (forward-sexp 1) but aware of multi-char elements."
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1163 (let ((pos (point))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1164 (forward-sexp-function))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1165 (forward-sexp 1)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1166 (let ((newpos (point)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1167 (skip-syntax-backward "/w")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1168 (cond
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1169 ((looking-at "\\\\end\\>")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1170 (signal 'scan-error
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1171 (list "Containing expression ends prematurely"
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1172 (point)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1173 (prog1
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1174 (progn (ignore-errors (forward-sexp 2)) (point))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1175 (goto-char pos)))))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1176 ((looking-at "\\\\begin\\>")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1177 (goto-char (match-end 0))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1178 (tex-next-unmatched-end))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1179 (t (goto-char newpos))))))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1180
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1181 (defun latex-forward-sexp (&optional arg)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1182 "Like `forward-sexp' but aware of multi-char elements."
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1183 (interactive "P")
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1184 (unless arg (setq arg 1))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1185 (let ((pos (point)))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1186 (condition-case err
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1187 (while (/= arg 0)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1188 (setq arg
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1189 (if (> arg 0)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1190 (progn (latex-forward-sexp-1) (1- arg))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1191 (progn (latex-backward-sexp-1) (1+ arg)))))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1192 (scan-error
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1193 (goto-char pos)
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1194 (signal (car err) (cdr err))))))
74db1ffe4fe8 (latex-metasection-list): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31990
diff changeset
1195
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1196 (defun latex-syntax-after ()
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1197 "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
1198 (if (looking-at "\\\\end\\>") ?\) (char-syntax (following-char))))
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1199
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1200 (defun latex-skip-close-parens ()
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1201 "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
1202 (let ((forward-sexp-function nil))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1203 (while (progn (skip-syntax-forward " )")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1204 (looking-at "\\\\end\\>"))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1205 (forward-sexp 2))))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1206
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1207 (defun latex-down-list ()
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1208 "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
1209 (forward-comment (point-max))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1210 (let ((forward-sexp-function nil))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1211 (if (not (looking-at "\\\\begin\\>"))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1212 (down-list 1)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1213 (forward-sexp 1)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1214 ;; Skip arguments.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1215 (while (looking-at "[ \t]*\\s(") (forward-sexp)))))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1216
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1217 (defun tex-close-latex-block ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1218 "Creates an \\end{...} to match the last unclosed \\begin{...}."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1219 (interactive "*")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1220 (let ((new-line-needed (bolp))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1221 text indentation)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1222 (save-excursion
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1223 (condition-case nil
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1224 (tex-last-unended-begin)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1225 (error (error "Couldn't find unended \\begin")))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1226 (setq indentation (current-column))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1227 (re-search-forward "\\\\begin\\(\\s *{[^}\n]*}\\)")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1228 (setq text (buffer-substring (match-beginning 1) (match-end 1))))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1229 (indent-to indentation)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1230 (insert "\\end" text)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1231 (if new-line-needed (insert ?\n))))
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1232
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1233 (defconst tex-discount-args-cmds
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1234 '("begin" "end" "input" "special" "cite" "ref" "include" "includeonly"
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1235 "documentclass" "usepackage" "label")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1236 "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
1237
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1238 (defun tex-count-words (begin end)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1239 "Count the number of words in the buffer."
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1240 (interactive
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1241 (if (and transient-mark-mode mark-active)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1242 (list (region-beginning) (region-end))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1243 (list (point-min) (point-max))))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1244 ;; 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
1245 (save-excursion
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1246 (goto-char begin)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1247 (let ((count 0))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1248 (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
1249 (if (not (eq (char-syntax (preceding-char)) ?/))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1250 (progn
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1251 ;; Don't count single-char words.
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1252 (unless (looking-at ".\\>") (incf count))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1253 (forward-char 1))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1254 (let ((cmd
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1255 (buffer-substring-no-properties
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1256 (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
1257 (forward-char 1))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1258 (point)))))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1259 (when (member cmd tex-discount-args-cmds)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1260 (skip-chars-forward "*")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1261 (forward-comment (point-max))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1262 (when (looking-at "\\[")
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1263 (forward-sexp 1)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1264 (forward-comment (point-max)))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1265 (if (not (looking-at "{"))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1266 (forward-char 1)
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1267 (forward-sexp 1))))))
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1268 (message "%s words" count))))
37942
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1269
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1270
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1271
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1272 ;;; Invoking TeX in an inferior shell.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1273
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1274 ;; 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
1275 ;; gets stuck, the user can switch to the shell window and type at it.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1276
37896
5cc52d5c2f2b (tex-mode-syntax-table): Add ^.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36105
diff changeset
1277 ;; The utility functions:
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1278
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1279 (define-derived-mode tex-shell shell-mode "TeX-Shell"
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1280 (compilation-shell-minor-mode t))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1281
7834
fc1c95bf734b (tex-start-shell): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents: 7827
diff changeset
1282 ;;;###autoload
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1283 (defun tex-start-shell ()
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1284 (with-current-buffer
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1285 (make-comint
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1286 "tex-shell"
34139
358adc86d127 (tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33789
diff changeset
1287 (or tex-shell-file-name (getenv "ESHELL") shell-file-name)
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1288 nil)
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1289 (let ((proc (get-process "tex-shell")))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1290 (set-process-sentinel proc 'tex-shell-sentinel)
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1291 (process-kill-without-query proc)
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1292 (tex-shell)
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1293 (while (zerop (buffer-size))
10572
c8717227f621 (tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents: 10341
diff changeset
1294 (sleep-for 1)))))
c8717227f621 (tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents: 10341
diff changeset
1295
23761
a99c30431979 (tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents: 23642
diff changeset
1296 (defun tex-feed-input ()
a99c30431979 (tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents: 23642
diff changeset
1297 "Send input to the tex shell process.
a99c30431979 (tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents: 23642
diff changeset
1298 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
1299 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
1300 (interactive)
37942
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1301 (set-buffer (tex-shell-buf))
23761
a99c30431979 (tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents: 23642
diff changeset
1302 (comint-send-input)
a99c30431979 (tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents: 23642
diff changeset
1303 (tex-recenter-output-buffer nil))
a99c30431979 (tex-feed-input): New function.
Richard M. Stallman <rms@gnu.org>
parents: 23642
diff changeset
1304
10572
c8717227f621 (tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents: 10341
diff changeset
1305 (defun tex-display-shell ()
c8717227f621 (tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents: 10341
diff changeset
1306 "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
1307 (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
1308 (tex-recenter-output-buffer nil))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1309
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1310 (defun tex-shell-sentinel (proc msg)
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1311 (cond ((null (buffer-name (process-buffer proc)))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1312 ;; buffer killed
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1313 (set-process-buffer proc nil)
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1314 (tex-delete-last-temp-files))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1315 ((memq (process-status proc) '(signal exit))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1316 (tex-delete-last-temp-files))))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1317
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1318 (defun tex-set-buffer-directory (buffer directory)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1319 "Set BUFFER's default directory to be DIRECTORY."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1320 (setq directory (file-name-as-directory (expand-file-name directory)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1321 (if (not (file-directory-p directory))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1322 (error "%s is not a directory" directory)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1323 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1324 (set-buffer buffer)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1325 (setq default-directory directory))))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1326
5088
73a1b31b673f (tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents: 5087
diff changeset
1327 (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
1328 (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
1329
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1330 (defun tex-shell-proc ()
37942
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1331 (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
1332 (defun tex-shell-buf ()
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1333 (process-buffer (tex-shell-proc)))
37942
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1334 (defun tex-shell-buf-no-error ()
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1335 (let ((proc (tex-shell-running)))
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1336 (and proc (process-buffer proc))))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1337
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1338 (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
1339 "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
1340 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
1341 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
1342 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
1343 evaluates to a command string.
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1344
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1345 Return the process in which TeX is running."
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1346 (save-excursion
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1347 (let* ((cmd (eval command))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1348 (proc (tex-shell-proc))
5262
b3a689b41d39 (tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents: 5088
diff changeset
1349 (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
1350 (star (string-match "\\*" cmd))
5087
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1351 (string
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1352 (concat
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1353 (if file
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1354 (if star (concat (substring cmd 0 star)
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1355 file (substring cmd (1+ star)))
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1356 (concat cmd " " file))
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1357 cmd)
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1358 (if background "&" ""))))
5262
b3a689b41d39 (tex-common-initialization): Make paragraph-start
Richard M. Stallman <rms@gnu.org>
parents: 5088
diff changeset
1359 ;; 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
1360 (set-buffer buf)
5088
73a1b31b673f (tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents: 5087
diff changeset
1361 ;; 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
1362 ;; 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
1363 (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
1364 (accept-process-output proc))
5087
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1365 (goto-char (process-mark proc))
a7b2df620d1a (tex-start-shell): Don't use -v option.
Richard M. Stallman <rms@gnu.org>
parents: 4917
diff changeset
1366 (insert string)
5088
73a1b31b673f (tex-send-command): Wait for output first,
Richard M. Stallman <rms@gnu.org>
parents: 5087
diff changeset
1367 (comint-send-input)
21314
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1368 (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
1369 proc)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1370
6479
855f4f2d24da (tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents: 5427
diff changeset
1371 (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
1372 "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
1373 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
1374 (if tex-last-temp-file
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1375 (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
1376 (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
1377 (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
1378 (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
1379 (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
1380 dir))))
7536
efecdee78026 (tex-delete-last-temp-files): Don't fail on non-existent directory.
Karl Heuer <kwzh@gnu.org>
parents: 7298
diff changeset
1381 (while list
6479
855f4f2d24da (tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents: 5427
diff changeset
1382 (if not-all
855f4f2d24da (tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents: 5427
diff changeset
1383 (and
855f4f2d24da (tex-delete-last-temp-files): New arg NOT-ALL.
Richard M. Stallman <rms@gnu.org>
parents: 5427
diff changeset
1384 ;; 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
1385 (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
1386 (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
1387 (delete-file (concat dir (car list))))
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1388 (setq list (cdr list))))))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1389
741
587f7a98341d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 739
diff changeset
1390 (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
1391
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1392 (defun tex-guess-main-file (&optional all)
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1393 "Find a likely `tex-main-file'.
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1394 Looks for hints in other buffers in the same directory or in
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1395 ALL other buffers."
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1396 (let ((dir default-directory)
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1397 (header-re tex-start-of-header))
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1398 (catch 'found
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1399 ;; 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
1400 (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
1401 (with-current-buffer buf
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1402 (when (and (or all (equal dir default-directory))
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1403 (stringp tex-main-file))
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1404 (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
1405 ;; 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
1406 (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
1407 (with-current-buffer buf
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1408 (when (and (or all (equal dir default-directory))
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1409 buffer-file-name
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1410 ;; (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
1411 ;; (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
1412 (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
1413 (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
1414 (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
1415 (goto-char (point-min))
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
1416 (re-search-forward header-re 10000 t))))
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1417 (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
1418
34139
358adc86d127 (tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33789
diff changeset
1419 (defun tex-main-file ()
358adc86d127 (tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33789
diff changeset
1420 "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
1421 (let* ((file (or tex-main-file
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1422 ;; Compatibility with AUCTeX.
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1423 (and (boundp 'TeX-master) (stringp TeX-master)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1424 (set (make-local-variable 'tex-main-file) TeX-master))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1425 ;; Try to guess the main file.
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1426 (if (not buffer-file-name)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1427 (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
1428 (file-relative-name
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1429 (if (save-excursion
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1430 (goto-char (point-min))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1431 (re-search-forward tex-start-of-header 10000 t))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1432 ;; This is the main file.
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1433 buffer-file-name
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1434 ;; 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
1435 (or (tex-guess-main-file)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1436 ;; (tex-guess-main-file t)
34139
358adc86d127 (tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33789
diff changeset
1437 buffer-file-name)))))))
358adc86d127 (tex-start-shell): Obey shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33789
diff changeset
1438 (if (file-exists-p file) file (concat file ".tex"))))
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1439
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1440
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1441 (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
1442 "Start a TeX run, using COMMAND on FILE."
23322
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1443 (let* ((star (string-match "\\*" command))
21314
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1444 (compile-command
23322
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1445 (if star
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1446 (concat (substring command 0 star)
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1447 (comint-quote-filename file)
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1448 (substring command (1+ star)))
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1449 (concat command " "
24330
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
1450 (if (< 0 (length tex-start-options-string))
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
1451 (concat
fee8d10bbb21 (tex-run-command, latex-run-command)
Richard M. Stallman <rms@gnu.org>
parents: 24273
diff changeset
1452 (shell-quote-argument tex-start-options-string) " "))
23322
26cc35857be5 (tex-run-command): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23296
diff changeset
1453 (comint-quote-filename file)))))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1454 (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
1455
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1456 (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
1457 (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
1458 (and buf (with-current-buffer buf
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1459 default-directory))))
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1460 (not dir))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1461 (let (shell-dirtrack-verbose)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1462 (tex-send-command tex-shell-cd-command dir)))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1463 (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
1464 (make-local-variable 'compilation-parse-errors-function)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1465 (setq compilation-parse-errors-function 'tex-compilation-parse-errors)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1466 (setq compilation-last-buffer (current-buffer))
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1467 (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
1468 ;; Don't parse previous compilations.
33472
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1469 (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
1470 (tex-display-shell)
1de979dabe6f (tex-font-lock-keywords-1): Use `keep'
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33363
diff changeset
1471 (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
1472
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
1473 (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
1474 (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
1475 (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
1476 (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
1477 (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
1478 (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
1479 (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
1480 (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
1481 (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
1482 ;; 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
1483 (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
1484 st)
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
1485 "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
1486
21314
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1487 (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
1488 "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
1489 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
1490
24129
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1491 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
1492 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
1493 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
1494 for the error messages."
21314
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1495 (require 'thingatpt)
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1496 (setq compilation-error-list nil)
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1497 (message "Parsing error messages...")
24129
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1498 (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
1499 (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
1500 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
1501 last-filename last-linenum last-position
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1502 begin-of-error end-of-error)
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1503 ;; 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
1504 (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
1505 ;; Parse messages.
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1506 (while (and (not (or found-desired (eobp)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1507 (prog1 (re-search-forward "^! " nil 'move)
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1508 (setq begin-of-error (match-beginning 0)
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1509 end-of-error (match-end 0)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1510 (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
1511 "^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\)?\\(.*\\)$" nil 'move))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1512 (let* ((this-error (set-marker (make-marker) begin-of-error))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1513 (linenum (string-to-int (match-string 1)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1514 (error-text (regexp-quote (match-string 3)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1515 (filename
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1516 (save-excursion
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1517 (with-syntax-table tex-error-parse-syntax-table
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1518 (backward-up-list 1)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1519 (skip-syntax-forward "(_")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1520 (while (not (file-readable-p (thing-at-point 'filename)))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1521 (skip-syntax-backward "(_")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1522 (backward-up-list 1)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1523 (skip-syntax-forward "(_"))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1524 (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
1525 (new-file
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1526 (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
1527 (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
1528 (error-location
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1529 (save-excursion
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1530 (if (equal filename (concat tex-zap-file ".tex"))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1531 (set-buffer tex-last-buffer-texed)
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1532 (set-buffer (find-file-noselect filename)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1533 (if new-file
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
1534 (progn (goto-line linenum) (setq last-position nil))
24129
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1535 (goto-char last-position)
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1536 (forward-line (- linenum last-linenum)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1537 ;; first try a forward search for the error text,
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1538 ;; then a backward search limited by the last error.
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1539 (let ((starting-point (point)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1540 (or (re-search-forward error-text nil t)
33789
3cb3c23bbe84 (tex-font-lock-keywords-1): Fix ARG regexp to skip quoted braces.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33477
diff changeset
1541 (re-search-backward error-text last-position t)
24129
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1542 (goto-char starting-point)))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1543 (point-marker))))
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1544 (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
1545 (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
1546 (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
1547 (>= 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
1548 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
1549 (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
1550 (>= 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
1551 new-file)
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1552 (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
1553 (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
1554 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
1555 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
1556 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
1557 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
1558 (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
1559 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
1560 (goto-char end-of-error)))))
25414
7c4808c6804b (tex-compilation-parse-errors):
Richard M. Stallman <rms@gnu.org>
parents: 24527
diff changeset
1561 (set-marker compilation-parsing-end (point))
24129
18c751deec0d (tex-define-common-keys): Remove key binding of tex-feed-input.
Richard M. Stallman <rms@gnu.org>
parents: 24109
diff changeset
1562 (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
1563 (message "Parsing error messages...done"))
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1564
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1565 ;;; The commands:
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1566
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1567 (defun tex-region (beg end)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1568 "Run TeX on the current region, via a temporary file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1569 The file's name comes from the variable `tex-zap-file' and the
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1570 variable `tex-directory' says where to put it.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1571
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1572 If the buffer has a header, the header is given to TeX before the
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1573 region itself. The buffer's header is all lines between the strings
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1574 defined by `tex-start-of-header' and `tex-end-of-header' inclusive.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1575 The header must start in the first 100 lines of the buffer.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1576
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1577 The value of `tex-trailer' is given to TeX as input after the region.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1578
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1579 The value of `tex-command' specifies the command to use to run TeX."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1580 (interactive "r")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1581 (if (tex-shell-running)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1582 (tex-kill-job)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1583 (tex-start-shell))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1584 (or tex-zap-file
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1585 (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
1586 ;; 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
1587 ;; 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
1588 ;; \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
1589 ;; 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
1590 ;; tex-directory is ".".
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1591 (let* ((zap-directory
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1592 (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
1593 (tex-out-file (expand-file-name (concat tex-zap-file ".tex")
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1594 zap-directory)))
9450
af39d29d1386 (compare-windows-whitespace): Eliminate initial value.
Richard M. Stallman <rms@gnu.org>
parents: 8890
diff changeset
1595 ;; 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
1596 (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
1597 (tex-delete-last-temp-files t))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1598 ;; Write the new temp file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1599 (save-excursion
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1600 (save-restriction
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1601 (widen)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1602 (goto-char (point-min))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1603 (forward-line 100)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1604 (let ((search-end (point))
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1605 (default-directory zap-directory)
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1606 (already-output 0))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1607 (goto-char (point-min))
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1608
16777
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
1609 ;; Maybe copy first line, such as `\input texinfo', to temp file.
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
1610 (and tex-first-line-header-regexp
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
1611 (looking-at tex-first-line-header-regexp)
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1612 (write-region (point)
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1613 (progn (forward-line 1)
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1614 (setq already-output (point)))
16777
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
1615 tex-out-file nil nil))
b655268ba44f (tex-first-line-header-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16493
diff changeset
1616
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1617 ;; Write out the header, if there is one,
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1618 ;; and any of the specified region which extends before it.
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1619 ;; But don't repeat anything already written.
13248
a7e83f7eb499 (tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents: 12704
diff changeset
1620 (if (re-search-forward tex-start-of-header search-end t)
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1621 (let (hbeg)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1622 (beginning-of-line)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1623 (setq hbeg (point)) ;mark beginning of header
13248
a7e83f7eb499 (tex-start-of-header): Now a regexp.
Richard M. Stallman <rms@gnu.org>
parents: 12704
diff changeset
1624 (if (re-search-forward tex-end-of-header nil t)
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1625 (let (hend)
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1626 (forward-line 1)
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1627 (setq hend (point)) ;mark end of header
16807
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1628 (write-region (max (min hbeg beg) already-output)
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1629 hend
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1630 tex-out-file
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1631 (not (zerop already-output)) nil)
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1632 (setq already-output hend)))))
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1633
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1634 ;; Write out the specified region
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1635 ;; (but don't repeat anything already written).
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1636 (write-region (max beg already-output) end
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1637 tex-out-file
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1638 (not (zerop already-output)) nil))
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1639 ;; Write the trailer, if any.
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1640 ;; Precede it with a newline to make sure it
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1641 ;; is not hidden in a comment.
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1642 (if tex-trailer
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1643 (write-region (concat "\n" tex-trailer) nil
f8d567e52662 (tex-region): Correctly handle possible
Richard M. Stallman <rms@gnu.org>
parents: 16777
diff changeset
1644 tex-out-file t nil))))
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1645 ;; Record the file name to be deleted afterward.
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1646 (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
1647 ;; 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
1648 ;; 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
1649 ;; 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
1650 (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
1651 (setq tex-print-file tex-out-file)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1652
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1653 (defun tex-buffer ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1654 "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
1655 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
1656 See \\[tex-file] for an alternative."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1657 (interactive)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1658 (tex-region (point-min) (point-max)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1659
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1660 (defun tex-file ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1661 "Prompt to save all buffers and run TeX (or LaTeX) on current buffer's file.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1662 This function is more useful than \\[tex-buffer] when you need the
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1663 `.aux' file of LaTeX to have the correct name."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1664 (interactive)
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1665 (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
1666 (file-dir (file-name-directory (expand-file-name source-file))))
758
f8688580137c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 741
diff changeset
1667 (if tex-offer-save
741
587f7a98341d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 739
diff changeset
1668 (save-some-buffers))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1669 (if (tex-shell-running)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1670 (tex-kill-job)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1671 (tex-start-shell))
31968
dc896c1b6a26 (latex-imenu-indent-string): Add a space.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30888
diff changeset
1672 (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
1673 (setq tex-print-file (expand-file-name source-file))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1674
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1675 (defun tex-generate-zap-file-name ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1676 "Generate a unique name suitable for use as a file name."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1677 ;; Include the shell process number and host name
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1678 ;; 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
1679 ;; 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
1680 ;; 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
1681 (format "_TZ_%d-%s"
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1682 (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
1683 (subst-char-in-string ?. ?- (system-name))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1684
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1685 ;; This will perhaps be useful for modifying TEXINPUTS.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1686 ;; Expand each file name, separated by colons, in the string S.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1687 (defun tex-expand-files (s)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1688 (let (elts (start 0))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1689 (while (string-match ":" s start)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1690 (setq elts (cons (substring s start (match-beginning 0)) elts))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1691 (setq start (match-end 0)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1692 (or (= start 0)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1693 (setq elts (cons (substring s start) elts)))
30888
e559f0aa6b2d Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26270
diff changeset
1694 (mapconcat (lambda (elt)
e559f0aa6b2d Don't quote lambda.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26270
diff changeset
1695 (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
1696 (nreverse elts) ":")))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1697
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1698 (defun tex-shell-running ()
36105
595ee2f062cf tex-shell-running: Check the process buffer too
Sam Steingold <sds@gnu.org>
parents: 34139
diff changeset
1699 (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
1700 (when proc
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1701 (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
1702 (buffer-live-p (process-buffer proc)))
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1703 ;; return the TeX process on success
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1704 proc
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1705 ;; get rid of the process permanently
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1706 ;; 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
1707 ;; 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
1708 (delete-process proc)))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1709
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1710 (defun tex-kill-job ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1711 "Kill the currently running TeX job."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1712 (interactive)
37942
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1713 ;; `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
1714 ;; 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
1715 ;; 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
1716 ;; 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
1717 (let ((proc (get-process "tex-shell")))
0f57d8b106f1 fix live process/dead buffer bub on w32
Sam Steingold <sds@gnu.org>
parents: 37896
diff changeset
1718 (when proc (quit-process proc t))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1719
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1720 (defun tex-recenter-output-buffer (linenum)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1721 "Redisplay buffer of TeX job output so that most recent output can be seen.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1722 The last line of the buffer is displayed on
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1723 line LINE of the window, or centered if LINE is nil."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1724 (interactive "P")
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1725 (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
1726 (old-buffer (current-buffer))
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1727 (window))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1728 (if (null tex-shell)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1729 (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
1730 (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
1731 (save-selected-window
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1732 (select-window window)
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1733 (bury-buffer tex-shell)
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1734 (goto-char (point-max))
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1735 (recenter (if linenum
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1736 (prefix-numeric-value linenum)
bdca7f3626c0 (tex-file): Fix paren error in last change.
Richard M. Stallman <rms@gnu.org>
parents: 16356
diff changeset
1737 (/ (window-height) 2)))))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1738
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1739 (defun tex-print (&optional alt)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1740 "Print the .dvi file made by \\[tex-region], \\[tex-buffer] or \\[tex-file].
1577
a52da8d63ff3 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 957
diff changeset
1741 Runs the shell command defined by `tex-dvi-print-command'. If prefix argument
a52da8d63ff3 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 957
diff changeset
1742 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
1743 (interactive "P")
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1744 (let ((print-file-name-dvi (tex-append tex-print-file ".dvi"))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1745 test-name)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1746 (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
1747 (buffer-file-name)
f27bcd1faf07 (tex-print): Better check for when to print current
Richard M. Stallman <rms@gnu.org>
parents: 10325
diff changeset
1748 ;; Check that this buffer's printed file is up to date.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1749 (file-newer-than-file-p
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1750 (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
1751 (buffer-file-name)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1752 (setq print-file-name-dvi test-name))
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1753 (if (not (file-exists-p print-file-name-dvi))
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1754 (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
1755 (if (tex-shell-running)
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1756 (tex-kill-job)
7d4a55d38b2c (tex-send-command): Return the process.
Richard M. Stallman <rms@gnu.org>
parents: 21121
diff changeset
1757 (tex-start-shell))
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1758 (tex-send-command
24273
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1759 (if alt tex-alt-dvi-print-command tex-dvi-print-command)
803ec3bfa983 When compiling, require compare-w and skeleton
Richard M. Stallman <rms@gnu.org>
parents: 24222
diff changeset
1760 print-file-name-dvi t))))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1761
4917
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1762 (defun tex-alt-print ()
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1763 "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
1764 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
1765 (interactive)
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1766 (tex-print t))
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1767
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1768 (defun tex-view ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1769 "Preview the last `.dvi' file made by running TeX under Emacs.
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1770 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
1771 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
1772 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
1773 because there is no standard value that would generally work."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1774 (interactive)
11617
9eaeed5c8a40 (tex-view): Nice error if tex-dvi-view-command is nil.
Richard M. Stallman <rms@gnu.org>
parents: 11235
diff changeset
1775 (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
1776 (error "You must set `tex-dvi-view-command'"))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1777 (let ((tex-dvi-print-command tex-dvi-view-command))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1778 (tex-print)))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1779
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1780 (defun tex-append (file-name suffix)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1781 "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
1782 Pascal-based TeX scans for the first period, C TeX uses the last.
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1783 No period is retained immediately before SUFFIX,
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1784 so normally SUFFIX starts with one."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1785 (if (stringp file-name)
4917
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1786 (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
1787 trial-name)
14383
af281a43a3bb (tex-face-alist, tex-latex-face-alist): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 13399
diff changeset
1788 ;; 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
1789 ;; 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
1790 ;; 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
1791 ;; 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
1792 (setq trial-name
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1793 (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
1794 (substring file 0
10778
ace814499178 (tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents: 10572
diff changeset
1795 (string-match "\\.[^.]*$" file))
4917
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1796 suffix))
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1797 (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
1798 (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
1799 trial-name
10778
ace814499178 (tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents: 10572
diff changeset
1800 ;; 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
1801 (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
1802 (substring file 0
10778
ace814499178 (tex-append): Try splitting on last period, then
Richard M. Stallman <rms@gnu.org>
parents: 10572
diff changeset
1803 (string-match "\\." file))
4917
550746214170 (tex-alt-print): New function for menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 4908
diff changeset
1804 suffix)))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1805 " "))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1806
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1807 (defun tex-show-print-queue ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1808 "Show the print queue that \\[tex-print] put your job on.
1577
a52da8d63ff3 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 957
diff changeset
1809 Runs the shell command defined by `tex-show-queue-command'."
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1810 (interactive)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1811 (if (tex-shell-running)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1812 (tex-kill-job)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1813 (tex-start-shell))
10572
c8717227f621 (tex-display-shell): Pass nil as arg to
Richard M. Stallman <rms@gnu.org>
parents: 10341
diff changeset
1814 (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
1815 (tex-display-shell))
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1816
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1817 (defun tex-bibtex-file ()
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1818 "Run BibTeX on the current buffer's file."
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1819 (interactive)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1820 (if (tex-shell-running)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1821 (tex-kill-job)
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1822 (tex-start-shell))
24222
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1823 (let (shell-dirtrack-verbose
8b2cecc76fe3 (tex-mode-map): Replace validate-tex-buffer by
Markus Rost <rost@math.uni-bielefeld.de>
parents: 24173
diff changeset
1824 (tex-out-file
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1825 (tex-append (file-name-nondirectory (buffer-file-name)) ""))
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1826 (file-dir (file-name-directory (buffer-file-name))))
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1827 (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
1828 (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
1829 (tex-display-shell))
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1830
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1831 ;;;;
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1832 ;;;; LaTeX indentation
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1833 ;;;;
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1834
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1835 (defvar tex-indent-allhanging t)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1836 (defvar tex-indent-arg 4)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1837 (defvar tex-indent-basic 2)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1838 (defvar tex-indent-item tex-indent-basic)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1839 (defvar tex-indent-item-re "\\\\\\(bib\\)?item\\>")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1840
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1841 (easy-mmode-defsyntax tex-latex-indent-syntax-table
33363
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1842 '((?$ . ".")
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1843 (?\( . ".")
1a5b4e0146bc (standard-latex-block-names): Add "math".
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33113
diff changeset
1844 (?\) . "."))
32479
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1845 "Syntax table used while computing indentation."
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1846 :copy tex-mode-syntax-table)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1847
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1848 (defun latex-indent (&optional arg)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1849 (with-syntax-table tex-latex-indent-syntax-table
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1850 ;; TODO: Rather than ignore $, we should try to be more clever about it.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1851 (let ((indent
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1852 (save-excursion
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1853 (beginning-of-line)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1854 (latex-find-indent))))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1855 (if (< indent 0) (setq indent 0))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1856 (if (<= (current-column) (current-indentation))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1857 (indent-line-to indent)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1858 (save-excursion (indent-line-to indent))))))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1859
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1860 (defun latex-find-indent (&optional virtual)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1861 "Find the proper indentation of text after point.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1862 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
1863 in order to determine the indentation of something else.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1864 There might be text before point."
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1865 (save-excursion
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1866 (skip-chars-forward " \t")
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1867 (or
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1868 ;; Trust the current indentation, if such info is applicable.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1869 (and virtual (>= (current-indentation) (current-column))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1870 (current-indentation))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1871 ;; Put leading close-paren where the matching open brace would be.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1872 (and (eq (latex-syntax-after) ?\))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1873 (ignore-errors
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1874 (save-excursion
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1875 (latex-skip-close-parens)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1876 (latex-backward-sexp-1)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1877 (latex-find-indent 'virtual))))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1878 ;; Default (maybe an argument)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1879 (let ((pos (point))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1880 (char (char-after))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1881 ;; Outdent \item if necessary.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1882 (indent (if (looking-at tex-indent-item-re) (- tex-indent-item) 0))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1883 up-list-pos)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1884 ;; Find the previous point which determines our current indentation.
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1885 (condition-case err
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1886 (progn
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1887 (latex-backward-sexp-1)
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1888 (while (> (current-column) (current-indentation))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1889 (latex-backward-sexp-1)))
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1890 (scan-error
783ed0889617 Require CL when compiling.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32045
diff changeset
1891 (setq up-list-pos (nth 2 err))))
37952
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1892 (cond
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1893 ((= (point-min) pos) 0) ; We're really just indenting the first line.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1894 ((integerp up-list-pos)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1895 ;; Have to indent relative to the open-paren.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1896 (goto-char up-list-pos)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1897 (if (and (not tex-indent-allhanging)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1898 (> pos (progn (latex-down-list)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1899 (forward-comment (point-max))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1900 (point))))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1901 ;; Align with the first element after the open-paren.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1902 (current-column)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1903 ;; We're the first element after a hanging brace.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1904 (goto-char up-list-pos)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1905 (+ indent tex-indent-basic (latex-find-indent 'virtual))))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1906 ;; We're now at the "beginning" of a line.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1907 ((not (and (not virtual) (eq (char-after) ?\\)))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1908 ;; Nothing particular here: just keep the same indentation.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1909 (+ indent (current-column)))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1910 ;; We're now looking at a macro call.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1911 ((looking-at tex-indent-item-re)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1912 ;; Indenting relative to an item, have to re-add the outdenting.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1913 (+ indent (current-column) tex-indent-item))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1914 (t
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1915 (let ((col (current-column)))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1916 (if (not (eq (char-syntax char) ?\())
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1917 ;; If the first char was not an open-paren, there's
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1918 ;; a risk that this is really not an argument to the
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1919 ;; macro at all.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1920 (+ indent col)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1921 (forward-sexp 1)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1922 (if (< (line-end-position)
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1923 (save-excursion (forward-comment (point-max))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1924 (point)))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1925 ;; we're indenting the first argument.
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1926 (min (current-column) (+ tex-indent-arg col))
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1927 (skip-syntax-forward " ")
4192225498c7 (latex-find-indent): Handle the BOBP case.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37942
diff changeset
1928 (current-column))))))))))
739
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1929
0bb85f26b79c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 657
diff changeset
1930 (run-hooks 'tex-mode-load-hook)
85
253ec6b277ee Initial revision
root <root>
parents:
diff changeset
1931
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 269
diff changeset
1932 (provide 'tex-mode)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 269
diff changeset
1933
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1934 ;;; tex-mode.el ends here