annotate lisp/auctex/tex.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents
children 441bb1e64a06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1 ;;; tex.el --- Support for TeX documents.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
3 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk>
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
4 ;; Version: 9.7i
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
5 ;; Keywords: wp
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
6 ;; X-URL: http://sunsite.auc.dk/auctex
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
7
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
8 ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
9 ;; Copyright (C) 1987 Lars Peter Fischer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
10 ;; Copyright (C) 1991 Kresten Krab Thorup
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
11 ;; Copyright (C) 1993, 1994, 1996, 1997 Per Abrahamsen
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
12 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
13 ;; This program is free software; you can redistribute it and/or modify
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 1, or (at your option)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
16 ;; any later version.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
17 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
18 ;; This program is distributed in the hope that it will be useful,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
22 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
24 ;; along with this program; if not, write to the Free Software
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
25 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
26
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
27 ;;; Code:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
28
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
29 ;;; Site Customization
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
30 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
31 ;; The following variables are likely to need to be changed for your
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
32 ;; site. It is suggested that you do this by *not* changing this
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
33 ;; file, but instead copy those definitions you need to change to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
34 ;; `tex-site.el'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
35
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
36 (defvar TeX-lisp-directory "auctex/"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
37 "*The directory where the AUC TeX lisp files are located.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
38
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
39 ;; Change this to point to the place where the TeX macros are stored
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
40 ;; at yourt site. [Ignore when bundled with XEmacs]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
41 (defvar TeX-macro-global '("/usr/lib/texmf/tex/")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
42 "*Directories containing the sites TeX macro files and style files.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
43
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
44 The directory names *must* end with a slash.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
45
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
46 ;; How to print.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
47
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
48 (defvar TeX-print-command "dvips %s -P%p"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
49 "*Command used to print a file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
50
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
51 First %p is expanded to the printer name, then ordinary expansion is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
52 performed as specified in TeX-expand-list.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
53
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
54 (defvar TeX-queue-command "lpq -P%p"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
55 "*Command used to show the status of a printer queue.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
56
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
57 First %p is expanded to the printer name, then ordinary expansion is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
58 performed as specified in TeX-expand-list.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
59
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
60 ;; This is the major configuration variable. Most sites will only
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
61 ;; need to change the second string in each entry, which is the name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
62 ;; of a command to send to the shell. If you use other formatters
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
63 ;; like AMSLaTeX or AMSTeX, you can add those to the list. See
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
64 ;; TeX-expand-list for a description of the % escapes
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
65
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
66 (defvar TeX-command-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
67 ;; You may have to remove the single quotes around the command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
68 ;; arguments if you use DOS.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
69 (list (list "TeX" "tex '\\nonstopmode\\input %t'" 'TeX-run-TeX nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
70 (list "TeX Interactive" "tex %t" 'TeX-run-interactive nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
71 (list "LaTeX" "%l '\\nonstopmode\\input{%t}'"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
72 'TeX-run-LaTeX nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
73 (list "LaTeX Interactive" "%l %t" 'TeX-run-interactive nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
74 (list "LaTeX2e" "latex2e '\\nonstopmode\\input{%t}'"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
75 'TeX-run-LaTeX nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
76 (if (or window-system (getenv "DISPLAY"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
77 (list "View" "%v " 'TeX-run-background t nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
78 (list "View" "dvi2tty -q -w 132 %s " 'TeX-run-command t nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
79 (list "Print" "%p " 'TeX-run-command t nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
80 (list "Queue" "%q" 'TeX-run-background nil nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
81 (list "File" "dvips %d -o %f " 'TeX-run-command t nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
82 (list "BibTeX" "bibtex %s" 'TeX-run-BibTeX nil nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
83 (list "Index" "makeindex %s" 'TeX-run-command nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
84 ;; (list "Check" "chktex -v3 %s" 'TeX-run-compile nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
85 ;; Uncomment the above line and comment out the next line to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
86 ;; use `chktex' instead of `lacheck'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
87 (list "Check" "lacheck %s" 'TeX-run-compile nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
88 (list "Spell" "<ignored>" 'TeX-run-ispell nil nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
89 (list "Other" "" 'TeX-run-command t t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
90 ;; Not part of standard TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
91 (list "Makeinfo" "makeinfo %t" 'TeX-run-compile nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
92 (list "AmSTeX" "amstex '\\nonstopmode\\input %t'"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
93 'TeX-run-TeX nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
94 "*List of commands to execute on the current document.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
95
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
96 Each element is a list, whose first element is the name of the command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
97 as it will be presented to the user.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
98
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
99 The second element is the string handed to the shell after being
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
100 expanded. The expansion is done using the information found in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
101 TeX-expand-list.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
102
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
103 The third element is the function which actually start the process.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
104 Several such hooks has been defined:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
105
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
106 TeX-run-command: Start up the process and show the output in a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
107 separate buffer. Check that there is not two commands running for the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
108 same file. Return the process object.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
109
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
110 TeX-run-format: As TeX-run-command, but assume the output is created
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
111 by a TeX macro package. Return the process object.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
112
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
113 TeX-run-TeX: For TeX output.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
114
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
115 TeX-run-LaTeX: For LaTeX output.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
116
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
117 TeX-run-interactive: Run TeX or LaTeX interactively.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
118
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
119 TeX-run-BibTeX: For BibTeX output.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
120
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
121 TeX-run-compile: Use `compile' to run the process.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
122
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
123 TeX-run-shell: Use `shell-command' to run the process.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
124
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
125 TeX-run-discard: Start the process in the background, discarding its
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
126 output.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
127
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
128 TeX-run-background: Start the process in the background, show output
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
129 in other window.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
130
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
131 TeX-run-dviout: Special hook for the Japanese dviout previewer for
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
132 PC-9801.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
133
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
134 To create your own hook, define a function taking three arguments: The
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
135 name of the command, the command string, and the name of the file to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
136 process. It might be useful to use TeX-run-command in order to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
137 create an asynchronous process.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
138
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
139 If the fourth element is non-nil, the user will get a chance to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
140 modify the expanded string.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
141
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
142 The fifth element is obsolete and ignored.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
143
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
144 ;; You may want to change the default LaTeX version for your site.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
145 (defvar LaTeX-version "2e"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
146 "Default LaTeX version. Currently recognized is \"2\" and \"2e\".")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
147
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
148 ;; You may want special options to the view command depending on the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
149 ;; style options. Only works if parsing is enabled.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
150
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
151 (defvar LaTeX-command-style
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
152 (if (string-equal LaTeX-version "2")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
153 ;; There is a lot of different LaTeX 2 based formats.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
154 '(("^latex2e$" "latex2e")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
155 ("^foils$" "foiltex")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
156 ("^ams" "amslatex")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
157 ("^slides$" "slitex")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
158 ("^plfonts\\|plhb$" "platex")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
159 ("." "latex"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
160 ;; They have all been combined in LaTeX 2e.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
161 '(("." "latex")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
162 "*List of style options and LaTeX commands.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
163
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
164 If the first element (a regular expresion) matches the name of one of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
165 the style files, any occurrence of the string %l in a command in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
166 TeX-command-list will be replaced with the second element. The first
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
167 match is used, if no match is found the %l is replaced with the empty
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
168 string.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
169
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
170 ;; Enter the names of the printers available at your site, or nil if
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
171 ;; you only have one printer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
172
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
173 (defvar TeX-printer-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
174 '(("Local" "dvips -f %s | lpr" "lpq")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
175 ("lw") ("ps"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
176 "*List of available printers.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
177
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
178 The first element of each entry is the printer name.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
179
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
180 The second element is the command used to print to this
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
181 printer. It defaults to the value of TeX-print-command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
182
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
183 The third element is the command used to examine the print queue for
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
184 this printer. It defaults to the value of TeX-queue-command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
185
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
186 Any occurence of `%p' in the second or third element is expanded to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
187 the printer name given in the first element, then ordinary expansion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
188 is performed as specified in TeX-expand-list.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
189
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
190 ;; The name of the most used printer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
191
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
192 (defvar TeX-printer-default (or (getenv "PRINTER")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
193 (and TeX-printer-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
194 (car (car TeX-printer-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
195 "lw")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
196 "*Default printer to use with TeX-command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
197
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
198 ;; You may want special options to the view command depending on the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
199 ;; style options. Only works if parsing is enabled.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
200
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
201 (defvar TeX-view-style '(("^a5$" "xdvi %d -paper a5")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
202 ("^landscape$" "xdvi %d -paper a4r -s 4")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
203 ;; The latest xdvi can show embedded postscript.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
204 ;; If you don't have that, uncomment next line.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
205 ;; ("^epsf$" "ghostview %f")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
206 ("." "xdvi %d"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
207 "*List of style options and view options.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
208
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
209 If the first element (a regular expresion) matches the name of one of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
210 the style files, any occurrence of the string %v in a command in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
211 TeX-command-list will be replaced with the second element. The first
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
212 match is used, if no match is found the %v is replaced with the empty
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
213 string.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
214
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
215 ;; This is the list of expansion for the commands in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
216 ;; TeX-command-list. Not likely to be changed, but you may e.g. want
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
217 ;; to handle .ps files.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
218
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
219 (defvar TeX-expand-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
220 (list (list "%p" 'TeX-printer-query) ;%p must be the first entry
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
221 (list "%q" (function (lambda ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
222 (TeX-printer-query TeX-queue-command 2))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
223 (list "%v" 'TeX-style-check TeX-view-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
224 (list "%l" 'TeX-style-check LaTeX-command-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
225 (list "%s" 'file nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
226 (list "%t" 'file 't t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
227 (list "%d" 'file "dvi" t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
228 (list "%f" 'file "ps" t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
229 "*List of expansion strings for TeX command names.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
230
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
231 Each entry is a list with two or more elements. The first element is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
232 the string to be expanded. The second element is the name of a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
233 function returning the expanded string when called with the remaining
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
234 elements as arguments. The special value `file' will be expanded to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
235 the name of the file being processed, with an optional extension.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
236
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
237 ;; End of Site Customization.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
238
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
239 ;;; Import
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
240
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
241 (or (assoc TeX-lisp-directory (mapcar 'list load-path)) ;No `member' yet.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
242 (setq load-path (cons TeX-lisp-directory load-path)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
243
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
244 (defvar no-doc
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
245 "This function is part of AUC TeX, but has not yet been loaded.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
246 Full documentation will be available after autoloading the function."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
247 "Documentation for autoload functions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
248
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
249 ;; This hook will store bibitems when you save a BibTeX buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
250 (defvar bibtex-mode-hook nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
251 (or (memq 'BibTeX-auto-store bibtex-mode-hook) ;No `add-hook' yet.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
252 (setq bibtex-mode-hook (cons 'BibTeX-auto-store bibtex-mode-hook)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
253
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
254 (autoload 'BibTeX-auto-store "latex" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
255
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
256 (autoload 'LaTeX-math-mode "latex" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
257 (autoload 'japanese-plain-tex-mode "tex-jp" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
258 (autoload 'japanese-latex-mode "tex-jp" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
259 (autoload 'japanese-slitex-mode "tex-jp" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
260 (autoload 'texinfo-mode "tex-info" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
261 (autoload 'latex-mode "latex" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
262
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
263 (autoload 'multi-prompt "multi-prompt" no-doc nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
264
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
265 ;;; Portability.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
266
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
267 (require 'easymenu)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
268
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
269 ;; An GNU Emacs 19 function.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
270 (or (fboundp 'set-text-properties)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
271 (fset 'set-text-properties (symbol-function 'ignore)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
272
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
273 ;; An GNU Emacs 19 variable.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
274 (defvar minor-mode-map-alist nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
275
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
276 ;;; Special support for Emacs 18
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
277
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
278 (cond ((< (string-to-int emacs-version) 19)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
279
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
280 (condition-case error
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
281 (require 'outline) ;No provide in Emacs 18 outline.el
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
282 (error (provide 'outline)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
283
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
284 ;; Emacs 18 grok this regexp, but you loose the ability to use
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
285 ;; whitespace anywhere in your documentstyle command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
286 (defvar LaTeX-auto-minimal-regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
287 '(("\\\\documentstyle\\[\\([^#\\\\\\.\n\r]+\\)\\]{\\([^#\\\\\\.\n\r]+\\)}"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
288 (1 2) LaTeX-auto-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
289 ("\\\\documentstyle{\\([^#\\\\\\.\n\r]+\\)}" (1) LaTeX-auto-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
290 ("\\\\documentclass\\[\\([^#\\\\\\.\n\r]+\\)\\]{\\([^#\\\\\\.\n\r]+\\)}"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
291 (1 2) LaTeX-auto-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
292 ("\\\\documentclass{\\([^#\\\\\\.\n\r]+\\)}" (1) LaTeX-auto-style))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
293 "Minimal list of regular expressions matching LaTeX macro definitions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
294
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
295 ;; The Emacs 19 definition of `comment-region'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
296 (defun comment-region (beg end &optional arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
297 "Comment the region; third arg numeric means use ARG comment characters.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
298 If ARG is negative, delete that many comment characters instead.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
299 Comments are terminated on each line, even for syntax in which newline does
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
300 not end the comment. Blank lines do not get comments."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
301 ;; if someone wants it to only put a comment-start at the beginning and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
302 ;; comment-end at the end then typing it, C-x C-x, closing it, C-x C-x
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
303 ;; is easy enough. No option is made here for other than commenting
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
304 ;; every line.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
305 (interactive "r\np")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
306 (or comment-start (error "No comment syntax is defined"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
307 (if (> beg end) (let (mid) (setq mid beg beg end end mid)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
308 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
309 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
310 (let ((cs comment-start) (ce comment-end))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
311 (cond ((not arg) (setq arg 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
312 ((> arg 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
313 (while (> (setq arg (1- arg)) 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
314 (setq cs (concat cs comment-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
315 ce (concat ce comment-end)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
316 (narrow-to-region beg end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
317 (goto-char beg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
318 (while (not (eobp))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
319 (if (< arg 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
320 (let ((count arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
321 (while (and (> 1 (setq count (1+ count)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
322 (looking-at (regexp-quote cs)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
323 (delete-char (length cs)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
324 (if (string= "" ce) ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
325 (setq count arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
326 (while (> 1 (setq count (1+ count)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
327 (end-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
328 ;; this is questionable if comment-end ends in whitespace
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
329 ;; that is pretty brain-damaged though
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
330 (skip-chars-backward " \t")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
331 (backward-char (length ce))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
332 (if (looking-at (regexp-quote ce))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
333 (delete-char (length ce)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
334 (forward-line 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
335 (if (looking-at "[ \t]*$") ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
336 (insert cs)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
337 (if (string= "" ce) ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
338 (end-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
339 (insert ce)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
340 (search-forward "\n" nil 'move)))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
341
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
342 ;; The Emacs 19 definition of `add-hook'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
343 (defun add-hook (hook function &optional append)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
344 "Add to the value of HOOK the function FUNCTION.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
345 FUNCTION is not added if already present.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
346 FUNCTION is added (if necessary) at the beginning of the hook list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
347 unless the optional argument APPEND is non-nil, in which case
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
348 FUNCTION is added at the end.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
349
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
350 HOOK should be a symbol, and FUNCTION may be any valid function. If
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
351 HOOK is void, it is first set to nil. If HOOK's value is a single
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
352 function, it is changed to a list of functions."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
353 (or (boundp hook) (set hook nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
354 ;; If the hook value is a single function, turn it into a list.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
355 (let ((old (symbol-value hook)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
356 (if (or (not (listp old)) (eq (car old) 'lambda))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
357 (set hook (list old))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
358 (or (if (consp function)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
359 ;; Clever way to tell whether a given lambda-expression
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
360 ;; is equal to anything in the hook.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
361 (let ((tail (assoc (cdr function) (symbol-value hook))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
362 (equal function tail))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
363 (memq function (symbol-value hook)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
364 (set hook
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
365 (if append
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
366 (nconc (symbol-value hook) (list function))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
367 (cons function (symbol-value hook))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
368
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
369 ;; An Emacs 19 function.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
370 (defun make-directory (dir)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
371 "Create the directory DIR."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
372 (shell-command (concat "mkdir " (if (string-match "/$" dir)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
373 (substring dir 0 -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
374 dir))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
375
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
376 ;; An Emacs 19 function.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
377 (defun abbreviate-file-name (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
378 name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
379
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
380 ;; Different interface for each variant.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
381 (defun TeX-active-mark ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
382 ;; Emacs 18 does not have active marks.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
383 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
384
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
385 ;; Different interface for each variant.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
386 (defun TeX-mark-active ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
387 ;; In Emacs 18 (mark) returns nil when not active.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
388 (mark))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
389
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
390 ;; An Emacs 19 function.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
391 (defun member (elt list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
392 "Return non-nil if ELT is an element of LIST. Comparison done with EQUAL.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
393 The value is actually the tail of LIST whose car is ELT."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
394 (while (and list (not (equal elt (car list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
395 (setq list (cdr list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
396 list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
397
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
398 ;; An Emacs 19 macro.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
399 (defmacro save-match-data (&rest body)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
400 "Execute the BODY forms, restoring the global value of the match data."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
401 (let ((original (make-symbol "match-data")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
402 (list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
403 'let (list (list original '(match-data)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
404 (list 'unwind-protect
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
405 (cons 'progn body)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
406 (list 'store-match-data original)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
407
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
408 )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
409
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
410 ;;; Special support for XEmacs
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
411
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
412 ((or (string-match "Lucid" emacs-version)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
413 (string-match "XEmacs" emacs-version))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
414
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
415 (if (eq emacs-minor-version 13)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
416 ;; XEmacs 19.13 had a partial defintion of set-text-properties.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
417 (defadvice set-text-properties (around ignore-strings activate)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
418 "Ignore strings."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
419 (or (stringp (ad-get-arg 3))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
420 ad-do-it)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
421
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
422 (defadvice popup-mode-menu (before LaTeX-update activate)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
423 "Run `LaTeX-menu-update' before showing menu."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
424 (and (fboundp 'LaTeX-menu-update)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
425 (LaTeX-menu-update)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
426
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
427 (defun TeX-mark-active ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
428 ;; In Lucid (mark) returns nil when not active.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
429 (if zmacs-regions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
430 (mark)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
431 (mark t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
432
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
433 (defun TeX-active-mark ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
434 (and zmacs-regions (mark)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
435
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
436 ;; Lucid 19.11 have no idea what `kill-all-local-variables' is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
437 ;; supposed to do. I have to explicitly clear `TeX-symbol-list'
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
438 ;; despite it being buffer local. You can verify this by removing the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
439 ;; hook below, setting a breakpoint just after the call to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
440 ;; `kill-all-local-variables' in `VirTeX-common-initialization' and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
441 ;; examine the local and global value of `TeX-symbol-list'. Make sure
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
442 ;; you have a `%%% mode: latex' line in your file variable section,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
443 ;; and have latex-mode as your default mode for ".tex" files.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
444 ;; Unfortunately I have been unable to isolate the error further.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
445 (add-hook 'change-major-mode-hook
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
446 '(lambda () (setq TeX-symbol-list nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
447 LaTeX-environment-list nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
448
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
449 ;; Lucid 19.6 grok this regexp, but you loose the ability to use
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
450 ;; whitespace in your documentstyle command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
451 (string-match "\\`[0-9]+\\.\\([0-9]+\\)" emacs-version)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
452 (or (> (string-to-int (substring emacs-version
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
453 (match-beginning 1) (match-end 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
454 8)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
455 (> (string-to-int emacs-version) 19)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
456 (boundp 'LaTeX-auto-minimal-regexp-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
457 (setq LaTeX-auto-minimal-regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
458 '(("\\\\documentstyle\\[\\([^#\\\\\\.\n\r]+\\)\\]{\\([^#\\\\\\.\n\r]+\\)}"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
459 (1 2) LaTeX-auto-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
460 ("\\\\documentstyle{\\([^#\\\\\\.\n\r]+\\)}" (1) LaTeX-auto-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
461 ("\\\\documentclass\\[\\([^#\\\\\\.\n\r]+\\)\\]{\\([^#\\\\\\.\n\r]+\\)}"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
462 (1 2) LaTeX-auto-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
463 ("\\\\documentclass{\\([^#\\\\\\.\n\r]+\\)}" (1) LaTeX-auto-style))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
464
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
465 ;; Lucid only
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
466 (fset 'TeX-activate-region (symbol-function 'zmacs-activate-region))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
467
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
468 )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
469 ;;; Special support for GNU Emacs 19
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
470
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
471 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
472
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
473 (defun TeX-mark-active ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
474 ;; In FSF 19 mark-active indicates if mark is active.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
475 mark-active)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
476
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
477 (defun TeX-active-mark ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
478 (and transient-mark-mode mark-active))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
479
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
480 (defun TeX-activate-region ())
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
481
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
482 ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
483
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
484 ;;; Version
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
485
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
486 ;; These two variables are automatically updated with "make dist", so
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
487 ;; be careful before changing anything.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
488
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
489 (defconst AUC-TeX-version "9.7i"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
490 "AUC TeX version number")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
491
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
492 (defconst AUC-TeX-date "Thu Feb 20 11:30:55 MET 1997"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
493 "AUC TeX release date")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
494
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
495 ;;; Buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
496
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
497 (defvar TeX-display-help t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
498 "*Non-nil means popup help when stepping thrugh errors with \\[TeX-next-error]")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
499
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
500 (defvar TeX-debug-bad-boxes nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
501 "*Non-nil means also find overfull/underfull boxes warnings with TeX-next-error")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
502
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
503 (defvar TeX-command-BibTeX "BibTeX"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
504 "*The name of the BibTeX entry in TeX-command-list.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
505 (make-variable-buffer-local 'TeX-command-BibTeX)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
506
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
507 (defvar TeX-command-Show "View"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
508 "*The default command to show (view or print) a TeX file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
509 Must be the car of an entry in TeX-command-list.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
510 (make-variable-buffer-local 'TeX-command-Show)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
511
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
512 (defvar TeX-command-Print "Print"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
513 "The name of the Print entry in TeX-command-Print.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
514
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
515 (defvar TeX-command-Queue "Queue"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
516 "The name of the Queue entry in TeX-command-Queue.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
517
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
518 (autoload 'TeX-region-create "tex-buf" no-doc nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
519 (autoload 'TeX-save-document "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
520 (autoload 'TeX-home-buffer "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
521 (autoload 'TeX-command-region "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
522 (autoload 'TeX-command-buffer "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
523 (autoload 'TeX-command-master "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
524 (autoload 'TeX-command "tex-buf" no-doc nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
525 (autoload 'TeX-kill-job "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
526 (autoload 'TeX-recenter-output-buffer "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
527 (autoload 'TeX-next-error "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
528 (autoload 'TeX-toggle-debug-boxes "tex-buf" no-doc t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
529 (autoload 'TeX-region-file "tex-buf" no-doc nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
530
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
531 (defvar TeX-trailer-start nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
532 "Regular expression delimiting start of trailer in a TeX file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
533
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
534 (make-variable-buffer-local 'TeX-trailer-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
535
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
536 (defvar TeX-header-end nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
537 "Regular expression delimiting end of header in a TeX file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
538
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
539 (make-variable-buffer-local 'TeX-header-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
540
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
541 (defvar TeX-command-default nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
542 "The default command for TeX-command in the current major mode.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
543
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
544 (make-variable-buffer-local 'TeX-command-default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
545
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
546
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
547 ;;; Master File
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
548
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
549 (defvar TeX-one-master "\\.tex$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
550 "*Regular expression matching ordinary TeX files.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
551
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
552 You should set this variable to match the name of all files, where
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
553 automatically adding a file variable with the name of the master file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
554 is a good idea. When AUC TeX add the name of the master file as a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
555 file variable, it does not need to ask next time you edit the file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
556
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
557 If you dislike AUC TeX automatically modifying your files, you can set
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
558 this variable to \"<none>\".")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
559
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
560 (defun TeX-master-file (&optional extension nondirectory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
561 "Return the name of the master file for the current document.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
562
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
563 If optional argument EXTENSION is non-nil, add that file extension to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
564 the name. Special value `t' means use `TeX-default-extension'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
565
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
566 If optional second argument NONDIRECTORY is non-nil, do not include
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
567 the directory.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
568
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
569 Currently is will check for the presence of a ``Master:'' line in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
570 the beginning of the file, but that feature will be phased out."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
571 (if (eq extension t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
572 (setq extension TeX-default-extension))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
573 (let ((my-name (if (buffer-file-name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
574 (TeX-strip-extension nil (list TeX-default-extension) t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
575 "<none>")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
576 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
577 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
578 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
579 (goto-char (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
580 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
581 ;; Special value 't means it is own master (a free file).
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
582 ((equal TeX-master my-name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
583 (setq TeX-master t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
584
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
585 ;; For files shared between many documents.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
586 ((eq 'shared TeX-master)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
587 (setq TeX-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
588 (TeX-strip-extension
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
589 (read-file-name "Master file: (default this file) "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
590 nil "///")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
591 (list TeX-default-extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
592 'path))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
593 (if (or (string-equal TeX-master "///")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
594 (string-equal TeX-master ""))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
595 (setq TeX-master t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
596
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
597 ;; We might already know the name.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
598 (TeX-master)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
599
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
600 ;; Support the ``Master:'' line (under protest!)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
601 ((re-search-forward
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
602 "^%% *[Mm]aster:?[ \t]*\\([^ \t\n]+\\)" 500 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
603 (setq TeX-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
604 (TeX-strip-extension (TeX-match-buffer 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
605 (list TeX-default-extension)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
606 (if TeX-convert-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
607 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
608 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
609 (kill-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
610 (TeX-add-local-master))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
611
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
612 ;; Is this a master file?
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
613 ((re-search-forward TeX-header-end 10000 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
614 (setq TeX-master my-name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
615
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
616 ;; Ask the user (but add it as a local variable).
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
617 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
618 (setq TeX-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
619 (TeX-strip-extension
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
620 (condition-case name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
621 (read-file-name "Master file: (default this file) "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
622 nil "<default>")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
623 (quit "<quit>"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
624 (list TeX-default-extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
625 'path))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
626 (cond ((string-equal TeX-master "<quit>")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
627 (setq TeX-master t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
628 ((or (string-equal TeX-master "<default>")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
629 (string-equal TeX-master ""))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
630 (setq TeX-master t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
631 (TeX-add-local-master))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
632 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
633 (TeX-add-local-master)))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
634
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
635 (let ((name (if (eq TeX-master t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
636 my-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
637 TeX-master)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
638
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
639 (if (TeX-match-extension name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
640 ;; If it already have an extension...
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
641 (if (equal extension TeX-default-extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
642 ;; Use instead of the default extension
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
643 (setq extension nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
644 ;; Otherwise drop it.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
645 (setq name (TeX-strip-extension name))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
646
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
647 ;; Remove directory if needed.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
648 (if nondirectory
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
649 (setq name (file-name-nondirectory name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
650
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
651 (if extension
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
652 (concat name "." extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
653 name))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
654
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
655 (defun TeX-master-directory ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
656 "Directory of master file."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
657 (abbreviate-file-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
658 (expand-file-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
659 (concat (file-name-directory buffer-file-name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
660 (file-name-directory (TeX-master-file))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
661
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
662 (defvar TeX-master t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
663 "*The master file associated with the current buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
664 If the file being edited is actually included from another file, you
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
665 can tell AUC TeX the name of the master file by setting this variable.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
666 If there are multiple levels of nesting, specify the top level file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
667
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
668 If this variable is nil, AUC TeX will query you for the name.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
669
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
670 If the variable is t, AUC TeX will assume the file is a master file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
671 itself.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
672
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
673 If the variable is 'shared, AUC TeX will query for the name, but not
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
674 change the file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
675
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
676 It is suggested that you use the File Variables (see the info node in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
677 the Emacs manual) to set this variable permanently for each file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
678
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
679 (make-variable-buffer-local 'TeX-master)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
680
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
681 (defvar TeX-convert-master t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
682 "*If not nil, automatically convert ``Master:'' lines to file variables.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
683 This will be done when AUC TeX first try to use the master file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
684
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
685 (defun TeX-add-local-master ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
686 "Add local variable for TeX-master."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
687
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
688 (if (and (buffer-file-name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
689 (string-match TeX-one-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
690 (file-name-nondirectory (buffer-file-name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
691 (not buffer-read-only))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
692 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
693 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
694 (if (re-search-backward (concat "^\\([^\n]+\\)Local " "Variables:")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
695 (- (point-max) 3000) t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
696 (let ((prefix (TeX-match-buffer 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
697 (re-search-forward (regexp-quote (concat prefix
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
698 "End:")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
699 (beginning-of-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
700 (insert prefix "TeX-master: " (prin1-to-string TeX-master) "\n"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
701 (insert "\n%%% Local " "Variables: \n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
702 "%%% mode: " (substring (symbol-name major-mode) 0 -5)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
703 "\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
704 "%%% TeX-master: " (prin1-to-string TeX-master) "\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
705 "%%% End: \n")))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
706
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
707 ;;; Style Paths
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
708
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
709 (or (string-match "/\\'" TeX-lisp-directory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
710 (setq TeX-lisp-directory (concat TeX-lisp-directory "/")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
711
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
712 (defvar TeX-auto-global (concat TeX-lisp-directory "auto/")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
713 "*Directory containing automatically generated information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
714 Must end with a slash.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
715
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
716 For storing automatic extracted information about the TeX macros
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
717 shared by all users of a site.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
718
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
719 (defvar TeX-style-global (concat TeX-lisp-directory "style/")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
720 "*Directory containing hand generated TeX information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
721 Must end with a slash.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
722
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
723 These correspond to TeX macros shared by all users of a site.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
724
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
725 (defvar TeX-auto-local "auto/"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
726 "*Directory containing automatically generated TeX information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
727 Must end with a slash.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
728
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
729 This correspond to TeX macros found in the current directory.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
730
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
731 (defvar TeX-style-local "style/"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
732 "*Directory containing hand generated TeX information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
733 Must end with a slash.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
734
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
735 These correspond to TeX macros found in the current directory.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
736
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
737 (defun TeX-split-string (regexp string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
738 "Returns a list of strings. given REGEXP the STRING is split into
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
739 sections which in string was seperated by REGEXP.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
740
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
741 Examples:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
742
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
743 (TeX-split-string \"\:\" \"abc:def:ghi\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
744 -> (\"abc\" \"def\" \"ghi\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
745
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
746 (TeX-split-string \" *\" \"dvips -Plw -p3 -c4 testfile.dvi\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
747
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
748 -> (\"dvips\" \"-Plw\" \"-p3\" \"-c4\" \"testfile.dvi\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
749
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
750 If REGEXP is nil, or \"\", an error will occur."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
751
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
752 (let ((start 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
753 (result '()))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
754 (while (string-match regexp string start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
755 (let ((match (string-match regexp string start)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
756 (setq result (cons (substring string start match) result))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
757 (setq start (match-end 0))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
758 (setq result (cons (substring string start nil) result))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
759 (nreverse result)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
760
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
761 (defun TeX-directory-absolute-p (dir)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
762 ;; Non-nil iff DIR is the name of an absolute directory.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
763 (if (memq system-type '(ms-dos emx windows-nt))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
764 (string-match "^\\([A-Za-z]:\\)?/" dir)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
765 (string-match "^/" dir)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
766
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
767 (defun TeX-parse-path (env)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
768 ;; Return a list if private TeX directories found in environment
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
769 ;; variable ENV.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
770 (let* ((value (getenv env))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
771 (entries (and value (TeX-split-string ":" value)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
772 entry
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
773 answers)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
774 (while entries
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
775 (setq entry (car entries))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
776 (setq entries (cdr entries))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
777 (or (string-match "/$" entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
778 (setq entry (concat entry "/")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
779 (and (string-match "//$" entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
780 (setq entry (substring entry 0 -1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
781 (or (not (TeX-directory-absolute-p entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
782 (member entry TeX-macro-global)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
783 (string-equal "/" entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
784 (setq answers (cons entry answers))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
785 answers))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
786
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
787 (defvar TeX-macro-private (append (TeX-parse-path "TEXINPUTS")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
788 (TeX-parse-path "BIBINPUTS"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
789 "*Directories where you store your personal TeX macros.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
790 Each must end with a slash.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
791
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
792 (defvar TeX-auto-private (mapcar (function (lambda (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
793 (concat entry TeX-auto-local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
794 TeX-macro-private)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
795 "*List of directories containing automatically generated information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
796 Must end with a slash.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
797
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
798 These correspond to the personal TeX macros.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
799
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
800 (if (stringp TeX-auto-private) ;Backward compatibility
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
801 (setq TeX-auto-private (list TeX-auto-private)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
802
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
803 (defvar TeX-style-private (mapcar (function (lambda (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
804 (concat entry
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
805 TeX-style-local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
806 TeX-macro-private)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
807 "*List of directories containing hand generated information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
808 Must end with a slash.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
809
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
810 These correspond to the personal TeX macros.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
811
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
812 (if (stringp TeX-style-private) ;Backward compatibility
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
813 (setq TeX-style-private (list TeX-style-private)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
814
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
815 (defvar TeX-style-path
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
816 (let ((path))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
817 (mapcar (function (lambda (file) (if file (setq path (cons file path)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
818 (append (list TeX-auto-global TeX-style-global)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
819 TeX-auto-private TeX-style-private
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
820 (list TeX-auto-local TeX-style-local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
821 path)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
822 "*List of directories to search for AUC TeX style files.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
823
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
824 (defvar TeX-check-path (append (list "./") TeX-macro-private TeX-macro-global)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
825 "*Directory path to search for dependencies.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
826
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
827 If nil, just check the current file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
828 Used when checking if any files have changed.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
829
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
830 ;;; Style Files
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
831
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
832 (defvar TeX-style-hook-list nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
833 "List of TeX style hooks currently loaded.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
834
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
835 Each entry is a list where the first element is the name of the style,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
836 and the remaining elements are hooks to be run when that style is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
837 active.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
838
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
839 (defvar TeX-byte-compile nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
840 "*Not nil means try to byte compile auto files before loading.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
841
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
842 (defun TeX-load-style (style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
843 "Search for and load each definition for style in TeX-style-path."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
844 (cond ((assoc style TeX-style-hook-list)) ; We already found it
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
845 ((string-match "\\`\\(.+/\\)\\([^/]*\\)\\'" style) ;Complex path
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
846 (let* ((dir (substring style (match-beginning 1) (match-end 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
847 (style (substring style (match-beginning 2) (match-end 2)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
848 (TeX-style-path (append (list (concat dir TeX-auto-local)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
849 (concat dir TeX-style-local))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
850 TeX-style-path)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
851 (TeX-load-style style)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
852 (t ;Relative path
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
853 ;; Insert empty list to mark the fact that we have searched.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
854 (setq TeX-style-hook-list (cons (list style) TeX-style-hook-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
855 ;; Now check each element of the path
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
856 (mapcar (function (lambda (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
857 (TeX-load-style-file (if (string-match "/$" name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
858 (concat name style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
859 (concat name "/" style)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
860 TeX-style-path))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
861
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
862 (defun TeX-load-style-file (file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
863 ;; Load FILE checking for a lisp extensions.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
864 (let ((el (concat file ".el"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
865 (elc (concat file ".elc")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
866 (cond ((and (null TeX-byte-compile)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
867 (file-readable-p el))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
868 (load-file el))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
869 ((file-newer-than-file-p el elc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
870 (if (not (file-writable-p elc))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
871 (load-file el)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
872 (byte-compile-file el)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
873 (load-file elc)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
874 ((file-readable-p elc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
875 (load-file elc))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
876 ((file-readable-p el)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
877 (load-file el)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
878
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
879 (defun TeX-add-style-hook (style hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
880 "Give STYLE yet another HOOK to run."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
881 (let ((entry (assoc style TeX-style-hook-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
882 (if (null entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
883 (setq TeX-style-hook-list (cons (list style hook) TeX-style-hook-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
884 (setcdr entry (cons hook (cdr entry))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
885
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
886 (defun TeX-unload-style (style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
887 "Forget that we once loaded STYLE."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
888 (cond ((null (assoc style TeX-style-hook-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
889 ((equal (car (car TeX-style-hook-list)) style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
890 (setq TeX-style-hook-list (cdr TeX-style-hook-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
891 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
892 (let ((entry TeX-style-hook-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
893 (while (not (equal (car (car (cdr entry))) style))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
894 (setq entry (cdr entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
895 (setcdr entry (cdr (cdr entry)))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
896
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
897 (defvar TeX-virgin-style (if (and TeX-auto-global
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
898 (file-directory-p TeX-auto-global))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
899 "virtex"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
900 "NoVirtexSymbols")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
901 "Style all documents use.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
902
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
903 (defvar TeX-active-styles nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
904 "List of styles currently active in the document.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
905
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
906 (make-variable-buffer-local 'TeX-active-styles)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
907
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
908 (defun TeX-run-style-hooks (&rest styles)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
909 "Run the TeX following style hooks."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
910 (mapcar (function
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
911 (lambda (style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
912 (if (TeX-member style TeX-active-styles 'string-equal)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
913 () ;Avoid recursion.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
914 (setq TeX-active-styles
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
915 (cons style TeX-active-styles))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
916 (TeX-load-style style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
917 (if (string-match "\\`\\(.+/\\)\\([^/]*\\)\\'" style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
918 (setq style ; Complex path
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
919 (substring style (match-beginning 2) (match-end 2))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
920 (mapcar 'funcall
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
921 (cdr-safe (assoc style TeX-style-hook-list))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
922 styles))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
923
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
924 (defvar TeX-parse-self nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
925 "*Parse file after loading it if no style hook is found for it.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
926
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
927 (defvar TeX-style-hook-applied-p nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
928 "Nil, unless the style specific hooks have been applied.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
929 (make-variable-buffer-local 'TeX-style-hook-applied-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
930
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
931 (defun TeX-update-style (&optional force)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
932 "Run style specific hooks for the current document.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
933
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
934 Only do this if it has not been done before, or if optional argument
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
935 FORCE is not nil."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
936
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
937 (if (or (eq TeX-auto-update 'BibTeX) ; Not a real TeX buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
938 (and (not force) TeX-style-hook-applied-p))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
939 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
940 (setq TeX-style-hook-applied-p t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
941 (message "Applying style hooks...")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
942 (TeX-run-style-hooks (TeX-strip-extension nil nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
943 ;; Run parent style hooks if it has a single parent that isn't itself.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
944 (if (or (not (memq TeX-master '(nil t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
945 (and (buffer-file-name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
946 (string-match TeX-one-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
947 (file-name-nondirectory (buffer-file-name)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
948 (TeX-run-style-hooks (TeX-master-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
949
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
950 (if (and TeX-parse-self
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
951 (null (cdr-safe (assoc (TeX-strip-extension nil nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
952 TeX-style-hook-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
953 (TeX-auto-apply))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
954
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
955 (message "Applying style hooks... done")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
956
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
957 (defvar TeX-remove-style-hook nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
958 "List of hooks to call when we remove the style specific information.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
959 (make-variable-buffer-local 'TeX-remove-style-hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
960
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
961 (defun TeX-remove-style ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
962 "Remnove all style specific information."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
963 (setq TeX-style-hook-applied-p nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
964 (run-hooks 'TeX-remove-style-hooks)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
965 (setq TeX-active-styles (list TeX-virgin-style)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
966
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
967 (defun TeX-style-list ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
968 "Return a list of all styles (subfils) use by the current document."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
969 (TeX-update-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
970 TeX-active-styles)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
971
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
972 ;;; Special Characters
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
973
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
974 (defvar TeX-esc "\\" "The TeX escape character.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
975 (make-variable-buffer-local 'TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
976
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
977 (defvar TeX-grop "{" "The TeX group opening character.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
978 (make-variable-buffer-local 'TeX-grop)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
979
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
980 (defvar TeX-grcl "}" "The TeX group closing character.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
981 (make-variable-buffer-local 'TeX-grcl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
982
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
983 ;;; Symbols
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
984
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
985 ;; Must be before keymaps.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
986
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
987 (defvar TeX-complete-word 'ispell-complete-word
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
988 "*Function to call for completing non-macros in tex-mode.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
989
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
990 (defvar TeX-complete-list nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
991 "List of ways to complete the preceding text.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
992
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
993 Each entry is a list with the following elements:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
994
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
995 0. Regexp matching the preceding text.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
996 1. A number indicating the subgroup in the regexp containing the text.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
997 2. A function returning an alist of possible completions.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
998 3. Text to append after a succesful completion.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
999
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1000 Or alternatively:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1001
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1002 0. Regexp matching the preceding text.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1003 1. Function to do the actual completion.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1004
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1005 (defun TeX-complete-symbol ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1006 "Perform completion on TeX/LaTeX symbol preceding point."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1007 (interactive "*")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1008 (let ((list TeX-complete-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1009 entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1010 (while list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1011 (setq entry (car list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1012 list (cdr list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1013 (if (TeX-looking-at-backward (car entry) 250)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1014 (setq list nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1015 (if (numberp (nth 1 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1016 (let* ((sub (nth 1 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1017 (close (nth 3 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1018 (begin (match-beginning sub))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1019 (end (match-end sub))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1020 (pattern (TeX-match-buffer 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1021 (symbol (buffer-substring begin end))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1022 (list (funcall (nth 2 entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1023 (completion (try-completion symbol list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1024 (cond ((eq completion t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1025 (and close
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1026 (not (looking-at (regexp-quote close)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1027 (insert close)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1028 ((null completion)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1029 (error "Can't find completion for \"%s\"" pattern))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1030 ((not (string-equal symbol completion))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1031 (delete-region begin end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1032 (insert completion)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1033 (and close
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1034 (eq (try-completion completion list) t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1035 (not (looking-at (regexp-quote close)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1036 (insert close)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1037 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1038 (message "Making completion list...")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1039 (let ((list (all-completions symbol list nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1040 (with-output-to-temp-buffer "*Completions*"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1041 (display-completion-list list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1042 (message "Making completion list...done"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1043 (funcall (nth 1 entry)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1044
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1045 (defvar TeX-default-macro "ref"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1046 "*The default macro when creating new ones with TeX-insert-macro.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1047
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1048 (make-variable-buffer-local 'TeX-default-macro)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1049
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1050 (defvar TeX-insert-braces t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1051 "*If non-nil, append a empty pair of braces after inserting a macro.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1052
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1053 (defun TeX-math-mode-p ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1054 "Are we in TeX math mode?"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1055 ;; This should check for dollar signs, but thats to hard for now.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1056 (and (boundp 'LaTeX-math-mode) LaTeX-math-mode))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1057
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1058 (defun TeX-insert-macro (symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1059 "Insert TeX macro with completion.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1060
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1061 AUC TeX knows of some macros, and may query for extra arguments."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1062 (interactive (list (completing-read (concat "Macro (default "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1063 TeX-default-macro
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1064 "): "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1065 TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1066 (TeX-symbol-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1067 (cond ((string-equal symbol "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1068 (setq symbol TeX-default-macro))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1069 ((interactive-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1070 (setq TeX-default-macro symbol)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1071 (TeX-parse-macro symbol (cdr-safe (assoc symbol (TeX-symbol-list)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1072
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1073 (defvar TeX-electric-macro-map nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1074
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1075 (if TeX-electric-macro-map
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1076 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1077 (setq TeX-electric-macro-map (copy-keymap minibuffer-local-completion-map))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1078 (define-key TeX-electric-macro-map " " 'minibuffer-complete-and-exit))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1079
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1080 (defun TeX-electric-macro ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1081 "Insert TeX macro with completion.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1082
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1083 AUC TeX knows of some macros, and may query for extra arguments.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1084 Space will complete and exit."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1085 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1086 (if (memq (preceding-char) '(?\\ ?.))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1087 (call-interactively 'self-insert-command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1088 (let ((minibuffer-local-completion-map TeX-electric-macro-map))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1089 (call-interactively 'TeX-insert-macro))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1090
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1091 (defun TeX-parse-macro (symbol args)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1092 "How to parse TeX macros which takes one or more arguments."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1093
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1094 ;; First argument is the name of the macro.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1095
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1096 ;; If called with no additional arguments, insert macro with point
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1097 ;; inside braces. Otherwise, each argument of this function should
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1098 ;; match an argument to the TeX macro. What is done depend on the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1099 ;; argument type.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1100
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1101 ;; string: Use the string as a prompt to prompt for the argument.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1102
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1103 ;; number: Insert that many braces, leave point inside the first.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1104
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1105 ;; nil: Insert empty braces.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1106
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1107 ;; t: Insert empty braces, leave point between the braces.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1108
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1109 ;; other symbols: Call the symbol as a function. You can define
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1110 ;; your own hook, or use one of the predefined argument hooks. If
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1111 ;; you add new hooks, you can assume that point is placed directly
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1112 ;; after the previous argument, or after the macro name if this is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1113 ;; the first argument. Please leave point located efter the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1114 ;; argument you are inserting. If you want point to be located
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1115 ;; somewhere else after all hooks have been processed, set the value
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1116 ;; of `exit-mark'. It will point nowhere, until the argument hook
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1117 ;; set it. By convention, these hook all start with `TeX-arg-'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1118
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1119 ;; list: If the car is a string, insert it as a prompt and the next
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1120 ;; element as initial input. Otherwise, call the car of the list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1121 ;; with the remaining elements as arguments.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1122
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1123 ;; vector: Optional argument. If it has more than one element,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1124 ;; parse it as a list, otherwise parse the only element as above.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1125 ;; Use square brackets instead of curly braces, and is not inserted
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1126 ;; on empty user input.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1127
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1128 (insert TeX-esc symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1129 (let ((exit-mark (make-marker))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1130 (position (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1131 (TeX-parse-arguments args)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1132 (cond ((marker-position exit-mark)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1133 (goto-char (marker-position exit-mark))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1134 (set-marker exit-mark nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1135 ((and TeX-insert-braces
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1136 (equal position (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1137 (string-match "[a-zA-Z]+" symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1138 (not (TeX-math-mode-p)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1139 (insert TeX-grop TeX-grcl)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1140
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1141 (defun TeX-arg-string (optional &optional prompt input)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1142 "Prompt for a string."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1143 (TeX-argument-insert
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1144 (read-string (TeX-argument-prompt optional prompt "Text") input)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1145 optional))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1146
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1147 (defun TeX-parse-arguments (args)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1148 "Parse TeX macro arguments.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1149
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1150 See TeX-parse-macro for details."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1151 (let ((last-optional-rejected nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1152 (while args
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1153 (if (vectorp (car args))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1154 (if last-optional-rejected
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1155 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1156 (let ((< LaTeX-optop)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1157 (> LaTeX-optcl))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1158 (TeX-parse-argument t (if (equal (length (car args)) 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1159 (aref (car args) 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1160 (append (car args) nil)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1161 (let ((< TeX-grop)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1162 (> TeX-grcl))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1163 (setq last-optional-rejected nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1164 (TeX-parse-argument nil (car args))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1165 (setq args (cdr args)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1166
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1167 (defun TeX-parse-argument (optional arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1168 "Depending on OPTIONAL, insert TeX macro argument ARG in curly braces.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1169 If OPTIONAL is set, only insert if there is anything to insert, and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1170 then use scare brackets.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1171
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1172 See TeX-parse-macro for details."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1173
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1174 (cond ((stringp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1175 (TeX-arg-string optional arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1176 ((numberp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1177 (if (< arg 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1178 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1179 (TeX-parse-argument optional t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1180 (while (> arg 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1181 (TeX-parse-argument optional nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1182 (setq arg (- arg 1)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1183 ((null arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1184 (insert < >))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1185 ((eq arg t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1186 (insert < )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1187 (set-marker exit-mark (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1188 (insert >))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1189 ((symbolp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1190 (funcall arg optional))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1191 ((listp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1192 (let ((head (car arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1193 (tail (cdr arg)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1194 (cond ((stringp head)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1195 (apply 'TeX-arg-string optional arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1196 ((symbolp head)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1197 (apply head optional tail))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1198 (t (error "Unknown list argument type %s"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1199 (prin1-to-string head))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1200 (t (error "Unknown argument type %s" (prin1-to-string arg)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1201
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1202 (defun TeX-argument-insert (name optional &optional prefix)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1203 "Insert NAME surrounded by curly braces.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1204
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1205 If OPTIONAL, only insert it if not empty, and then use scuare brackets."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1206 (if (and optional (string-equal name ""))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1207 (setq last-optional-rejected t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1208 (insert <)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1209 (if prefix
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1210 (insert prefix))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1211 (if (and (string-equal name "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1212 (null (marker-position exit-mark)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1213 (set-marker exit-mark (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1214 (insert name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1215 (insert >)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1216
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1217 (defun TeX-argument-prompt (optional prompt default &optional complete)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1218 "Return a argument prompt.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1219
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1220 If OPTIONAL is not nil then the prompt will start with ``(Optional) ''.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1221
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1222 PROMPT will be used if not nil, otherwise use DEFAULT.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1223
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1224 Unless optional argument COMPLETE is non-nil, ``: '' will be appended."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1225 (concat (if optional "(Optional) " "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1226 (if prompt prompt default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1227 (if complete "" ": ")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1228
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1229 ;;; The Mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1230
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1231 (defvar TeX-format-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1232 '(("AMSTEX" ams-tex-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1233 "\\\\document\\b")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1234 ("LATEX" latex-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1235 "\\\\\\(begin\\|section\\|chapter\\|documentstyle\\|documentclass\\)\\b")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1236 ("TEX" plain-tex-mode "."))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1237 "*List of format packages to consider when choosing a TeX mode.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1238
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1239 A list with a entry for each format package available at the site.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1240
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1241 Each entry is a list with three elements.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1242
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1243 1. The name of the format package.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1244 2. The name of the major mode.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1245 3. A regexp typically matched in the beginning of the file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1246
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1247 When entering tex-mode, each regexp is tried in turn in order to find
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1248 when major mode to enter.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1249
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1250 (defvar TeX-default-mode 'latex-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1251 "*Mode to enter for a new file when it can't be determined whether
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1252 the file is plain TeX or LaTeX or what.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1253
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1254 (defvar TeX-force-default-mode nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1255 "*If set to nil, try to infer the mode of the file from its content.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1256
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1257 ;;; Do not ;;;###autoload because of conflict with standard tex-mode.el.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1258 (defun tex-mode ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1259 "Major mode for editing files of input for TeX or LaTeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1260 Tries to guess whether this file is for plain TeX or LaTeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1261
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1262 The algorithm is as follows:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1263
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1264 1) if the file is empty or TeX-force-default-mode is not set to nil,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1265 TeX-default-mode is chosen
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1266 2) If \\documentstyle or \\begin{, \\section{, \\part{ or \\chapter{ is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1267 found, latex-mode is selected.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1268 3) Otherwise, use plain-tex-mode "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1269 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1270
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1271 (funcall (if (or (equal (buffer-size) 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1272 TeX-force-default-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1273 TeX-default-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1274 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1275 (goto-char (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1276 (let ((comment-start-skip ;Used by TeX-in-comment
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1277 (concat
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1278 "\\(\\(^\\|[^\\]\\)\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1279 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1280 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1281 "\\)*\\)\\(%+ *\\)"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1282 (entry TeX-format-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1283 answer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1284 (while (and entry (not answer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1285 (if (re-search-forward (nth 2 (car entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1286 10000 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1287 (if (not (TeX-in-comment))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1288 (setq answer (nth 1 (car entry))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1289 (setq entry (cdr entry))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1290 (if answer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1291 answer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1292 TeX-default-mode))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1293
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1294 ;;; Do not ;;;###autoload because of conflict with standard tex-mode.el.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1295 (defun plain-tex-mode ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1296 "Major mode for editing files of input for plain TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1297 See info under AUC TeX for documentation.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1298
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1299 Special commands:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1300 \\{TeX-mode-map}
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1301
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1302 Entering plain-tex-mode calls the value of text-mode-hook,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1303 then the value of TeX-mode-hook, and then the value
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1304 of plain-TeX-mode-hook."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1305 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1306 (plain-TeX-common-initialization)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1307 (setq mode-name "TeX")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1308 (setq major-mode 'plain-tex-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1309 (setq TeX-command-default "TeX")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1310 (run-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1311
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1312 ;;;###autoload
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1313 (defun ams-tex-mode ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1314 "Major mode for editing files of input for AmS TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1315 See info under AUC TeX for documentation.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1316
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1317 Special commands:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1318 \\{TeX-mode-map}
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1319
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1320 Entering AmS-tex-mode calls the value of text-mode-hook,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1321 then the value of TeX-mode-hook, and then the value
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1322 of AmS-TeX-mode-hook."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1323 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1324 (plain-TeX-common-initialization)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1325 (setq mode-name "AmS TeX")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1326 (setq major-mode 'ams-tex-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1327 (setq TeX-command-default "AmSTeX")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1328 (run-hooks 'text-mode-hook 'TeX-mode-hook 'AmS-TeX-mode-hook))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1329
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1330 (defun VirTeX-common-initialization ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1331 ;; Initialize
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1332 (kill-all-local-variables)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1333 (setq local-abbrev-table text-mode-abbrev-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1334 (setq indent-tabs-mode nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1335
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1336 ;; Ispell support
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1337 (make-local-variable 'ispell-parser)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1338 (setq ispell-parser 'tex)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1339 (make-local-variable 'ispell-tex-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1340 (setq ispell-tex-p t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1341
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1342 ;; Redefine some standard varaibles
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1343 (make-local-variable 'paragraph-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1344 (make-local-variable 'paragraph-separate)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1345 (make-local-variable 'comment-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1346 (setq comment-start "%")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1347 (make-local-variable 'comment-start-skip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1348 (setq comment-start-skip
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1349 (concat
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1350 "\\(\\(^\\|[^\\]\\)\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1351 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1352 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1353 "\\)*\\)\\(%+ *\\)"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1354 (make-local-variable 'comment-indent-hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1355 (setq comment-indent-hook 'TeX-comment-indent)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1356 (make-local-variable 'comment-multi-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1357 (setq comment-multi-line nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1358 (make-local-variable 'compile-command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1359 (if (boundp 'compile-command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1360 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1361 (setq compile-command "make"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1362 (make-local-variable 'words-include-escapes)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1363 (setq words-include-escapes nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1364
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1365 ;; Make TAB stand out
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1366 ;; (make-local-variable 'buffer-display-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1367 ;; (setq buffer-display-table (if standard-display-table
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1368 ;; (copy-sequence standard-display-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1369 ;; (make-display-table)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1370 ;; (aset buffer-display-table ?\t (apply 'vector (append "<TAB>" nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1371
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1372 ;; Symbol completion.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1373 (make-local-variable 'TeX-complete-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1374 (setq TeX-complete-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1375 (list (list "\\\\\\([a-zA-Z]*\\)"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1376 1 'TeX-symbol-list (if TeX-insert-braces "{}"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1377 (list "" TeX-complete-word)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1378
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1379 ;; We want this to be early in the list, so we do not add it before
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1380 ;; we enter TeX mode the first time.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1381 (if (boundp 'local-write-file-hooks)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1382 (add-hook 'local-write-file-hooks 'TeX-safe-auto-write)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1383 (add-hook 'write-file-hooks 'TeX-safe-auto-write))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1384 (make-local-variable 'TeX-auto-update)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1385 (setq TeX-auto-update t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1386
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1387 (defun plain-TeX-common-initialization ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1388 ;; Common initialization for plain TeX like modes.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1389 (VirTeX-common-initialization)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1390 (use-local-map plain-TeX-mode-map)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1391 (easy-menu-add TeX-mode-menu plain-TeX-mode-map)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1392 (easy-menu-add plain-TeX-mode-menu plain-TeX-mode-map)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1393 (set-syntax-table TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1394 (setq paragraph-start
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1395 (concat
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1396 "\\(^[ \t]*$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1397 "\\|" (regexp-quote TeX-esc) "par\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1398 "^[ \t]*"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1399 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1400 "\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1401 "begin\\|end\\|part\\|chapter\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1402 "section\\|subsection\\|subsubsection\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1403 "paragraph\\|include\\|includeonly\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1404 "tableofcontents\\|appendix\\|label\\|caption\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1405 "\\[\\|\\]" ; display math delimitors
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1406 "\\)"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1407 "\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1408 "^[ \t]*\\$\\$" ; display math delimitor
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1409 "\\)" ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1410 (setq paragraph-separate
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1411 (concat
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1412 "\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1413 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1414 "par\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1415 "^[ \t]*$\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1416 "^[ \t]*"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1417 (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1418 "\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1419 "begin\\|end\\|label\\|caption\\|part\\|chapter\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1420 "section\\|subsection\\|subsubsection\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1421 "paragraph\\|include\\|includeonly\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1422 "tableofcontents\\|appendix\\|" (regexp-quote TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1423 "\\)"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1424 "\\)"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1425 (setq TeX-header-end (regexp-quote "%**end of header"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1426 (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1427 (TeX-run-style-hooks "TEX"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1428
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1429 ;;; Hilighting
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1430
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1431 (if (boundp 'hilit-patterns-alist)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1432 (let ((latex-patterns (cdr-safe (assq 'latex-mode hilit-patterns-alist)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1433 (plain-tex-patterns (cdr-safe (assq 'plain-tex-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1434 hilit-patterns-alist))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1435 (if (and latex-patterns plain-tex-patterns)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1436 (setq hilit-patterns-alist
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1437 (append (list (cons 'ams-tex-mode plain-tex-patterns))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1438 hilit-patterns-alist)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1439
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1440 ;;; Parsing
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1441
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1442 (defvar TeX-auto-parser '((styles TeX-auto-file TeX-run-style-hooks)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1443 ;; Alist of parsed information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1444 ;; Each entry is a list with the following elements:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1445 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1446 ;; 0. Name of information type.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1447 ;; 1. Name of temporary variable used when parsing.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1448 ;; 2. Name of function to add information to add to #3.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1449 ;; 3. Name of variable holding buffer local information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1450 ;; 4. Name of variable indicating that #3 has changed.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1451
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1452
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1453 (defconst TeX-auto-parser-temporary 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1454 (defconst TeX-auto-parser-add 2)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1455 (defconst TeX-auto-parser-local 3)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1456 (defconst TeX-auto-parser-change 4)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1457
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1458 (defun TeX-auto-add-type (name prefix &optional plural)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1459 "Add information about name to the parser using PREFIX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1460
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1461 Optional third argument PLURAL is the plural form of TYPE.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1462 By default just add a `s'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1463
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1464 This function create a set of variables and functions to maintain a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1465 separate type of information in the parser."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1466 (let* ((names (or plural (concat name "s")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1467 (tmp (intern (concat prefix "-auto-" name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1468 (add (intern (concat prefix "-add-" names)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1469 (local (intern (concat prefix "-" name "-list")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1470 (change (intern (concat prefix "-" name "-changed"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1471 (setq TeX-auto-parser
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1472 (cons (list name tmp add local change) TeX-auto-parser))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1473 (set local nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1474 (make-variable-buffer-local local)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1475 (set change nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1476 (make-variable-buffer-local change)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1477 (fset add (list 'lambda '(&rest entries)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1478 (concat "Add information about " (upcase name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1479 " to the current buffer.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1480 (list 'TeX-auto-add-information name 'entries)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1481 (fset local (list 'lambda nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1482 (concat "List of " names
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1483 " active in the current buffer.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1484 (list 'TeX-auto-list-information name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1485 (add-hook 'TeX-remove-style-hook
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1486 (list 'lambda nil (list 'setq (symbol-name local) nil)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1487
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1488 (defun TeX-auto-add-information (name entries)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1489 ;; For NAME in `TeX-auto-parser' add ENTRIES.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1490 (let* ((entry (assoc name TeX-auto-parser))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1491 (change (nth TeX-auto-parser-change entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1492 (change-value (symbol-value change))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1493 (local (nth TeX-auto-parser-local entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1494 (local-value (symbol-value local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1495 (if change-value
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1496 (set local (cons entries local-value))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1497 (set change t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1498 (set local (list entries local-value)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1499
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1500 (defun TeX-auto-list-information (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1501 ;; Return information in `TeX-auto-parser' about NAME.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1502 (TeX-update-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1503 (let* ((entry (assoc name TeX-auto-parser))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1504 (change (nth TeX-auto-parser-change entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1505 (change-value (symbol-value change))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1506 (local (nth TeX-auto-parser-local entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1507 (if (not change-value)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1508 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1509 (set change nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1510 ;; Sort it
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1511 (message "Sorting " name "...")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1512 (set local
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1513 (sort (mapcar 'TeX-listify (apply 'append (symbol-value local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1514 'TeX-car-string-lessp))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1515 ;; Make it unique
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1516 (message "Removing duplicates...")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1517 (let ((entry (symbol-value local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1518 (while (and entry (cdr entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1519 (let ((this (car entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1520 (next (car (cdr entry))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1521 (if (not (string-equal (car this) (car next)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1522 (setq entry (cdr entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1523 ;; We have two equal symbols. Use the one with
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1524 ;; most arguments.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1525 (if (> (length next) (length this))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1526 (setcdr this (cdr next)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1527 (setcdr entry (cdr (cdr entry)))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1528 (message "Removing duplicates... done"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1529 (symbol-value local)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1530
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1531 (TeX-auto-add-type "symbol" "TeX")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1532
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1533 (defvar TeX-auto-apply-hook nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1534 "Hook run when a buffer is parsed and the information is applied.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1535
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1536 (defun TeX-auto-apply ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1537 ;; Parse and apply TeX information in the current buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1538 (TeX-auto-parse)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1539 (run-hooks 'TeX-auto-apply-hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1540 (mapcar 'TeX-auto-apply-entry TeX-auto-parser))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1541
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1542 (defun TeX-auto-apply-entry (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1543 ;; Apply the information in an entry in `TeX-auto-parser'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1544 (let ((value (symbol-value (nth TeX-auto-parser-temporary entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1545 (add (nth TeX-auto-parser-add entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1546 (if value (apply add value))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1547
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1548 (defun TeX-safe-auto-write ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1549 ;; Call TeX-auto-write safely
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1550 (condition-case name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1551 (and (boundp 'TeX-auto-update)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1552 TeX-auto-update
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1553 (TeX-auto-write))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1554 (error nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1555 ;; Continue with the other write file hooks.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1556 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1557
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1558 (defvar TeX-auto-save nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1559 "*Automatically save style information when saving the buffer.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1560
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1561 (defvar TeX-auto-untabify t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1562 "*Automatically untabify when saving the buffer.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1563
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1564 (defun TeX-auto-write ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1565 ;; Save all relevant TeX information from the current buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1566 (if TeX-auto-untabify
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1567 (untabify (point-min) (point-max)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1568 (if (and TeX-auto-save TeX-auto-local)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1569 (let* ((file (concat (TeX-master-directory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1570 TeX-auto-local
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1571 (if (string-match "/$" TeX-auto-local) "" "/")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1572 (TeX-strip-extension nil TeX-all-extensions t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1573 ".el"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1574 (dir (file-name-directory file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1575 ;; Create auto directory if possible.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1576 (if (not (file-exists-p dir))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1577 (condition-case name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1578 (make-directory (substring dir 0 -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1579 (error nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1580 (if (file-writable-p file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1581 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1582 (TeX-update-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1583 (TeX-auto-store file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1584 (message "Can't write style information.")))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1585
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1586 (defvar TeX-macro-default (car-safe TeX-macro-private)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1587 "*Default directory to search for TeX macros.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1588
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1589 (defvar TeX-auto-default (car-safe TeX-auto-private)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1590 "*Default directory to place automatically generated TeX information.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1591
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1592 ;;;###autoload
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1593 (defun TeX-auto-generate (tex auto)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1594 "Generate style file for TEX and store it in AUTO.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1595 If TEX is a directory, generate style files for all files in the directory."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1596 (interactive (list (setq TeX-macro-default
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1597 (expand-file-name (read-file-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1598 "TeX file or directory: "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1599 TeX-macro-default
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1600 TeX-macro-default 'confirm)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1601 (setq TeX-auto-default
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1602 (expand-file-name (read-file-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1603 "AUTO lisp directory: "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1604 TeX-auto-default
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1605 TeX-auto-default 'confirm)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1606 (cond ((not (file-readable-p tex)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1607 ((string-match TeX-ignore-file tex))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1608 ((file-directory-p tex)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1609 (let ((files (directory-files tex))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1610 (default-directory (concat (if (TeX-directory-absolute-p tex)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1611 ""
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1612 default-directory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1613 (if (string-match "/$" tex)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1614 tex
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1615 (concat tex "/")))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1616 (mapcar (function (lambda (file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1617 (if (or TeX-file-recurse
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1618 (not (file-directory-p file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1619 (TeX-auto-generate file auto))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1620 files)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1621 ((TeX-match-extension tex (append TeX-file-extensions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1622 BibTeX-file-extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1623 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1624 (set-buffer (find-file-noselect tex))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1625 (message "Parsing %s..." tex)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1626 (TeX-auto-store (concat auto
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1627 (if (string-match "/$" auto) "" "/")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1628 (TeX-strip-extension tex
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1629 TeX-all-extensions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1630 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1631 ".el"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1632 (kill-buffer (current-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1633 (message "Parsing %s... done" tex)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1634
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1635 ;;;###autoload
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1636 (defun TeX-auto-generate-global ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1637 "Create global auto directory for global TeX macro definitions."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1638 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1639 (make-directory (if (string-match "/$" TeX-auto-global)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1640 (substring TeX-auto-global 0 -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1641 TeX-auto-global))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1642 (mapcar (function (lambda (macro) (TeX-auto-generate macro TeX-auto-global)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1643 TeX-macro-global)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1644 (byte-recompile-directory TeX-auto-global 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1645
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1646 (defun TeX-auto-store (file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1647 ;; Extract information for auc tex from current buffer and store it in FILE.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1648 (TeX-auto-parse)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1649
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1650 (if (member nil (mapcar 'TeX-auto-entry-clear-p TeX-auto-parser))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1651 (let ((style (TeX-strip-extension nil TeX-all-extensions t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1652 (TeX-unload-style style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1653 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1654 (set-buffer (generate-new-buffer file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1655 (erase-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1656 (insert "(TeX-add-style-hook \"" style "\"\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1657 " (function\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1658 " (lambda ()")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1659 (mapcar 'TeX-auto-insert TeX-auto-parser)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1660 (insert ")))\n\n")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1661 (write-region (point-min) (point-max) file nil 'silent)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1662 (kill-buffer (current-buffer))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1663 (if (file-exists-p (concat file "c"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1664 (delete-file (concat file "c")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1665 (if (file-exists-p file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1666 (delete-file file))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1667
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1668 (defun TeX-auto-entry-clear-p (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1669 ;; Check if the temporary for `TeX-auto-parser' entry ENTRY is clear.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1670 (null (symbol-value (nth TeX-auto-parser-temporary entry))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1671
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1672 (defun TeX-auto-insert (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1673 ;; Insert code to initialize ENTRY from `TeX-auto-parser'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1674 (let ((name (symbol-name (nth TeX-auto-parser-add entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1675 (list (symbol-value (nth TeX-auto-parser-temporary entry))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1676 (if (null list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1677 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1678 (insert "\n (" name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1679 (while list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1680 (insert "\n ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1681 (if (stringp (car list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1682 (insert (prin1-to-string (car list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1683 (insert "'" (prin1-to-string (car list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1684 (setq list (cdr list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1685 (insert ")"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1686
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1687 (defvar TeX-auto-ignore
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1688 '("csname" "filedate" "fileversion" "docdate" "next" "labelitemi"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1689 "labelitemii" "labelitemiii" "labelitemiv" "labelitemv"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1690 "labelenumi" "labelenumii" "labelenumiii" "labelenumiv"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1691 "labelenumv" "theenumi" "theenumii" "theenumiii" "theenumiv"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1692 "theenumv" "document" "par" "do" "expandafter")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1693 "List of symbols to ignore when scanning a TeX style file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1694
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1695 (defun TeX-auto-add-regexp (regexp)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1696 "Add REGEXP to TeX-auto-regexp-list if not already a member."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1697 (if (symbolp TeX-auto-regexp-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1698 (setq TeX-auto-regexp-list (symbol-value TeX-auto-regexp-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1699 (or (memq regexp TeX-auto-regexp-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1700 (setq TeX-auto-regexp-list (cons regexp TeX-auto-regexp-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1701
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1702 (defvar TeX-auto-empty-regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1703 '(("<IMPOSSIBLE>\\(\\'\\`\\)" 1 ignore))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1704 "List of regular expressions guaranteed to match nothing.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1705
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1706 (defvar plain-TeX-auto-regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1707 '(("\\\\def\\\\\\([a-zA-Z]+\\)[^a-zA-Z@]" 1 TeX-auto-symbol-check)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1708 ("\\\\let\\\\\\([a-zA-Z]+\\)[^a-zA-Z@]" 1 TeX-auto-symbol-check)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1709 ("\\\\font\\\\\\([a-zA-Z]+\\)[^a-zA-Z@]" 1 TeX-auto-symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1710 ("\\\\chardef\\\\\\([a-zA-Z]+\\)[^a-zA-Z@]" 1 TeX-auto-symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1711 ("\\\\new\\(count|dimen|muskip|skip\\)\\\\\\([a-z]+\\)[^a-zA-Z@]"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1712 2 TeX-auto-symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1713 ("\\\\newfont{?\\\\\\([a-zA-Z]+\\)}?" 1 TeX-auto-symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1714 ("\\\\typein\\[\\\\\\([a-zA-Z]+\\)\\]" 1 TeX-auto-symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1715 ("\\\\input +\\(\\.*[^#%\\\\\\.\n\r]+\\)\\(\\.[^#%\\\\\\.\n\r]+\\)?"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1716 1 TeX-auto-file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1717 ("\\\\mathchardef\\\\\\([a-zA-Z]+\\)[^a-zA-Z@]" 1 TeX-auto-symbol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1718 "List of regular expression matching common LaTeX macro definitions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1719
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1720 (defvar TeX-auto-full-regexp-list plain-TeX-auto-regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1721 "Full list of regular expression matching TeX macro definitions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1722
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1723 (defvar TeX-auto-prepare-hook nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1724 "List of hooks to be called before parsing a TeX file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1725
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1726 (defvar TeX-auto-cleanup-hook nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1727 "List of hooks to be called after parsing a TeX file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1728
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1729 (defvar TeX-auto-parse-length 999999
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1730 "*Maximal length of TeX file that will be parsed.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1731 (make-variable-buffer-local 'TeX-auto-parse-length)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1732
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1733 (defun TeX-auto-parse ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1734 "Parse TeX information in current buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1735
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1736 Call the functions in TeX-auto-prepare-hook before parsing, and the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1737 functions in TeX-auto-cleanup-hook after parsing."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1738
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1739 (let ((case-fold-search nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1740 (regexp-list (if (symbolp TeX-auto-regexp-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1741 (symbol-value TeX-auto-regexp-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1742 TeX-auto-regexp-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1743
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1744 (mapcar 'TeX-auto-clear-entry TeX-auto-parser)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1745 (run-hooks 'TeX-auto-prepare-hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1746
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1747 ;; Parse
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1748 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1749 (goto-char (min (point-max) TeX-auto-parse-length))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1750 ;; Extract the information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1751 (let ((regexp (concat "\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1752 (mapconcat 'car regexp-list "\\)\\|\\(")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1753 "\\)")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1754 (while (re-search-backward regexp nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1755 (if (TeX-in-comment)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1756 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1757 (let* ((entry (TeX-member nil regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1758 (function (lambda (a b)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1759 (looking-at (nth 0 b))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1760 (symbol (nth 2 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1761 (match (nth 1 entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1762 (if (fboundp symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1763 (funcall symbol match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1764 (set symbol (cons (if (listp match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1765 (mapcar 'TeX-match-buffer match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1766 (TeX-match-buffer match))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1767 (symbol-value symbol)))))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1768
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1769 ;; Cleanup ignored symbols.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1770
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1771 ;; NOTE: This is O(N M) where it could be O(N log N + M log M) if we
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1772 ;; sorted the lists first.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1773 (while (member (car TeX-auto-symbol) TeX-auto-ignore)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1774 (setq TeX-auto-symbol (cdr TeX-auto-symbol)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1775 (let ((list TeX-auto-symbol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1776 (while (and list (cdr list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1777 (if (member (car (cdr list)) TeX-auto-ignore)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1778 (setcdr list (cdr (cdr list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1779 (setq list (cdr list)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1780
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1781 (run-hooks 'TeX-auto-cleanup-hook)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1782
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1783 (defun TeX-auto-clear-entry (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1784 ;; Set the temporary variable in ENTRY to nil.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1785 (set (nth TeX-auto-parser-temporary entry) nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1786
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1787 (defvar LaTeX-auto-end-symbol nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1788
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1789 (defun TeX-auto-symbol-check (match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1790 "Add MATCH to TeX-auto-symbols.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1791 Check for potential LaTeX environments."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1792 (let ((symbol (if (listp match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1793 (mapcar 'TeX-match-buffer match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1794 (TeX-match-buffer match))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1795 (if (and (stringp symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1796 (string-match "^end\\(.+\\)$" symbol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1797 (setq LaTeX-auto-end-symbol
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1798 (cons (substring symbol (match-beginning 1) (match-end 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1799 LaTeX-auto-end-symbol))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1800 (setq TeX-auto-symbol (cons symbol TeX-auto-symbol)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1801
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1802 ;;; Utilities
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1803 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1804 ;; Some of these functions has little to do with TeX, but nonetheless we
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1805 ;; should use the "TeX-" prefix to avoid name clashes.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1806
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1807 (defvar TeX-auto-regexp-list 'TeX-auto-full-regexp-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1808 "*List of regular expresions used for parsing the current file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1809 (make-variable-buffer-local 'TeX-auto-regexp-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1810
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1811 (defvar TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "texinfo")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1812 "*File extensions used by manually generated TeX files.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1813
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1814 (defvar TeX-all-extensions '("[^.\n]+")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1815 "All possible file extensions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1816
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1817 (defvar TeX-default-extension "tex"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1818 "*Default extension for TeX files.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1819
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1820 (make-variable-buffer-local 'TeX-default-extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1821
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1822 (defvar BibTeX-file-extensions '("bib")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1823 "Valid file extensions for BibTeX files.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1824
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1825 (defvar BibTeX-style-extensions '("bst")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1826 "Valid file extensions for BibTeX styles.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1827
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1828 (defvar TeX-ignore-file "\\(^\\|/\\)\\(\\.\\|\\.\\.\\|RCS\\|SCCS\\|CVS\\)$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1829 "*Regular expression matching file names to ignore.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1830
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1831 These files or directories will not be considered when searching for
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1832 TeX files in a directory.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1833
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1834 (defvar TeX-file-recurse t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1835 "*If not nil, search TeX directories recursivly.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1836
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1837 (defun TeX-match-extension (file &optional extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1838 "Return non-nil if FILE has an one of EXTENSIONS.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1839
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1840 If EXTENSIONS is not specified or nil, the value of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1841 TeX-file-extensions is used instead."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1842
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1843 (if (null extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1844 (setq extensions TeX-file-extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1845
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1846 (let ((regexp (concat "\\.\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1847 (mapconcat 'identity extensions "\\|")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1848 "\\)$")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1849 (string-match regexp file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1850
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1851 (defun TeX-strip-extension (&optional string extensions nodir nostrip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1852 "Return STRING without any trailing extension in EXTENSIONS.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1853 If NODIR is `t', also remove directory part of STRING.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1854 If NODIR is `path', remove directory part of STRING if it is equal to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1855 the current directory, TeX-macro-private or TeX-macro-global.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1856 If NOSTRIP is set, do not remove extension after all.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1857 STRING defaults to the name of the current buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1858 EXTENSIONS defaults to TeX-file-extensions."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1859
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1860 (if (null string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1861 (setq string (or (buffer-file-name) "<none>")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1862
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1863 (if (null extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1864 (setq extensions TeX-file-extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1865
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1866 (let* ((strip (if (and (not nostrip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1867 (TeX-match-extension string extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1868 (substring string 0 (match-beginning 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1869 string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1870 (dir (file-name-directory (expand-file-name strip))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1871 (if (or (eq nodir t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1872 (string-equal dir (expand-file-name "./"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1873 (member dir TeX-macro-global)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1874 (member dir TeX-macro-private))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1875 (file-name-nondirectory strip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1876 strip)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1877
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1878 (defun TeX-search-files (&optional directories extensions nodir strip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1879 "Return a list of all reachable files in DIRECTORIES ending with EXTENSIONS.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1880 If optional argument NODIR is set, remove directory part.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1881 If optional argument STRIP is set, remove file extension.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1882 If optional argument DIRECTORIES is set, search in those directories.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1883 Otherwise, search in all TeX macro directories.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1884 If optional argument EXTENSIONS is not set, use TeX-file-extensions"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1885
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1886 (if (null extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1887 (setq extensions TeX-file-extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1888
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1889 (if (null directories)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1890 (setq directories
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1891 (cons "./" (append TeX-macro-private TeX-macro-global))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1892
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1893 (let (match)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1894
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1895 (while directories
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1896 (let* ((directory (car directories))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1897 (content (and directory
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1898 (file-readable-p directory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1899 (file-directory-p directory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1900 (directory-files directory))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1901
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1902 (setq directories (cdr directories))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1903
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1904 (while content
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1905 (let ((file (concat directory (car content))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1906
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1907 (setq content (cdr content))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1908 (cond ((string-match TeX-ignore-file file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1909 ((not (file-readable-p file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1910 ((file-directory-p file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1911 (if TeX-file-recurse
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1912 (setq directories
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1913 (cons (concat file "/") directories))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1914 ((TeX-match-extension file extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1915 (setq match (cons (TeX-strip-extension file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1916 extensions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1917 nodir
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1918 (not strip))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1919 match))))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1920
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1921 match))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1922
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1923 (defun TeX-car-string-lessp (a b)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1924 (string-lessp (car a) (car b)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1925
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1926 (defun TeX-listify (a)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1927 (if (listp a) a (list a)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1928
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1929 (defun TeX-member (elt list how)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1930 "Returns the member ELT in LIST. Comparison done with HOW.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1931
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1932 Return nil if ELT is not a member of LIST."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1933 (while (and list (not (funcall how elt (car list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1934 (setq list (cdr list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1935 (car-safe list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1936
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1937 (defun TeX-assoc (elem list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1938 "Like assoc, except case incentive."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1939 (let ((case-fold-search t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1940 (TeX-member elem list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1941 (function (lambda (a b)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1942 (string-match (concat "^" (regexp-quote a) "$")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1943 (car b)))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1944
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1945 (defun TeX-match-buffer (n)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1946 "Return the substring corresponding to the N'th match.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1947 See match-data for details."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1948 (if (match-beginning n)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1949 (let ((str (buffer-substring (match-beginning n) (match-end n))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1950 (set-text-properties 0 (length str) nil str)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1951 (copy-sequence str))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1952 ""))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1953
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1954 (defun TeX-function-p (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1955 "Return non-nil if ARG is callable as a function."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1956 (or (and (fboundp 'byte-code-function-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1957 (byte-code-function-p arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1958 (and (listp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1959 (eq (car arg) 'lambda))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1960 (and (symbolp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1961 (fboundp arg))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1962
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1963 (defun TeX-looking-at-backward (regexp &optional limit)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1964 ;; Return non-nil if the text before point matches REGEXP.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1965 ;; Optional second argument LIMIT gives a max number of characters
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1966 ;; to look backward for.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1967 (let ((pos (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1968 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1969 (and (re-search-backward regexp
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1970 (if limit (max (point-min) (- (point) limit)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1971 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1972 (eq (match-end 0) pos)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1973
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1974 ;;; Syntax Table
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1975
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1976 (defvar TeX-mode-syntax-table (make-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1977 "Syntax table used while in TeX mode.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1978
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1979 (make-variable-buffer-local 'TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1980
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1981 (progn ; Define TeX-mode-syntax-table.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1982 (modify-syntax-entry (string-to-char TeX-esc)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1983 "\\" TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1984 (modify-syntax-entry ?\f ">" TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1985 (modify-syntax-entry ?\n ">" TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1986 (modify-syntax-entry (string-to-char TeX-grop)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1987 (concat "(" TeX-grcl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1988 TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1989 (modify-syntax-entry (string-to-char TeX-grcl)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1990 (concat ")" TeX-grop)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1991 TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1992 (modify-syntax-entry ?% "<" TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1993 (modify-syntax-entry ?\" "." TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1994 (modify-syntax-entry ?& "." TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1995 (modify-syntax-entry ?_ "." TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1996 (modify-syntax-entry ?@ "_" TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1997 (modify-syntax-entry ?~ " " TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1998 (modify-syntax-entry ?$ "$" TeX-mode-syntax-table)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1999 (modify-syntax-entry ?' "w" TeX-mode-syntax-table))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2000
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2001 ;;; Menu Support
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2002
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2003 (defvar TeX-command-current 'TeX-command-master)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2004 ;; Function used to run external command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2005
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2006 (defun TeX-command-select-master ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2007 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2008 (message "Next command will be on the master file")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2009 (setq TeX-command-current 'TeX-command-master))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2010
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2011 (defun TeX-command-select-buffer ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2012 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2013 (message "Next command will be on the buffer")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2014 (setq TeX-command-current 'TeX-command-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2015
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2016 (defun TeX-command-select-region ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2017 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2018 (message "Next command will be on the region")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2019 (setq TeX-command-current 'TeX-command-region))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2020
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2021 (defvar TeX-command-force nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2022 ;; If non-nil, TeX-command-query will return the value of this
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2023 ;; variable instead of quering the user.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2024
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2025 (defun TeX-command-menu (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2026 ;; Execute TeX-command-list NAME from a menu.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2027 (let ((TeX-command-force name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2028 (funcall TeX-command-current)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2029
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2030 (defun TeX-command-menu-print (printer command name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2031 ;; Print on PRINTER using method COMMAND to run NAME.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2032 (let ((TeX-printer-default printer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2033 (TeX-printer-list nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2034 (TeX-print-command command))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2035 (TeX-command-menu name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2036
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2037 (defun TeX-command-menu-printer-entry (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2038 ;; Return TeX-printer-list ENTRY as a menu item.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2039 (vector (nth 0 entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2040 (list 'TeX-command-menu-print
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2041 (nth 0 entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2042 (or (nth lookup entry) command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2043 name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2044 t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2045
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2046 ;; Begin fix part 1 by Ulrik Dickow <dickow@nbi.dk> 16-Feb-1996,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2047 ;; to make queue command usable. Easy but ugly code duplication again.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2048
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2049 (defun TeX-command-menu-queue (printer command name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2050 ;; Show queue for PRINTER using method COMMAND to run NAME.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2051 (let ((TeX-printer-default printer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2052 (TeX-printer-list nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2053 (TeX-queue-command command))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2054 (TeX-command-menu name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2055
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2056 (defun TeX-command-menu-queue-entry (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2057 ;; Return TeX-printer-list ENTRY as a menu item.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2058 (vector (nth 0 entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2059 (list 'TeX-command-menu-queue
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2060 (nth 0 entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2061 (or (nth lookup entry) command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2062 name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2063 t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2064
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2065 ;; End fix part 1.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2066
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2067 (defun TeX-command-menu-entry (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2068 ;; Return TeX-command-list ENTRY as a menu item.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2069 (let ((name (car entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2070 (cond ((and (string-equal name TeX-command-Print)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2071 TeX-printer-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2072 (let ((command TeX-print-command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2073 (lookup 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2074 (append (list TeX-command-Print)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2075 (mapcar 'TeX-command-menu-printer-entry
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2076 TeX-printer-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2077 ((and (string-equal name TeX-command-Queue)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2078 TeX-printer-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2079 (let ((command TeX-queue-command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2080 (lookup 2))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2081 (append (list TeX-command-Queue)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2082 (mapcar 'TeX-command-menu-queue-entry ; dickow fix part 2.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2083 TeX-printer-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2084 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2085 (vector name (list 'TeX-command-menu name) t)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2086
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2087 ;;; Keymap
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2088
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2089 (defvar TeX-electric-escape nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2090 "If this is non-nil when AUC TeX is loaded, the TeX escape
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2091 character ``\\'' will be bound to `TeX-electric-macro'.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2092
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2093 (defvar TeX-mode-map nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2094 "Keymap for common TeX and LaTeX commands.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2095
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2096 (if TeX-mode-map
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2097 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2098 (setq TeX-mode-map (make-sparse-keymap))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2099
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2100 ;; Standard
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2101 ;; (define-key TeX-mode-map "\177" 'backward-delete-char-untabify)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2102 (define-key TeX-mode-map "\C-c}" 'up-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2103 (define-key TeX-mode-map "\C-c#" 'TeX-normal-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2104 (define-key TeX-mode-map "\C-c\C-n" 'TeX-normal-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2105 (define-key TeX-mode-map "\C-c?" 'describe-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2106 (define-key TeX-mode-map "\C-c\C-i" 'TeX-goto-info-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2107
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2108 ;; From tex.el
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2109 (define-key TeX-mode-map "\"" 'TeX-insert-quote)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2110 (define-key TeX-mode-map "$" 'TeX-insert-dollar)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2111 (define-key TeX-mode-map "." 'TeX-insert-punctuation)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2112 (define-key TeX-mode-map "," 'TeX-insert-punctuation)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2113 (define-key TeX-mode-map "\C-c{" 'TeX-insert-braces)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2114 (define-key TeX-mode-map "\C-c\C-f" 'TeX-font)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2115 (define-key TeX-mode-map "\C-c\C-m" 'TeX-insert-macro)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2116 (if TeX-electric-escape
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2117 (define-key TeX-mode-map "\\" 'TeX-electric-macro))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2118 (define-key TeX-mode-map "\e\t" 'TeX-complete-symbol) ;*** Emacs 19 way
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2119
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2120 (define-key TeX-mode-map "\C-c;" 'TeX-comment-region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2121 (define-key TeX-mode-map "\C-c%" 'TeX-comment-paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2122
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2123 (define-key TeX-mode-map "\C-c'" 'TeX-comment-paragraph) ;*** Old way
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2124 (define-key TeX-mode-map "\C-c:" 'TeX-un-comment-region) ;*** Old way
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2125 (define-key TeX-mode-map "\C-c\"" 'TeX-un-comment) ;*** Old way
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2126
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2127 ;; From tex-buf.el
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2128 (define-key TeX-mode-map "\C-c\C-d" 'TeX-save-document)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2129 (define-key TeX-mode-map "\C-c\C-r" 'TeX-command-region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2130 (define-key TeX-mode-map "\C-c\C-b" 'TeX-command-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2131 (define-key TeX-mode-map "\C-c\C-c" 'TeX-command-master)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2132 (define-key TeX-mode-map "\C-c\C-k" 'TeX-kill-job)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2133 (define-key TeX-mode-map "\C-c\C-l" 'TeX-recenter-output-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2134 (define-key TeX-mode-map "\C-c^" 'TeX-home-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2135 (define-key TeX-mode-map "\C-c`" 'TeX-next-error)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2136 (define-key TeX-mode-map "\C-c\C-w" 'TeX-toggle-debug-boxes))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2137
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2138 (easy-menu-define TeX-mode-menu
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2139 TeX-mode-map
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2140 "Menu used in TeX mode."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2141 (append '("Command")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2142 '(("Command on"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2143 [ "Master File" TeX-command-select-master
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2144 :keys "C-c C-c" :style radio
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2145 :selected (eq TeX-command-current 'TeX-command-master) ]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2146 [ "Buffer" TeX-command-select-buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2147 :keys "C-c C-b" :style radio
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2148 :selected (eq TeX-command-current 'TeX-command-buffer) ]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2149 [ "Region" TeX-command-select-region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2150 :keys "C-c C-r" :style radio
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2151 :selected (eq TeX-command-current 'TeX-command-region) ]))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2152 (let ((file 'TeX-command-on-current))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2153 (mapcar 'TeX-command-menu-entry TeX-command-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2154
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2155 (defvar plain-TeX-mode-map (copy-keymap TeX-mode-map)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2156 "Keymap used in plain TeX mode.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2157
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2158 (easy-menu-define plain-TeX-mode-menu
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2159 plain-TeX-mode-map
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2160 "Menu used in plain TeX mode."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2161 (list "TeX"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2162 ["Macro..." TeX-insert-macro t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2163 ["Complete" TeX-complete-symbol t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2164 ["Save Document" TeX-save-document t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2165 ["Next Error" TeX-next-error t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2166 ["Kill Job" TeX-kill-job t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2167 ["Debug Bad Boxes" TeX-toggle-debug-boxes
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2168 :style toggle :selected TeX-debug-bad-boxes ]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2169 ["Switch to Original File" TeX-home-buffer t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2170 ["Recenter Output Buffer" TeX-recenter-output-buffer t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2171 ;; ["Uncomment" TeX-un-comment t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2172 ["Uncomment Region" TeX-un-comment-region t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2173 ;; ["Comment Paragraph" TeX-comment-paragraph t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2174 ["Comment Region" TeX-comment-region t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2175 ["Switch to Master file" TeX-home-buffer t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2176 ["Documentation" TeX-goto-info-page t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2177 ["Submit bug report" TeX-submit-bug-report t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2178 ["Reset Buffer" TeX-normal-mode t]
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2179 ["Reset AUC TeX" (TeX-normal-mode t) :keys "C-u C-c C-n"]))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2180
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2181 ;;; Comments
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2182
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2183 (defun TeX-un-comment-region (start end level)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2184 "Remove up to LEVEL comment characters from each line in the region."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2185 (interactive "*r\np")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2186 (comment-region start end (- level)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2187
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2188 (defun TeX-un-comment (level)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2189 "Delete up to LEVEL %'s from the beginning of each line in a comment."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2190 (interactive "*p")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2191 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2192 ; Find first comment line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2193 (re-search-backward (concat "^[^" comment-start "]") nil 'limit)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2194 (let ((beg (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2195 (forward-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2196 ; Find last comment line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2197 (re-search-forward (concat "^[^" comment-start "]") nil 'limit)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2198 ; Uncomment region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2199 (comment-region beg (point) (- level)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2200
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2201 (fset 'TeX-comment-region 'comment-region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2202
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2203 (defun TeX-comment-paragraph (level)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2204 "Inserts LEVEL %'s at the beginning of every line in the current paragraph."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2205 (interactive "*p")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2206 (if (< level 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2207 (TeX-un-comment (- level))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2208 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2209 (mark-paragraph)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2210 (comment-region (point) (mark) level))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2211
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2212 (defun TeX-in-comment ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2213 ;; Return non-nil if point is in a comment.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2214 (if (or (bolp)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2215 (null comment-start-skip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2216 (eq (preceding-char) ?\r))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2217 nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2218 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2219 (let ((pos (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2220 (re-search-backward "^\\|\r" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2221 (or (looking-at comment-start-skip)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2222 (re-search-forward comment-start-skip pos t))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2223
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2224 ;;; Indentation
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2225
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2226 (defun TeX-brace-count-line ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2227 "Count number of open/closed braces."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2228 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2229 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2230 (let ((count 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2231 (narrow-to-region (point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2232 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2233 (re-search-forward "[^\\\\]%\\|\n\\|\\'")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2234 (backward-char)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2235 (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2236
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2237 (while (re-search-forward "\\({\\|}\\|\\\\.\\)" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2238 (cond
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2239 ((string= "{" (TeX-match-buffer 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2240 (setq count (+ count TeX-brace-indent-level)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2241 ((string= "}" (TeX-match-buffer 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2242 (setq count (- count TeX-brace-indent-level)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2243 count))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2244
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2245 (defvar TeX-brace-indent-level 2
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2246 "*The level of indentation produced by a open brace.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2247
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2248 (defun TeX-comment-indent ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2249 (if (looking-at "%%%")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2250 (current-column)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2251 (skip-chars-backward " \t")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2252 (max (if (bolp) 0 (1+ (current-column)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2253 comment-column)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2254
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2255 ;;; Fonts
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2256
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2257 (defvar TeX-font-list '((?\C-b "{\\bf " "}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2258 (?\C-c "{\\sc " "}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2259 (?\C-e "{\\em " "\\/}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2260 (?\C-i "{\\it " "\\/}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2261 (?\C-r "{\\rm " "}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2262 (?\C-s "{\\sl " "\\/}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2263 (?\C-t "{\\tt " "}")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2264 (?\C-d "" "" t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2265 "*List of fonts used by TeX-font.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2266
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2267 Each entry is a list with three elements. The first element is the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2268 key to active the font. The second element is the string to insert
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2269 before point, and the third element is the string to insert after
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2270 point. An optional fourth element means always replace if not nil.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2271
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2272 (defvar TeX-font-replace-function 'TeX-font-replace
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2273 "Determines the function which is called when a font should be replaced.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2274
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2275 (defun TeX-describe-font-entry (entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2276 ;; A textual description of an ENTRY in TeX-font-list.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2277 (concat (format "%8s\t" (key-description (char-to-string (nth 0 entry))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2278 (if (nth 3 entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2279 "-- delete font"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2280 (format "%10s %s" (nth 1 entry) (nth 2 entry)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2281
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2282 (defun TeX-font (replace what)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2283 "Insert template for font change command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2284 If REPLACE is not nil, replace current font. WHAT determines the font
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2285 to use, as specified by TeX-font-list."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2286 (interactive "*P\nc")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2287 (TeX-update-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2288 (let* ((entry (assoc what TeX-font-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2289 (setq replace (or replace (nth 3 entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2290 (cond ((null entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2291 (let ((help (concat "Font list:\n\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2292 (mapconcat 'TeX-describe-font-entry
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2293 TeX-font-list "\n"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2294 (with-output-to-temp-buffer "*Help*"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2295 (set-buffer "*Help*")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2296 (insert help))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2297 (replace
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2298 (funcall TeX-font-replace-function (nth 1 entry) (nth 2 entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2299 ((TeX-active-mark)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2300 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2301 (cond ((> (mark) (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2302 (insert (nth 1 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2303 (goto-char (mark))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2304 (insert (nth 2 entry)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2305 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2306 (insert (nth 2 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2307 (goto-char (mark))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2308 (insert (nth 1 entry))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2309 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2310 (insert (nth 1 entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2311 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2312 (insert (nth 2 entry)))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2313 (defun TeX-font-replace (start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2314 "Replace font specification around point with START and END."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2315 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2316 (while (not (looking-at "{\\\\[a-zA-Z]+ "))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2317 (up-list -1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2318 (forward-sexp)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2319 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2320 (replace-match start t t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2321 (if (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2322 (backward-char 3)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2323 (if (looking-at (regexp-quote "\\/}"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2324 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2325 (delete-char 3)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2326 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2327 t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2328 (delete-backward-char 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2329 (insert end)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2330
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2331 ;;; Dollars
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2332 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2333 ;; Originally stolen from VorTeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2334 ;; Copyright (C) 1986, 1987, 1988 Pehong Chen (phc@renoir.berkeley.edu)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2335
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2336 (defvar TeX-dollar-sign ?$
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2337 "*Character user to enter and leaver math mode in TeX.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2338
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2339 (defconst TeX-dollar-string (char-to-string TeX-dollar-sign))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2340
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2341 (defconst TeX-dollar-regexp
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2342 (concat "^" (regexp-quote TeX-dollar-string) "\\|[^" TeX-esc "]"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2343 (regexp-quote TeX-dollar-string)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2344
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2345 (defvar TeX-dollar-list nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2346 (make-variable-buffer-local 'TeX-match-dollar-on)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2347
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2348 (defvar TeX-par-start nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2349 (make-variable-buffer-local 'TeX-par-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2350
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2351 (defvar TeX-par-end nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2352 (make-variable-buffer-local 'TeX-par-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2353
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2354 (defvar TeX-symbol-marker nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2355
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2356 (defvar TeX-symbol-marker-pos 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2357
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2358 (defun TeX-bouncing-point (m)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2359 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2360 (if (pos-visible-in-window-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2361 (sit-for 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2362 (let* ((pos1 (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2363 (pos2 (+ pos1 m))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2364 (sym (buffer-substring pos1 pos2))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2365 (msg1 (progn (beginning-of-line) (buffer-substring (point) pos1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2366 (msg2 (progn (end-of-line) (buffer-substring pos2 (point)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2367 (message "%s`%s'%s" msg1 sym msg2)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2368
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2369 (defun TeX-locate-delimiter (pos sym symlst)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2370 (let ((marker nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2371 (marker-pos 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2372 (pair t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2373 (head nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2374 (catch 'loop
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2375 (while symlst
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2376 (setq marker (car symlst))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2377 (setq marker-pos (1- (marker-position marker)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2378 (if (and (/= pos marker-pos) (= (char-after marker-pos) sym))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2379 (if (> pos marker-pos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2380 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2381 (setq TeX-symbol-marker-pos marker-pos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2382 (setq TeX-symbol-marker marker)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2383 (setq head (cons marker head))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2384 (setq pair (not pair)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2385 (if pair (setq TeX-symbol-marker nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2386 (throw 'loop (append (reverse head)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2387 (cons (set-marker (make-marker) (1+ pos))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2388 symlst)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2389 (setq symlst (cdr symlst)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2390 (if pair (setq TeX-symbol-marker nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2391 (reverse (cons (set-marker (make-marker) (1+ pos)) head)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2392
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2393 (defun TeX-dollar-verify ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2394 ;; Verify if the current paragraph is the same as last.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2395 ;; If so, do nothing, otherwise reset TeX-par-start and TeX-par-end and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2396 ;; reconstruct the symbol-list.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2397 (let ((start (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2398 (if (re-search-backward paragraph-separate nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2399 (point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2400 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2401 (end (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2402 (if (re-search-forward paragraph-separate nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2403 (1+ (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2404 (1+ (point-max)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2405 (init nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2406 (if (null TeX-par-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2407 (setq TeX-par-start (set-marker (make-marker) 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2408 (if (/= (marker-position TeX-par-start) start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2409 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2410 (set-marker TeX-par-start start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2411 (setq init t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2412 (if (null TeX-par-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2413 (setq TeX-par-end (set-marker (make-marker) 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2414 (if (/= (marker-position TeX-par-end) end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2415 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2416 (set-marker TeX-par-end end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2417 (setq init t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2418 (if init
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2419 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2420 (setq TeX-dollar-list nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2421 (goto-char start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2422 (while (re-search-forward TeX-dollar-regexp end t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2423 (setq TeX-dollar-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2424 (append TeX-dollar-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2425 (list (set-marker (make-marker)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2426 (if (= (following-char)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2427 TeX-dollar-sign)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2428 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2429 (forward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2430 (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2431 (point)))))))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2432
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2433 (defun TeX-insert-dollar (&optional arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2434 "Insert dollar sign.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2435
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2436 Show matching dollar sign if this dollar sign end the TeX math mode.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2437 Ensure double dollar signs match up correctly by inserting extra
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2438 dollar signs when needed.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2439
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2440 With optional ARG, insert that many dollar signs."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2441 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2442 (if arg
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2443 (let ((count (prefix-numeric-value arg)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2444 (if (listp arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2445 (self-insert-command 1) ;C-u always inserts just one
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2446 (self-insert-command count)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2447 (let ((pc (preceding-char))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2448 (pos (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2449 (pt (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2450 (single t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2451 (TeX-dollar-verify)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2452 (if (= pc (string-to-char TeX-esc))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2453 (insert TeX-dollar-sign)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2454 (if (and (= pc TeX-dollar-sign)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2455 (/= (char-after (- (point) 2)) (string-to-char TeX-esc)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2456 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2457 (setq single nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2458 (if (and (> pos 2) (= (char-after (- pos 2)) TeX-dollar-sign))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2459 (setq pt (1- pos)) ; Doesn't echo 3rd $, if $$ already
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2460 (backward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2461 (insert TeX-dollar-sign)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2462 (goto-char (1+ pos))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2463 (insert TeX-dollar-sign))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2464 (setq TeX-dollar-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2465 (TeX-locate-delimiter pt TeX-dollar-sign TeX-dollar-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2466 (if TeX-symbol-marker
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2467 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2468 (goto-char TeX-symbol-marker-pos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2469 (if (and (= (preceding-char) TeX-dollar-sign)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2470 (/= (char-after (- (point) 2)) TeX-dollar-sign))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2471 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2472 (backward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2473 (if single
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2474 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2475 (goto-char pos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2476 (insert TeX-dollar-sign)))) ; $$foo$`$'
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2477 (if (not single)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2478 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2479 (insert TeX-dollar-sign) ; `$'$foo$$
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2480 (backward-char 1))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2481 (TeX-bouncing-point (if single 1 2))))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2482
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2483 ;;; Simple Commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2484
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2485 (defun TeX-normal-mode (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2486 "Remove all information about this buffer, and apply the style hooks again.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2487 Save buffer first including style information.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2488 With optional argument, also reload the style hooks."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2489 (interactive "*P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2490 (if arg
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2491 (setq TeX-style-hook-list nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2492 BibTeX-global-style-files nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2493 BibTeX-global-files nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2494 TeX-global-input-files nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2495 (let ((TeX-auto-save t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2496 (if (buffer-modified-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2497 (save-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2498 (TeX-auto-write)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2499 (normal-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2500 (TeX-update-style))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2501
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2502 (defvar TeX-open-quote "``"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2503 "*String inserted by typing \\[TeX-insert-quote] to open a quotation.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2504
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2505 (defvar TeX-close-quote "''"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2506 "*String inserted by typing \\[TeX-insert-quote] to close a quotation.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2507
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2508 (defvar TeX-quote-after-quote nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2509 "*Behaviour of \\[TeX-insert-quote]. Nil means standard behaviour;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2510 when non-nil, opening and closing quotes are inserted only after \".")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2511
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2512 ;;;###autoload
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2513 (defun TeX-insert-quote (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2514 "Insert the appropriate quote marks for TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2515 Inserts the value of `TeX-open-quote' (normally ``) or `TeX-close-quote'
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2516 \(normally '') depending on the context. If `TeX-quote-after-quote'
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2517 is non-nil, this insertion works only after \".
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2518 With prefix argument, always inserts \" characters."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2519 (interactive "*P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2520 (if arg
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2521 (self-insert-command (prefix-numeric-value arg))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2522 (TeX-update-style)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2523 (if TeX-quote-after-quote
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2524 (insert (cond ((bobp)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2525 ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2526 ((not (= (preceding-char) ?\"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2527 ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2528 ((save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2529 (forward-char -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2530 (bobp))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2531 (delete-backward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2532 TeX-open-quote)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2533 ((save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2534 (forward-char -2) ;;; at -1 there is double quote
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2535 (looking-at "[ \t\n]\\|\\s("))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2536 (delete-backward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2537 TeX-open-quote)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2538 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2539 (delete-backward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2540 TeX-close-quote)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2541 (insert (cond ((bobp)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2542 TeX-open-quote)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2543 ((= (preceding-char) (string-to-char TeX-esc))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2544 ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2545 ((= (preceding-char) ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2546 ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2547 ((save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2548 (forward-char (- (length TeX-open-quote)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2549 (looking-at (regexp-quote TeX-open-quote)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2550 (delete-backward-char (length TeX-open-quote))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2551 ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2552 ((save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2553 (forward-char (- (length TeX-close-quote)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2554 (looking-at (regexp-quote TeX-close-quote)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2555 (delete-backward-char (length TeX-close-quote))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2556 ?\")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2557 ((save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2558 (forward-char -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2559 (looking-at "[ \t\n]\\|\\s("))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2560 TeX-open-quote)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2561 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2562 TeX-close-quote))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2563
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2564 ;; For the sake of BibTeX...
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2565 ;;; Do not ;;;###autoload because of conflict with standard tex-mode.el.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2566 (fset 'tex-insert-quote 'TeX-insert-quote)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2567
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2568 (defun TeX-insert-punctuation ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2569 "Insert point or comma, cleaning up preceding space."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2570 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2571 (if (TeX-looking-at-backward "\\\\/\\(}+\\)" 50)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2572 (replace-match "\\1" t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2573 (call-interactively 'self-insert-command))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2574
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2575 (defun TeX-insert-braces (arg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2576 "Make a pair of braces around next ARG sexps and leave point inside.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2577 No argument is equivalent to zero: just insert braces and leave point
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2578 between."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2579 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2580 (insert TeX-grop)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2581 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2582 (if arg (forward-sexp (prefix-numeric-value arg)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2583 (insert TeX-grcl)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2584
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2585 (defun TeX-goto-info-page ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2586 "Read documentation for AUC TeX in the info system."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2587 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2588 (require 'info)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2589 (Info-goto-node "(auctex)"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2590
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2591 ;;;###autoload
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2592 (defun TeX-submit-bug-report ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2593 "Submit via mail a bug report on AUC TeX"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2594 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2595 (require 'reporter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2596 (reporter-submit-bug-report
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2597 "auc-tex@iesd.auc.dk"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2598 (concat "AUC TeX " AUC-TeX-version)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2599 (list 'window-system
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2600 'LaTeX-version
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2601 'TeX-style-path
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2602 'TeX-auto-save
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2603 'TeX-parse-self
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2604 'TeX-master)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2605 nil nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2606 "Remember to cover the basics, that is, what you expected to happen and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2607 what in fact did happen."))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2608
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2609 ;;; Ispell Support
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2610
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2611 ;; The FSF ispell.el use this.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2612 (defun ispell-tex-buffer-p ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2613 (and (boundp 'ispell-tex-p) ispell-tex-p))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2614
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2615 ;; The FSF ispell.el might one day use this.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2616 (setq ispell-enable-tex-parser t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2617
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2618 (defun TeX-run-ispell (command string file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2619 "Run ispell on current TeX buffer."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2620 (cond ((and (string-equal file (TeX-region-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2621 (fboundp 'ispell-region))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2622 (call-interactively 'ispell-region))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2623 ((string-equal file (TeX-region-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2624 (call-interactively 'spell-region))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2625 ((fboundp 'ispell-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2626 (ispell-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2627 ((fboundp 'ispell)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2628 (ispell))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2629 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2630 (spell-buffer))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2631
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2632 ;; Some versions of ispell 3 use this.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2633 (defvar ispell-tex-major-modes nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2634 (setq ispell-tex-major-modes
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2635 (append '(plain-tex-mode ams-tex-mode latex-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2636 ispell-tex-major-modes))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2637
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2638 (provide 'tex)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2639
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2640 ;;; tex.el ends here