24
|
1 ;;; latex.el --- Support for LaTeX documents.
|
|
2 ;;
|
|
3 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk>
|
|
4 ;; Version: 9.7i
|
|
5 ;; Keywords: wp
|
|
6 ;; X-URL: http://sunsite.auc.dk/auctex
|
|
7
|
|
8 ;; Copyright 1991 Kresten Krab Thorup
|
|
9 ;; Copyright 1993, 1994, 1995, 1996, 1997 Per Abrahamsen
|
|
10 ;;
|
|
11 ;; This program is free software; you can redistribute it and/or modify
|
|
12 ;; it under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 1, or (at your option)
|
|
14 ;; any later version.
|
|
15 ;;
|
|
16 ;; This program is distributed in the hope that it will be useful,
|
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 ;; GNU General Public License for more details.
|
|
20 ;;
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with this program; if not, write to the Free Software
|
|
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
24
|
|
25 ;;; Code:
|
|
26
|
|
27 (require 'tex)
|
|
28
|
|
29 ;;; Syntax
|
|
30
|
|
31 (defvar LaTeX-optop "["
|
|
32 "The LaTeX optional argument opening character.")
|
|
33 (make-variable-buffer-local 'LaTeX-optop)
|
|
34
|
|
35 (defvar LaTeX-optcl "]"
|
|
36 "The LaTeX optional argument closeing character.")
|
|
37 (make-variable-buffer-local 'LaTeX-optcl)
|
|
38
|
|
39 ;;; Style
|
|
40
|
|
41 (defvar LaTeX-default-style "article"
|
|
42 "*Default when creating new documents.")
|
|
43
|
|
44 (make-variable-buffer-local 'LaTeX-default-style)
|
|
45
|
|
46 (defvar LaTeX-default-options nil
|
|
47 "*Default options to documentstyle.
|
|
48 A list of strings.")
|
|
49
|
|
50 (make-variable-buffer-local 'LaTeX-default-options)
|
|
51
|
|
52 ;;; Syntax Table
|
|
53
|
|
54 (defvar LaTeX-mode-syntax-table (copy-syntax-table TeX-mode-syntax-table)
|
|
55 "Syntax table used in LaTeX mode.")
|
|
56
|
|
57 (progn ; set [] to match for LaTeX.
|
|
58 (modify-syntax-entry (string-to-char LaTeX-optop)
|
|
59 (concat "(" LaTeX-optcl)
|
|
60 LaTeX-mode-syntax-table)
|
|
61 (modify-syntax-entry (string-to-char LaTeX-optcl)
|
|
62 (concat ")" LaTeX-optop)
|
|
63 LaTeX-mode-syntax-table))
|
|
64
|
|
65 ;;; Sections
|
|
66
|
|
67 (defun LaTeX-section (arg)
|
|
68 "Insert a template for a LaTeX section.
|
|
69 Determinate the type of section to be inserted, by the argument ARG.
|
|
70
|
|
71 If ARG is nil or missing, use the current level.
|
|
72 If ARG is a list (selected by C-u), go downward one level.
|
|
73 If ARG is negative, go up that many levels.
|
|
74 If ARG is positive or zero, use absolute level:
|
|
75
|
|
76 0 : part
|
|
77 1 : chapter
|
|
78 2 : section
|
|
79 3 : subsection
|
|
80 4 : subsubsection
|
|
81 5 : paragraph
|
|
82 6 : subparagraph
|
|
83
|
|
84 The following variables can be set to customize:
|
|
85
|
|
86 LaTeX-section-hook Hooks to run when inserting a section.
|
|
87 LaTeX-section-label Prefix to all section labels."
|
|
88
|
|
89 (interactive "*P")
|
|
90 (let* ((val (prefix-numeric-value arg))
|
|
91 (level (cond ((null arg)
|
|
92 (LaTeX-current-section))
|
|
93 ((listp arg)
|
|
94 (LaTeX-down-section))
|
|
95 ((< val 0)
|
|
96 (LaTeX-up-section (- val)))
|
|
97 (t val)))
|
|
98 (name (LaTeX-section-name level))
|
|
99 (toc nil)
|
|
100 (title "")
|
|
101 (done-mark (make-marker)))
|
|
102 (newline)
|
|
103 (run-hooks 'LaTeX-section-hook)
|
|
104 (newline)
|
|
105 (if (marker-position done-mark)
|
|
106 (goto-char (marker-position done-mark)))
|
|
107 (set-marker done-mark nil)))
|
|
108
|
|
109 (defun LaTeX-current-section ()
|
|
110 "Return the level of the section that contain point.
|
|
111 See also LaTeX-section for description of levels."
|
|
112 (save-excursion
|
|
113 (max (LaTeX-largest-level)
|
|
114 (if (re-search-backward (LaTeX-outline-regexp) nil t)
|
|
115 (- (LaTeX-outline-level) (LaTeX-outline-offset))
|
|
116 (LaTeX-largest-level)))))
|
|
117
|
|
118 (defun LaTeX-down-section ()
|
|
119 "Return the value of a section one level under the current. Tries to
|
|
120 find what kind of section that have been used earlier in the text, If
|
|
121 this fail, it will just return one less than the current section."
|
|
122 (save-excursion
|
|
123 (let ((current (LaTeX-current-section))
|
|
124 (next nil)
|
|
125 (regexp (LaTeX-outline-regexp)))
|
|
126 (if (not (re-search-backward regexp nil t))
|
|
127 (1+ current)
|
|
128 (while (not next)
|
|
129 (cond
|
|
130 ((eq (LaTeX-current-section) current)
|
|
131 (if (re-search-forward regexp nil t)
|
|
132 (if (<= (setq next (LaTeX-current-section)) current) ;Wow!
|
|
133 (setq next (1+ current)))
|
|
134 (setq next (1+ current))))
|
|
135 ((not (re-search-backward regexp nil t))
|
|
136 (setq next (1+ current)))))
|
|
137 next))))
|
|
138
|
|
139 (defun LaTeX-up-section (arg)
|
|
140 "Return the value of the section ARG levels above this one."
|
|
141 (save-excursion
|
|
142 (if (zerop arg)
|
|
143 (LaTeX-current-section)
|
|
144 (let ((current (LaTeX-current-section)))
|
|
145 (while (and (>= (LaTeX-current-section) current)
|
|
146 (re-search-backward (LaTeX-outline-regexp)
|
|
147 nil t)))
|
|
148 (LaTeX-up-section (1- arg))))))
|
|
149
|
|
150 (defvar LaTeX-section-list '(("part" 0)
|
|
151 ("chapter" 1)
|
|
152 ("section" 2)
|
|
153 ("subsection" 3)
|
|
154 ("subsubsection" 4)
|
|
155 ("paragraph" 5)
|
|
156 ("subparagraph" 6))
|
|
157 "List which elements is the names of the sections used by LaTeX.")
|
|
158
|
|
159 (defun LaTeX-section-name (level)
|
|
160 "Return the name of the section corresponding to LEVEL."
|
|
161 (let ((entry (TeX-member level LaTeX-section-list
|
|
162 (function (lambda (a b) (equal a (nth 1 b)))))))
|
|
163 (if entry
|
|
164 (nth 0 entry)
|
|
165 nil)))
|
|
166
|
|
167 (defun LaTeX-section-level (name)
|
|
168 "Return the level of the section NAME."
|
|
169 (let ((entry (TeX-member name LaTeX-section-list
|
|
170 (function (lambda (a b) (equal a (nth 0 b)))))))
|
|
171
|
|
172 (if entry
|
|
173 (nth 1 entry)
|
|
174 nil)))
|
|
175
|
|
176 (defvar TeX-outline-extra nil
|
|
177 "*List of extra TeX outline levels.
|
|
178
|
|
179 Each element is a list with two entries. The first entry is the
|
|
180 regular expression matching a header, and the second is the level of
|
|
181 the header. See LaTeX-section-list for existing header levels.")
|
|
182
|
|
183 (defun LaTeX-outline-regexp (&optional anywhere)
|
|
184 "Return regexp for LaTeX sections.
|
|
185
|
|
186 If optional argument ANYWHERE is not nil, do not require that the
|
|
187 header is at the start of a line."
|
|
188 (concat (if anywhere "" "^")
|
|
189 "[ \t]*"
|
|
190 (regexp-quote TeX-esc)
|
|
191 "\\(appendix\\|documentstyle\\|documentclass\\|"
|
|
192 (mapconcat 'car LaTeX-section-list "\\|")
|
|
193 "\\)\\b"
|
|
194 (if TeX-outline-extra
|
|
195 "\\|"
|
|
196 "")
|
|
197 (mapconcat 'car TeX-outline-extra "\\|")
|
|
198 "\\|" TeX-header-end
|
|
199 "\\|" TeX-trailer-start))
|
|
200
|
|
201 (defvar LaTeX-largest-level nil
|
|
202 "Largest sectioning level with current document style")
|
|
203
|
|
204 (make-variable-buffer-local 'LaTeX-largest-level)
|
|
205
|
|
206 (defun LaTeX-largest-level ()
|
|
207 (TeX-update-style)
|
|
208 LaTeX-largest-level)
|
|
209
|
|
210 (defun LaTeX-outline-offset ()
|
|
211 "Offset to add to LaTeX-section-list levels to get outline level."
|
|
212 (- 2 (LaTeX-largest-level)))
|
|
213
|
|
214 (defun TeX-look-at (list)
|
|
215 "Check if we are looking at the first element of a member of LIST.
|
|
216 If so, return the second element, otherwise return nil."
|
|
217 (while (and list
|
|
218 (not (looking-at (nth 0 (car list)))))
|
|
219 (setq list (cdr list)))
|
|
220 (if list
|
|
221 (nth 1 (car list))
|
|
222 nil))
|
|
223
|
|
224 (defun LaTeX-outline-level ()
|
|
225 "Find the level of current outline heading in an LaTeX document."
|
|
226 (cond ((looking-at LaTeX-header-end) 1)
|
|
227 ((looking-at LaTeX-trailer-start) 1)
|
|
228 ((TeX-look-at TeX-outline-extra)
|
|
229 (max 1 (+ (TeX-look-at TeX-outline-extra)
|
|
230 (LaTeX-outline-offset))))
|
|
231 (t
|
|
232 (save-excursion
|
|
233 (skip-chars-forward " \t")
|
|
234 (forward-char 1)
|
|
235 (cond ((looking-at "appendix") 1)
|
|
236 ((looking-at "documentstyle") 1)
|
|
237 ((looking-at "documentclass") 1)
|
|
238 ((TeX-look-at LaTeX-section-list)
|
|
239 (max 1 (+ (TeX-look-at LaTeX-section-list)
|
|
240 (LaTeX-outline-offset))))
|
|
241 (t
|
|
242 (error "Unrecognized header")))))))
|
|
243
|
|
244 (add-hook 'TeX-remove-style-hook
|
|
245 (function (lambda () (setq LaTeX-largest-level nil))))
|
|
246
|
|
247 (defvar LaTeX-section-hook
|
|
248 '(LaTeX-section-heading
|
|
249 LaTeX-section-title
|
|
250 ;; LaTeX-section-toc ; Most people won't want this
|
|
251 LaTeX-section-section
|
|
252 LaTeX-section-label)
|
|
253 "*List of hooks to run when a new section is inserted.
|
|
254
|
|
255 The following variables are set before the hooks are run
|
|
256
|
|
257 level - numeric section level, see the documentation of `LaTeX-section'.
|
|
258 name - name of the sectioning command, derived from `level'.
|
|
259 title - The title of the section, default to an empty string.
|
|
260 toc - Entry for the table of contents list, default nil.
|
|
261 done-mark - Position of point afterwards, default nil (meaning end).
|
|
262
|
|
263 The following standard hook exist -
|
|
264
|
|
265 LaTeX-section-heading: Query the user about the name of the
|
|
266 sectioning command. Modifies `level' and `name'.
|
|
267
|
|
268 LaTeX-section-title: Query the user about the title of the
|
|
269 section. Modifies `title'.
|
|
270
|
|
271 LaTeX-section-toc: Query the user for the toc entry. Modifies
|
|
272 `toc'.
|
|
273
|
|
274 LaTeX-section-section: Insert LaTeX section command according to
|
|
275 `name', `title', and `toc'. If `toc' is nil, no toc entry is
|
|
276 enserted. If `toc' or `title' are empty strings, `done-mark' will be
|
|
277 placed at the point they should be inserted.
|
|
278
|
|
279 LaTeX-section-label: Insert a label after the section command.
|
|
280 Controled by the variable `LaTeX-section-label'.
|
|
281
|
|
282 To get a full featured LaTeX-section command, insert
|
|
283
|
|
284 (setq LaTeX-section-hook
|
|
285 '(LaTeX-section-heading
|
|
286 LaTeX-section-title
|
|
287 LaTeX-section-toc
|
|
288 LaTeX-section-section
|
|
289 LaTeX-section-label))
|
|
290
|
|
291 in your .emacs file.")
|
|
292
|
|
293 (defvar LaTeX-section-label
|
|
294 '(("chapter" . "cha:")
|
|
295 ("section" . "sec:")
|
|
296 ("subsection" . "sec:"))
|
|
297 "*Default prefix when asking for a label.
|
|
298
|
|
299 If it is a string, it it used unchanged for all kinds of sections.
|
|
300 If it is nil, no label is inserted.
|
|
301 If it is a list, the list is searched for a member whose car is equal
|
|
302 to the name of the sectioning command being inserted. The cdr is then
|
|
303 used as the prefix. If the name is not found, or if the cdr is nil,
|
|
304 no label is inserted.")
|
|
305
|
|
306 ;;; Section Hooks.
|
|
307
|
|
308 (defun LaTeX-section-heading ()
|
|
309 "Hook to prompt for LaTeX section name.
|
|
310 Insert this hook into LaTeX-section-hook to allow the user to change
|
|
311 the name of the sectioning command inserted with M-x LaTeX-section."
|
|
312 (let ((string (completing-read
|
|
313 (concat "Select level: (default " name ") ")
|
|
314 LaTeX-section-list
|
|
315 nil nil nil)))
|
|
316 ; Update name
|
|
317 (if (not (zerop (length string)))
|
|
318 (setq name string))
|
|
319 ; Update level
|
|
320 (setq level (LaTeX-section-level name))))
|
|
321
|
|
322 (defun LaTeX-section-title ()
|
|
323 "Hook to prompt for LaTeX section title.
|
|
324 Insert this hook into LaTeX-section-hook to allow the user to change
|
|
325 the title of the section inserted with M-x LaTeX-section."
|
|
326 (setq title (read-string "What title: ")))
|
|
327
|
|
328 (defun LaTeX-section-toc ()
|
|
329 "Hook to prompt for the LaTeX section entry in the table of content .
|
|
330 Insert this hook into LaTeX-section-hook to allow the user to insert
|
|
331 a different entry for the section in the table of content."
|
|
332 (setq toc (read-string "Toc Entry: "))
|
|
333 (if (zerop (length toc))
|
|
334 (setq toc nil)))
|
|
335
|
|
336 (defun LaTeX-section-section ()
|
|
337 "Hook to insert LaTeX section command into the file.
|
|
338 Insert this hook into LaTeX-section-hook after those hooks which sets
|
|
339 the `name', `title', and `toc' variables, but before those hooks which
|
|
340 assumes the section already is inserted."
|
|
341 (insert TeX-esc name)
|
|
342 (cond ((null toc))
|
|
343 ((zerop (length toc))
|
|
344 (insert LaTeX-optop)
|
|
345 (set-marker done-mark (point))
|
|
346 (insert LaTeX-optcl))
|
|
347 (t
|
|
348 (insert LaTeX-optop toc LaTeX-optcl)))
|
|
349 (insert TeX-grop)
|
|
350 (if (zerop (length title))
|
|
351 (set-marker done-mark (point)))
|
|
352 (insert title TeX-grcl)
|
|
353 (newline))
|
|
354
|
|
355 (defun LaTeX-section-label ()
|
|
356 "Hook to insert a label after the sectioning command.
|
|
357 Insert this hook into LaTeX-section-hook to prompt for a label to be
|
|
358 inserted after the sectioning command.
|
|
359
|
|
360 The beaviour of this hook is controled by LaTeX-section-label."
|
|
361 (and (LaTeX-label name)
|
|
362 (newline)))
|
|
363
|
|
364 ;;; Environments
|
|
365
|
|
366 (defvar LaTeX-default-environment "itemize"
|
|
367 "*The default environment when creating new ones with LaTeX-environment.")
|
|
368 (make-variable-buffer-local 'LaTeX-default-environment)
|
|
369
|
|
370 (defun LaTeX-environment (arg)
|
|
371 "Make LaTeX environment (\\begin{...}-\\end{...} pair).
|
|
372 With optional ARG, modify current environment.
|
|
373
|
|
374 It may be customized with the following variables:
|
|
375
|
|
376 LaTeX-default-environment Your favorite environment.
|
|
377 LaTeX-default-style Your favorite document style.
|
|
378 LaTeX-default-options Your favorite document style options.
|
|
379 LaTeX-float Where you want figures and tables to float.
|
|
380 LaTeX-table-label Your prefix to labels in tables.
|
|
381 LaTeX-figure-label Your prefix to labels in figures.
|
|
382 LaTeX-default-format Format for array and tabular.
|
|
383 LaTeX-default-position Position for array and tabular."
|
|
384
|
|
385 (interactive "*P")
|
|
386 (let ((environment (completing-read (concat "Environment type: (default "
|
|
387 (if (TeX-near-bobp)
|
|
388 "document"
|
|
389 LaTeX-default-environment)
|
|
390 ") ")
|
|
391 (LaTeX-environment-list))))
|
|
392 ;; Get default
|
|
393 (cond ((and (zerop (length environment))
|
|
394 (TeX-near-bobp))
|
|
395 (setq environment "document"))
|
|
396 ((zerop (length environment))
|
|
397 (setq environment LaTeX-default-environment))
|
|
398 (t
|
|
399 (setq LaTeX-default-environment environment)))
|
|
400
|
|
401 (let ((entry (assoc environment (LaTeX-environment-list))))
|
|
402 (if (null entry)
|
|
403 (LaTeX-add-environments (list environment)))
|
|
404
|
|
405 (if arg
|
|
406 (LaTeX-modify-environment environment)
|
|
407 (LaTeX-environment-menu environment)))))
|
|
408
|
|
409 (defun LaTeX-environment-menu (environment)
|
|
410 ;; Insert ENVIRONMENT around point or region.
|
|
411 (let ((entry (assoc environment (LaTeX-environment-list))))
|
|
412 (cond ((not (and entry (nth 1 entry)))
|
|
413 (LaTeX-insert-environment environment))
|
|
414 ((numberp (nth 1 entry))
|
|
415 (let ((count (nth 1 entry))
|
|
416 (args ""))
|
|
417 (while (> count 0)
|
|
418 (setq args (concat args TeX-grop TeX-grcl))
|
|
419 (setq count (- count 1)))
|
|
420 (LaTeX-insert-environment environment args)))
|
|
421 ((stringp (nth 1 entry))
|
|
422 (let ((prompts (cdr entry))
|
|
423 (args ""))
|
|
424 (while prompts
|
|
425 (setq args (concat args
|
|
426 TeX-grop
|
|
427 (read-from-minibuffer (concat (car prompts)
|
|
428 ": "))
|
|
429 TeX-grcl))
|
|
430 (setq prompts (cdr prompts)))
|
|
431 (LaTeX-insert-environment environment args)))
|
|
432 (t
|
|
433 (apply (nth 1 entry) environment (nthcdr 2 entry))))))
|
|
434
|
|
435 (defun LaTeX-close-environment ()
|
|
436 "Creates an \\end{...} to match the current environment."
|
|
437 (interactive "*")
|
|
438 (if (> (point)
|
|
439 (save-excursion
|
|
440 (beginning-of-line)
|
|
441 (skip-chars-forward " \t")
|
|
442 (point)))
|
|
443 (insert "\n"))
|
|
444 (insert "\\end{" (LaTeX-current-environment 1) "}")
|
|
445 (LaTeX-indent-line)
|
|
446 (if (not (looking-at "[ \t]*$"))
|
|
447 (insert "\n")
|
|
448 (let ((next-line-add-newlines t))
|
|
449 (next-line 1)
|
|
450 (beginning-of-line)))
|
|
451 (LaTeX-indent-line))
|
|
452
|
|
453 (autoload 'outline-flag-region "outline")
|
|
454
|
|
455 (defun LaTeX-hide-environment ()
|
|
456 "Hide current LaTeX environment using selective display."
|
|
457 (interactive)
|
|
458 (outline-flag-region (save-excursion (LaTeX-find-matching-begin) (point))
|
|
459 (save-excursion (LaTeX-find-matching-end) (point))
|
|
460 ?\r))
|
|
461
|
|
462 (defun LaTeX-show-environment ()
|
|
463 "Show current LaTeX environment."
|
|
464 (interactive)
|
|
465 (outline-flag-region (save-excursion (LaTeX-find-matching-begin) (point))
|
|
466 (save-excursion (LaTeX-find-matching-end) (point))
|
|
467 ?\n))
|
|
468
|
|
469 (defun LaTeX-insert-environment (environment &optional extra)
|
|
470 "Insert environment of type ENV, with optional argument EXTRA."
|
|
471 (if (and (TeX-active-mark)
|
|
472 (not (eq (mark) (point))))
|
|
473 (progn
|
|
474 (if (< (mark) (point))
|
|
475 (exchange-point-and-mark))
|
|
476 (or (TeX-looking-at-backward "^[ \t]*")
|
|
477 (newline))
|
|
478 (insert TeX-esc "begin" TeX-grop environment TeX-grcl)
|
|
479 (LaTeX-indent-line)
|
|
480 (if extra (insert extra))
|
|
481 (newline)
|
|
482 (goto-char (mark))
|
|
483 (or (TeX-looking-at-backward "^[ \t]*")
|
|
484 (newline))
|
|
485 (insert TeX-esc "end" TeX-grop environment TeX-grcl)
|
|
486 (or (looking-at "[ \t]*$")
|
|
487 (save-excursion (newline-and-indent)))
|
|
488 (LaTeX-indent-line)
|
|
489 (end-of-line 0)
|
|
490 (or (assoc environment LaTeX-indent-environment-list)
|
|
491 (LaTeX-fill-environment nil)))
|
|
492 (or (TeX-looking-at-backward "^[ \t]*")
|
|
493 (newline))
|
|
494 (insert TeX-esc "begin" TeX-grop environment TeX-grcl)
|
|
495 (LaTeX-indent-line)
|
|
496 (if extra (insert extra))
|
|
497 (newline-and-indent)
|
|
498 (newline)
|
|
499 (insert TeX-esc "end" TeX-grop environment TeX-grcl)
|
|
500 (or (looking-at "[ \t]*$")
|
|
501 (save-excursion (newline-and-indent)))
|
|
502 (LaTeX-indent-line)
|
|
503 (end-of-line 0)))
|
|
504
|
|
505 (defun LaTeX-modify-environment (environment)
|
|
506 ;; Modify current environment.
|
|
507 (save-excursion
|
|
508 (LaTeX-find-matching-end)
|
|
509 (re-search-backward (concat (regexp-quote TeX-esc)
|
|
510 "end"
|
|
511 (regexp-quote TeX-grop)
|
|
512 " *\\([a-zA-Z*]*\\)"
|
|
513 (regexp-quote TeX-grcl))
|
|
514 (save-excursion (beginning-of-line 1) (point)))
|
|
515 (replace-match (concat TeX-esc "end" TeX-grop environment TeX-grcl) t t)
|
|
516 (beginning-of-line 1)
|
|
517 (LaTeX-find-matching-begin)
|
|
518 (re-search-forward (concat (regexp-quote TeX-esc)
|
|
519 "begin"
|
|
520 (regexp-quote TeX-grop)
|
|
521 " *\\([a-zA-Z*]*\\)"
|
|
522 (regexp-quote TeX-grcl))
|
|
523 (save-excursion (end-of-line 1) (point)))
|
|
524 (replace-match (concat TeX-esc "begin" TeX-grop environment TeX-grcl) t t)))
|
|
525
|
|
526 (defun LaTeX-current-environment (&optional arg)
|
|
527 "Return the name (a string) of the enclosing LaTeX environment.
|
|
528 With optional ARG>=1, find that outer level."
|
|
529 (setq arg (if arg (if (< arg 1) 1 arg) 1))
|
|
530 (save-excursion
|
|
531 (while (and
|
|
532 (/= arg 0)
|
|
533 (re-search-backward
|
|
534 (concat (regexp-quote TeX-esc) "begin" (regexp-quote TeX-grop)
|
|
535 "\\|"
|
|
536 (regexp-quote TeX-esc) "end" (regexp-quote TeX-grop))
|
|
537 nil t 1))
|
|
538 (cond ((TeX-in-comment)
|
|
539 (beginning-of-line 1))
|
|
540 ((looking-at (concat (regexp-quote TeX-esc)
|
|
541 "end" (regexp-quote TeX-grop)))
|
|
542 (setq arg (1+ arg)))
|
|
543 (t
|
|
544 (setq arg (1- arg)))))
|
|
545 (if (/= arg 0)
|
|
546 "document"
|
|
547 (search-forward TeX-grop)
|
|
548 (let ((beg (point)))
|
|
549 (search-forward TeX-grcl)
|
|
550 (backward-char 1)
|
|
551 (buffer-substring beg (point))))))
|
|
552
|
|
553 (defun TeX-near-bobp ()
|
|
554 ;; Return t iff there's nothing but whitespace between (bob) and (point).
|
|
555 (save-excursion
|
|
556 (skip-chars-backward " \t\n")
|
|
557 (bobp)))
|
|
558
|
|
559 ;;; Environment Hooks
|
|
560
|
|
561 (defvar LaTeX-document-style-hook nil
|
|
562 "List of hooks to run when inserting a document style environment.
|
|
563
|
|
564 To insert a hook here, you must insert it in the appropiate style file.")
|
|
565
|
|
566 (defun LaTeX-env-document (&optional ignore)
|
|
567 "Create new LaTeX document."
|
|
568
|
|
569 (TeX-insert-macro (if (string-equal LaTeX-version "2")
|
|
570 "documentstyle"
|
|
571 "documentclass"))
|
|
572
|
|
573 (newline 3)
|
|
574 (end-of-line 0)
|
|
575 (LaTeX-insert-environment "document")
|
|
576 (run-hooks 'LaTeX-document-style-hook)
|
|
577 (setq LaTeX-document-style-hook nil))
|
|
578
|
|
579 (defvar LaTeX-float "htbp"
|
|
580 "*Default float when creating figure and table environments.
|
|
581 Set to nil if you don't want any float.")
|
|
582 (make-variable-buffer-local 'LaTeX-float)
|
|
583
|
|
584 (defvar LaTeX-label-function nil
|
|
585 "*A function inserting a label at point.
|
|
586 Sole argument of the function is the environment. The function has to return
|
|
587 the label inserted, or nil if no label was inserted.")
|
|
588
|
|
589 (defvar LaTeX-figure-label "fig:"
|
|
590 "*Default prefix to figure labels.")
|
|
591 (make-variable-buffer-local 'LaTeX-figure-label)
|
|
592
|
|
593 (defvar LaTeX-table-label "tab:"
|
|
594 "*Default prefix to table labels.")
|
|
595 (make-variable-buffer-local 'LaTeX-table-label)
|
|
596
|
|
597 (defvar LaTeX-default-format ""
|
|
598 "Specifies the default format string for array and tabular environments.")
|
|
599 (make-variable-buffer-local 'LaTeX-default-format)
|
|
600
|
|
601 (defvar LaTeX-default-position ""
|
|
602 "Specifies the default position string for array and tabular environments.")
|
|
603 (make-variable-buffer-local 'LaTeX-default-position)
|
|
604
|
|
605 (defun LaTeX-env-item (environment)
|
|
606 "Insert ENVIRONMENT and the first item."
|
|
607 (LaTeX-insert-environment environment)
|
|
608 (if (TeX-active-mark)
|
|
609 (progn
|
|
610 (LaTeX-find-matching-begin)
|
|
611 (end-of-line 1))
|
|
612 (end-of-line 0))
|
|
613 (delete-char 1)
|
|
614 (delete-horizontal-space)
|
|
615 (LaTeX-insert-item))
|
|
616
|
|
617 (defun LaTeX-label (environment)
|
|
618 "Insert a label for ENVIRONMENT at point.
|
|
619 If LaTeX-label-function is a valid function, LaTeX label will transfer the
|
|
620 job to this function."
|
|
621 (let (label)
|
|
622 (if (and (boundp 'LaTeX-label-function)
|
|
623 LaTeX-label-function
|
|
624 (fboundp LaTeX-label-function))
|
|
625
|
|
626 (setq label (funcall LaTeX-label-function environment))
|
|
627 (let ((prefix
|
|
628 (cond
|
|
629 ((string= "figure" environment) LaTeX-figure-label)
|
|
630 ((string= "table" environment) LaTeX-table-label)
|
|
631 ((assoc environment LaTeX-section-list)
|
|
632 (cond
|
|
633 ((stringp LaTeX-section-label) LaTeX-section-label)
|
|
634 ((and (listp LaTeX-section-label)
|
|
635 (assoc environment LaTeX-section-label))
|
|
636 (cdr (assoc environment LaTeX-section-label)))
|
|
637 (t nil)))
|
|
638 (t ""))))
|
|
639 (if prefix
|
|
640 (progn
|
|
641 (setq label (read-string "What label: " prefix))
|
|
642 (if (string= prefix label)
|
|
643 (setq label nil) ; No label eneterd
|
|
644 (insert TeX-esc "label" TeX-grop label TeX-grcl)))))
|
|
645 (if label
|
|
646 (progn
|
|
647 (LaTeX-add-labels label)
|
|
648 label)
|
|
649 nil))))
|
|
650
|
|
651
|
|
652 (defun LaTeX-env-figure (environment)
|
|
653 "Create ENVIRONMENT with \\label and \\caption commands."
|
|
654 (let ((float (read-string "Float to: " LaTeX-float))
|
|
655 (caption (read-string "Caption: "))
|
|
656 (center (y-or-n-p "Center: ")))
|
|
657
|
|
658 (setq LaTeX-float (if (zerop (length float))
|
|
659 LaTeX-float
|
|
660 float))
|
|
661
|
|
662 (LaTeX-insert-environment environment
|
|
663 (and LaTeX-float
|
|
664 (concat LaTeX-optop
|
|
665 LaTeX-float
|
|
666 LaTeX-optcl)))
|
|
667
|
|
668 (if center
|
|
669 (progn
|
|
670 (LaTeX-insert-environment "center")))
|
|
671
|
|
672 (newline-and-indent)
|
|
673 (LaTeX-label environment)
|
|
674 (end-of-line 0)
|
|
675 (LaTeX-indent-line)
|
|
676
|
|
677 (if (zerop (length caption))
|
|
678 ()
|
|
679 ;; NOTE: Caption is _inside_ center because that looks best typeset.
|
|
680 (newline-and-indent)
|
|
681 (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
|
|
682 (end-of-line 0)
|
|
683 (LaTeX-indent-line))
|
|
684
|
|
685 (if (string= environment "table") (LaTeX-env-array "tabular"))))
|
|
686
|
|
687 (defun LaTeX-env-array (environment)
|
|
688 "Insert ENVIRONMENT with position and column specifications
|
|
689 like array and tabular."
|
|
690 (let ((pos (read-string "Position: "))
|
|
691 (fmt (read-string "Format: " LaTeX-default-format)))
|
|
692 (setq LaTeX-default-position pos)
|
|
693 (setq LaTeX-default-format fmt)
|
|
694 (LaTeX-insert-environment environment
|
|
695 (concat
|
|
696 (if (not (zerop (length pos)))
|
|
697 (format "[%s]" pos))
|
|
698 (format "{%s}" fmt)))
|
|
699 (end-of-line 0)
|
|
700 (next-line 1)
|
|
701 (delete-horizontal-space)))
|
|
702
|
|
703 (defun LaTeX-env-label (environment)
|
|
704 "Insert ENVIRONMENT and prompt for label."
|
|
705 (LaTeX-insert-environment environment)
|
|
706 (and (LaTeX-label environment)
|
|
707 (newline-and-indent)))
|
|
708
|
|
709 (defun LaTeX-env-list (environment)
|
|
710 "Insert ENVIRONMENT and the first item."
|
|
711 (let ((label (read-string "Default Label: ")))
|
|
712 (LaTeX-insert-environment environment
|
|
713 (format "{%s}{}" label))
|
|
714 (end-of-line 0)
|
|
715 (delete-char 1)
|
|
716 (delete-horizontal-space))
|
|
717 (LaTeX-insert-item))
|
|
718
|
|
719 (defun LaTeX-env-minipage (environment)
|
|
720 "Create new LaTeX minipage."
|
|
721 (let ((pos (read-string "Position: " LaTeX-default-position))
|
|
722 (width (read-string "Width: ")))
|
|
723 (setq LaTeX-default-position pos)
|
|
724 (if (zerop (length width))
|
|
725 (setq width "4cm"))
|
|
726 (LaTeX-insert-environment environment
|
|
727 (concat (if (not (zerop (length pos)))
|
|
728 (format "[%s]" pos))
|
|
729 (format "{%s}" width)))
|
|
730 (end-of-line 0)
|
|
731 (next-line 1)
|
|
732 (delete-horizontal-space)))
|
|
733
|
|
734 (defun LaTeX-env-tabular* (environment)
|
|
735 "Insert ENVIRONMENT with width, position and column specifications."
|
|
736 (let ((width (read-string "Width: "))
|
|
737 (pos (read-string "Position: " LaTeX-default-position))
|
|
738 (fmt (read-string "Format: " LaTeX-default-format)))
|
|
739 (setq LaTeX-default-position pos)
|
|
740 (setq LaTeX-default-format fmt)
|
|
741 (LaTeX-insert-environment environment
|
|
742 (concat
|
|
743 (if (not (zerop (length width)))
|
|
744 (format "{%s}" width))
|
|
745 (if (not (zerop (length pos)))
|
|
746 (format "[%s]" pos))
|
|
747 (format "{%s}" fmt)))
|
|
748 (end-of-line 0)
|
|
749 (next-line 1)
|
|
750 (delete-horizontal-space)))
|
|
751
|
|
752 (defun LaTeX-env-picture (environment)
|
|
753 "Insert ENVIRONMENT with width, height specifications."
|
|
754 (let ((width (read-string "Width: "))
|
|
755 (height (read-string "Height: "))
|
|
756 (x-offset (read-string "X Offset: "))
|
|
757 (y-offset (read-string "Y Offset: ")))
|
|
758 (if (zerop (length x-offset))
|
|
759 (setq x-offset "0"))
|
|
760 (if (zerop (length y-offset))
|
|
761 (setq y-offset "0"))
|
|
762 (LaTeX-insert-environment environment
|
|
763 (concat (format "(%s,%s)" width height)
|
|
764 (if (not (and (string= x-offset "0")
|
|
765 (string= y-offset "0")))
|
|
766 (format "(%s,%s)" x-offset y-offset))))
|
|
767
|
|
768 (end-of-line 0)
|
|
769 (next-line 1)
|
|
770 (delete-horizontal-space)))
|
|
771
|
|
772 (defun LaTeX-env-bib (environment)
|
|
773 "Insert ENVIRONMENT with label for bibitem."
|
|
774 (LaTeX-insert-environment environment
|
|
775 (concat TeX-grop
|
|
776 (read-string "Label for BibItem: " "99")
|
|
777 TeX-grcl))
|
|
778 (end-of-line 0)
|
|
779 (delete-char 1)
|
|
780 (delete-horizontal-space)
|
|
781 (LaTeX-insert-item))
|
|
782
|
|
783 ;;; Item hooks
|
|
784
|
|
785 (defvar LaTeX-item-list nil
|
|
786 "An list of environments where items have a special syntax.
|
|
787 The cdr is the name of the function, used to insert this kind of items.")
|
|
788
|
|
789 (defun LaTeX-insert-item ()
|
|
790 "Insert a new item in an environment.
|
|
791 You may use LaTeX-item-list to change the routines used to insert the item."
|
|
792 (interactive "*")
|
|
793 (let ((environment (LaTeX-current-environment)))
|
|
794 (newline)
|
|
795 (if (assoc environment LaTeX-item-list)
|
|
796 (funcall (cdr (assoc environment LaTeX-item-list)))
|
|
797 (TeX-insert-macro "item"))
|
|
798 (LaTeX-indent-line)))
|
|
799
|
|
800 (defun LaTeX-item-argument ()
|
|
801 "Insert a new item with an optional argument."
|
|
802 (let ((TeX-arg-item-label-p t))
|
|
803 (TeX-insert-macro "item")))
|
|
804
|
|
805 (defun LaTeX-item-bib ()
|
|
806 "Insert a new bibitem."
|
|
807 (TeX-insert-macro "bibitem"))
|
|
808
|
|
809 ;;; Parser
|
|
810
|
|
811 (defvar LaTeX-auto-minimal-regexp-list
|
|
812 '(("\\\\document\\(style\\|class\\)\
|
|
813 \\(\\[\\(\\([^#\\\\\\.%]\\|%[^\n\r]*[\n\r]\\)+\\)\\]\\)?\
|
|
814 {\\([^#\\\\\\.\n\r]+\\)}"
|
|
815 (3 5 1) LaTeX-auto-style))
|
|
816 "Minimal list of regular expressions matching LaTeX macro definitions.")
|
|
817
|
|
818 (defvar LaTeX-auto-label-regexp-list
|
|
819 '(("\\\\label{\\([^\n\r%\\{}]+\\)}" 1 LaTeX-auto-label))
|
|
820 "List of regular expression matching LaTeX labels only.")
|
|
821
|
|
822 (defvar LaTeX-auto-regexp-list
|
|
823 (append
|
|
824 '(("\\\\newcommand{?\\\\\\([a-zA-Z]+\\)}?\\[\\([0-9]+\\)\\]\
|
|
825 \\[\\([^\]\\\\\n\r]+\\)\\]"
|
|
826 (1 2 3) LaTeX-auto-optional)
|
|
827 ("\\\\newcommand{?\\\\\\([a-zA-Z]+\\)}?\\[\\([0-9]+\\)\\]"
|
|
828 (1 2) LaTeX-auto-arguments)
|
|
829 ("\\\\newcommand{?\\\\\\([a-zA-Z]+\\)}?" 1 TeX-auto-symbol)
|
|
830 ("\\\\newenvironment{?\\([a-zA-Z]+\\)}?\\[\\([0-9]+\\)\\]\\["
|
|
831 1 LaTeX-auto-environment)
|
|
832 ("\\\\newenvironment{?\\([a-zA-Z]+\\)}?\\[\\([0-9]+\\)\\]"
|
|
833 (1 2) LaTeX-auto-env-args)
|
|
834 ("\\\\newenvironment{?\\([a-zA-Z]+\\)}?" 1 LaTeX-auto-environment)
|
|
835 ("\\\\newtheorem{\\([a-zA-Z]+\\)}" 1 LaTeX-auto-environment)
|
|
836 ("\\\\input{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
|
|
837 1 TeX-auto-file)
|
|
838 ("\\\\include{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
|
|
839 1 TeX-auto-file)
|
|
840 ("\\\\usepackage\\(\\[[^\]\\\\]*\\]\\)?\
|
|
841 {\\(\\([^#}\\\\\\.%]\\|%[^\n\r]*[\n\r]\\)+\\)}"
|
|
842 (2) LaTeX-auto-style)
|
|
843 ("\\\\bibitem{\\([a-zA-Z][^, \n\r\t%\"#'()={}]*\\)}" 1 LaTeX-auto-bibitem)
|
|
844 ("\\\\bibitem\\[[^][\n\r]+\\]{\\([a-zA-Z][^, \n\r\t%\"#'()={}]*\\)}"
|
|
845 1 LaTeX-auto-bibitem)
|
|
846 ("\\\\bibliography{\\([^#}\\\\\n\r]+\\)}" 1 LaTeX-auto-bibliography))
|
|
847 LaTeX-auto-label-regexp-list
|
|
848 LaTeX-auto-minimal-regexp-list)
|
|
849 "List of regular expression matching common LaTeX macro definitions.")
|
|
850
|
|
851 (defun LaTeX-auto-prepare ()
|
|
852 ;; Prepare for LaTeX parsing.
|
|
853 (setq LaTeX-auto-arguments nil
|
|
854 LaTeX-auto-optional nil
|
|
855 LaTeX-auto-env-args nil
|
|
856 LaTeX-auto-style nil
|
|
857 LaTeX-auto-end-symbol nil))
|
|
858
|
|
859 (add-hook 'TeX-auto-prepare-hook 'LaTeX-auto-prepare)
|
|
860
|
|
861 (defun LaTeX-auto-cleanup ()
|
|
862 ;; Cleanup after LaTeX parsing.
|
|
863
|
|
864 ;; Cleanup BibTeX files
|
|
865 (setq LaTeX-auto-bibliography
|
|
866 (apply 'append (mapcar (function (lambda (arg)
|
|
867 (TeX-split-string "," arg)))
|
|
868 LaTeX-auto-bibliography)))
|
|
869
|
|
870 ;; Cleanup document styles and packages
|
|
871 (if (null LaTeX-auto-style)
|
|
872 ()
|
|
873 (while LaTeX-auto-style
|
|
874 (let* ((entry (car LaTeX-auto-style))
|
|
875 (options (nth 0 entry))
|
|
876 (style (nth 1 entry))
|
|
877 (class (nth 2 entry)))
|
|
878
|
|
879 ;; Next document style.
|
|
880 (setq LaTeX-auto-style (cdr LaTeX-auto-style))
|
|
881
|
|
882 ;; Get the options.
|
|
883 (setq options (TeX-split-string
|
|
884 "\\([ \t\r\n]\\|%[^\n\r]*[\n\r]\\|,\\)+"
|
|
885 options))
|
|
886
|
|
887 ;; Strip empty options.
|
|
888 (if (string-equal (car options) "")
|
|
889 (setq options (cdr options)))
|
|
890 (let ((index options))
|
|
891 (while (cdr-safe index)
|
|
892 (if (string-equal (car (cdr index)) "")
|
|
893 (setcdr index (cdr (cdr index)))
|
|
894 (setq index (cdr index)))))
|
|
895
|
|
896 ;; Add them, to the style list.
|
|
897 (setq TeX-auto-file (append options TeX-auto-file))
|
|
898
|
|
899 ;; The second argument if present is a normal style file.
|
|
900 (if (null style)
|
|
901 ()
|
|
902 (setq TeX-auto-file (cons style TeX-auto-file))
|
|
903
|
|
904 ;; And a special "art10" style file combining style and size.
|
|
905 (setq TeX-auto-file
|
|
906 (cons (concat
|
|
907 (cond ((string-equal "article" style)
|
|
908 "art")
|
|
909 ((string-equal "book" style)
|
|
910 "bk")
|
|
911 ((string-equal "report" style)
|
|
912 "rep")
|
|
913 ((string-equal "jarticle" style)
|
|
914 "jart")
|
|
915 ((string-equal "jbook" style)
|
|
916 "jbk")
|
|
917 ((string-equal "jreport" style)
|
|
918 "jrep")
|
|
919 ((string-equal "j-article" style)
|
|
920 "j-art")
|
|
921 ((string-equal "j-book" style)
|
|
922 "j-bk")
|
|
923 ((string-equal "j-report" style )
|
|
924 "j-rep")
|
|
925 (t style))
|
|
926 (cond ((member "11pt" options)
|
|
927 "11")
|
|
928 ((member "12pt" options)
|
|
929 "12")
|
|
930 (t
|
|
931 "10")))
|
|
932 TeX-auto-file)))
|
|
933
|
|
934 ;; The third argument if "class" indicates LaTeX2e features.
|
|
935 (cond ((equal class "class")
|
|
936 (setq TeX-auto-file (cons "latex2e" TeX-auto-file)))
|
|
937 ((equal class "style")
|
|
938 (setq TeX-auto-file (cons "latex2" TeX-auto-file)))))))
|
|
939
|
|
940 ;; Cleanup optional arguments
|
|
941 (mapcar (function (lambda (entry)
|
|
942 (setq TeX-auto-symbol
|
|
943 (cons (list (nth 0 entry)
|
|
944 (string-to-int (nth 1 entry)))
|
|
945 TeX-auto-symbol))))
|
|
946 LaTeX-auto-arguments)
|
|
947
|
|
948 ;; Cleanup default optional arguments
|
|
949 (mapcar (function (lambda (entry)
|
|
950 (setq TeX-auto-symbol
|
|
951 (cons (list (nth 0 entry)
|
|
952 (vector "argument")
|
|
953 (1- (string-to-int (nth 1 entry))))
|
|
954 TeX-auto-symbol))))
|
|
955 LaTeX-auto-optional)
|
|
956
|
|
957 ;; Cleanup environments arguments
|
|
958 (mapcar (function (lambda (entry)
|
|
959 (setq LaTeX-auto-environment
|
|
960 (cons (list (nth 0 entry)
|
|
961 (string-to-int (nth 1 entry)))
|
|
962 LaTeX-auto-environment))))
|
|
963 LaTeX-auto-env-args)
|
|
964
|
|
965 ;; Cleanup use of def to add environments
|
|
966 ;; NOTE: This uses an O(N^2) algorithm, while an O(N log N)
|
|
967 ;; algorithm is possible.
|
|
968 (mapcar (function (lambda (symbol)
|
|
969 (if (not (TeX-member symbol TeX-auto-symbol 'equal))
|
|
970 ;; No matching symbol, insert in list
|
|
971 (setq TeX-auto-symbol
|
|
972 (cons (concat "end" symbol) TeX-auto-symbol))
|
|
973 ;; Matching symbol found, remove from list
|
|
974 (if (equal (car TeX-auto-symbol) symbol)
|
|
975 ;; Is it the first symbol?
|
|
976 (setq TeX-auto-symbol (cdr TeX-auto-symbol))
|
|
977 ;; Nope! Travel the list
|
|
978 (let ((list TeX-auto-symbol))
|
|
979 (while (consp (cdr list))
|
|
980 ;; Until we find it.
|
|
981 (if (equal (car (cdr list)) symbol)
|
|
982 ;; Then remove it.
|
|
983 (setcdr list (cdr (cdr list))))
|
|
984 (setq list (cdr list)))))
|
|
985 ;; and add the symbol as an environment.
|
|
986 (setq LaTeX-auto-environment
|
|
987 (cons symbol LaTeX-auto-environment)))))
|
|
988 LaTeX-auto-end-symbol))
|
|
989
|
|
990 (add-hook 'TeX-auto-cleanup-hook 'LaTeX-auto-cleanup)
|
|
991
|
|
992 (TeX-auto-add-type "label" "LaTeX")
|
|
993 (TeX-auto-add-type "bibitem" "LaTeX")
|
|
994 (TeX-auto-add-type "environment" "LaTeX")
|
|
995 (TeX-auto-add-type "bibliography" "LaTeX" "bibliographies")
|
|
996
|
|
997 (fset 'LaTeX-add-bibliographies-auto
|
|
998 (symbol-function 'LaTeX-add-bibliographies))
|
|
999 (defun LaTeX-add-bibliographies (&rest bibliographies)
|
|
1000 "Add BIBLIOGRAPHIES to the list of known bibliographies and style files."
|
|
1001 (apply 'LaTeX-add-bibliographies-auto bibliographies)
|
|
1002 (apply 'TeX-run-style-hooks bibliographies))
|
|
1003
|
|
1004 (fset 'LaTeX-add-environments-auto
|
|
1005 (symbol-function 'LaTeX-add-environments))
|
|
1006 (defun LaTeX-add-environments (&rest environments)
|
|
1007 "Add ENVIRONMENTS to the list of known environments."
|
|
1008 (apply 'LaTeX-add-environments-auto environments)
|
|
1009 (setq LaTeX-menu-changed t))
|
|
1010
|
|
1011 ;;; BibTeX
|
|
1012
|
|
1013 ;;;###autoload
|
|
1014 (defun BibTeX-auto-store ()
|
|
1015 "This function should be called from bibtex-mode-hook.
|
|
1016 It will setup BibTeX to store keys in an auto file."
|
|
1017 ;; We want this to be early in the list, so we do not
|
|
1018 ;; add it before we enter BibTeX mode the first time.
|
|
1019 (if (boundp 'local-write-file-hooks)
|
|
1020 (add-hook 'local-write-file-hooks 'TeX-safe-auto-write)
|
|
1021 (add-hook 'write-file-hooks 'TeX-safe-auto-write))
|
|
1022 (make-local-variable 'TeX-auto-update)
|
|
1023 (setq TeX-auto-update 'BibTeX)
|
|
1024 (make-local-variable 'TeX-auto-untabify)
|
|
1025 (setq TeX-auto-untabify nil)
|
|
1026 (make-local-variable 'TeX-auto-parse-length)
|
|
1027 (setq TeX-auto-parse-length 999999)
|
|
1028 (make-local-variable 'TeX-auto-regexp-list)
|
|
1029 (setq TeX-auto-regexp-list BibTeX-auto-regexp-list))
|
|
1030
|
|
1031 (defvar BibTeX-auto-regexp-list
|
|
1032 '(("@[Ss][Tt][Rr][Ii][Nn][Gg]" 1 ignore)
|
|
1033 ("@[a-zA-Z]+[{(][ \t]*\\([a-zA-Z][^, \n\r\t%\"#'()={}]*\\)"
|
|
1034 1 LaTeX-auto-bibitem))
|
|
1035 "List of regexp-list expressions matching BibTeX items.")
|
|
1036
|
|
1037 ;;; Macro Argument Hooks
|
|
1038
|
|
1039 (defun TeX-arg-conditional (optional expr then else)
|
|
1040 "Implement if EXPR THEN ELSE.
|
|
1041
|
|
1042 If EXPR evaluate to true, parse THEN as an argument list, else parse
|
|
1043 ELSE as an argument list."
|
|
1044 (TeX-parse-arguments (if (eval expr) then else)))
|
|
1045
|
|
1046 (defun TeX-arg-free (optional &optional &rest args)
|
|
1047 "Parse its arguments but use no braces when they are inserted."
|
|
1048 (let ((< "")
|
|
1049 (> ""))
|
|
1050 (if (equal (length args) 1)
|
|
1051 (TeX-parse-argument optional (car args))
|
|
1052 (TeX-parse-argument optional args))))
|
|
1053
|
|
1054 (defun TeX-arg-literal (optional &optional &rest args)
|
|
1055 "Insert its arguments into the buffer.
|
|
1056 Used for specifying extra syntax for a macro."
|
|
1057 (apply 'insert args))
|
|
1058
|
|
1059 (defun TeX-arg-eval (optional &rest args)
|
|
1060 "Evaluate args and insert value in buffer."
|
|
1061 (TeX-argument-insert (eval args) optional))
|
|
1062
|
|
1063 (defun TeX-arg-label (optional &optional prompt definition)
|
|
1064 "Prompt for a label completing with known labels."
|
|
1065 (let ((label (completing-read (TeX-argument-prompt optional prompt "Key")
|
|
1066 (LaTeX-label-list))))
|
|
1067 (if (and definition (not (string-equal "" label)))
|
|
1068 (LaTeX-add-labels label))
|
|
1069 (TeX-argument-insert label optional optional)))
|
|
1070
|
|
1071 (defun TeX-arg-macro (optional &optional prompt definition)
|
|
1072 "Prompt for a TeX macro with completion."
|
|
1073 (let ((macro (completing-read (TeX-argument-prompt optional prompt
|
|
1074 (concat "Macro: "
|
|
1075 TeX-esc)
|
|
1076 t)
|
|
1077 (TeX-symbol-list))))
|
|
1078 (if (and definition (not (string-equal "" macro)))
|
|
1079 (TeX-add-symbols macro))
|
|
1080 (TeX-argument-insert macro optional TeX-esc)))
|
|
1081
|
|
1082 (defun TeX-arg-environment (optional &optional prompt definition)
|
|
1083 "Prompt for a LaTeX environment with completion."
|
|
1084 (let ((environment (completing-read (TeX-argument-prompt optional prompt
|
|
1085 "Environment")
|
|
1086 (TeX-symbol-list))))
|
|
1087 (if (and definition (not (string-equal "" environment)))
|
|
1088 (LaTeX-add-environments environment))
|
|
1089
|
|
1090 (TeX-argument-insert environment optional)))
|
|
1091
|
|
1092 (defun TeX-arg-cite (optional &optional prompt definition)
|
|
1093 "Prompt for a BibTeX citation with completion."
|
|
1094 (setq prompt (concat (if optional "(Optional) " "")
|
|
1095 (if prompt prompt "Add key")
|
|
1096 ": (default none) "))
|
|
1097 (let ((items (multi-prompt "," t prompt (LaTeX-bibitem-list))))
|
|
1098 (apply 'LaTeX-add-bibitems items)
|
|
1099 (TeX-argument-insert (mapconcat 'identity items ",") optional optional)))
|
|
1100
|
|
1101 (defun TeX-arg-counter (optional &optional prompt definition)
|
|
1102 "Prompt for a LaTeX counter."
|
|
1103 ;; Completion not implemented yet.
|
|
1104 (TeX-argument-insert
|
|
1105 (read-string (TeX-argument-prompt optional prompt "Counter"))
|
|
1106 optional))
|
|
1107
|
|
1108 (defun TeX-arg-savebox (optional &optional prompt definition)
|
|
1109 "Prompt for a LaTeX savebox."
|
|
1110 ;; Completion not implemented yet.
|
|
1111 (TeX-argument-insert
|
|
1112 (read-string (TeX-argument-prompt optional prompt
|
|
1113 (concat "Savebox: " TeX-esc)
|
|
1114 t))
|
|
1115 optional TeX-esc))
|
|
1116
|
|
1117 (defun TeX-arg-file (optional &optional prompt)
|
|
1118 "Prompt for a filename in the current directory."
|
|
1119 (TeX-argument-insert (read-file-name (TeX-argument-prompt optional
|
|
1120 prompt "File")
|
|
1121 "" "" nil)
|
|
1122 optional))
|
|
1123
|
|
1124 (defun TeX-arg-define-label (optional &optional prompt)
|
|
1125 "Prompt for a label completing with known labels."
|
|
1126 (TeX-arg-label optional prompt t))
|
|
1127
|
|
1128 (defun TeX-arg-define-macro (optional &optional prompt)
|
|
1129 "Prompt for a TeX macro with completion."
|
|
1130 (TeX-arg-macro optional prompt t))
|
|
1131
|
|
1132 (defun TeX-arg-define-environment (optional &optional prompt)
|
|
1133 "Prompt for a LaTeX environment with completion."
|
|
1134 (TeX-arg-environment optional prompt t))
|
|
1135
|
|
1136 (defun TeX-arg-define-cite (optional &optional prompt)
|
|
1137 "Prompt for a BibTeX citation."
|
|
1138 (TeX-arg-cite optional prompt t))
|
|
1139
|
|
1140 (defun TeX-arg-define-counter (optional &optional prompt)
|
|
1141 "Prompt for a LaTeX counter."
|
|
1142 (TeX-arg-counter optional prompt t))
|
|
1143
|
|
1144 (defun TeX-arg-define-savebox (optional &optional prompt)
|
|
1145 "Prompt for a LaTeX savebox."
|
|
1146 (TeX-arg-savebox optional prompt t))
|
|
1147
|
|
1148 (defvar LaTeX-style-list '(("book")
|
|
1149 ("article")
|
|
1150 ("letter")
|
|
1151 ("slides")
|
|
1152 ("report"))
|
|
1153 "*List of document styles.")
|
|
1154
|
|
1155 (make-variable-buffer-local 'LaTeX-style-list)
|
|
1156
|
|
1157 (defun TeX-arg-document (optional &optional ignore)
|
|
1158 "Insert arguments to documentstyle and documentclass."
|
|
1159 (let ((style (completing-read
|
|
1160 (concat "Document style: (default " LaTeX-default-style ") ")
|
|
1161 LaTeX-style-list))
|
|
1162 (options (read-string "Options: "
|
|
1163 (if (stringp LaTeX-default-options)
|
|
1164 LaTeX-default-options
|
|
1165 (mapconcat 'identity
|
|
1166 LaTeX-default-options
|
|
1167 ",")))))
|
|
1168 (if (zerop (length style))
|
|
1169 (setq style LaTeX-default-style))
|
|
1170 (if (not (zerop (length options)))
|
|
1171 (insert LaTeX-optop options LaTeX-optcl))
|
|
1172 (insert TeX-grop style TeX-grcl))
|
|
1173
|
|
1174 ;; remove old information
|
|
1175 (TeX-remove-style)
|
|
1176
|
|
1177 ;; defined in individual style hooks
|
|
1178 (TeX-update-style))
|
|
1179
|
|
1180 (defvar TeX-global-input-files nil
|
|
1181 "*List of the non-local TeX input files.
|
|
1182
|
|
1183 Initialized once at the first time you prompt for an input file.
|
|
1184 May be reset with `C-u \\[TeX-normal-mode]'.")
|
|
1185
|
|
1186 (defun TeX-arg-input-file (optionel &optional prompt local)
|
|
1187 "Prompt for a tex or sty file.
|
|
1188
|
|
1189 First optional argument is the promt, the second is a flag.
|
|
1190 If the flag is set, only complete with local files."
|
|
1191 (if (or TeX-global-input-files local)
|
|
1192 ()
|
|
1193 (message "Searching for files...")
|
|
1194 (setq TeX-global-input-files
|
|
1195 (mapcar 'list (TeX-search-files (append TeX-macro-private
|
|
1196 TeX-macro-global)
|
|
1197 TeX-file-extensions t t))))
|
|
1198 (let ((file (if TeX-check-path
|
|
1199 (completing-read
|
|
1200 (TeX-argument-prompt optionel prompt "File")
|
|
1201 (append (mapcar 'list
|
|
1202 (TeX-search-files '(".")
|
|
1203 TeX-file-extensions
|
|
1204 t t))
|
|
1205 (if local
|
|
1206 nil
|
|
1207 TeX-global-input-files)))
|
|
1208 (read-file-name
|
|
1209 (TeX-argument-prompt optionel prompt "File")))))
|
|
1210 (if (null file)
|
|
1211 (setq file ""))
|
|
1212 (if (not (string-equal "" file))
|
|
1213 (TeX-run-style-hooks file))
|
|
1214 (TeX-argument-insert file optionel)))
|
|
1215
|
|
1216 (defvar BibTeX-global-style-files nil
|
|
1217 "*Association list of BibTeX style files.
|
|
1218
|
|
1219 Initialized once at the first time you prompt for an input file.
|
|
1220 May be reset with `C-u \\[TeX-normal-mode]'.")
|
|
1221
|
|
1222 (defun TeX-arg-bibstyle (optional &optional prompt)
|
|
1223 "Prompt for a BibTeX style file."
|
|
1224 (message "Searching for BibTeX styles...")
|
|
1225 (or BibTeX-global-style-files
|
|
1226 (setq BibTeX-global-style-files
|
|
1227 (mapcar 'list
|
|
1228 (TeX-search-files (append TeX-macro-private
|
|
1229 TeX-macro-global)
|
|
1230 BibTeX-style-extensions t t))))
|
|
1231
|
|
1232 (TeX-argument-insert
|
|
1233 (completing-read (TeX-argument-prompt optional prompt "BibTeX style")
|
|
1234 (append (mapcar 'list
|
|
1235 (TeX-search-files '(".")
|
|
1236 BibTeX-style-extensions
|
|
1237 t t))
|
|
1238 BibTeX-global-style-files))
|
|
1239 optional))
|
|
1240
|
|
1241 (defvar BibTeX-global-files nil
|
|
1242 "*Association list of BibTeX files.
|
|
1243
|
|
1244 Initialized once at the first time you prompt for an BibTeX file.
|
|
1245 May be reset with `C-u \\[TeX-normal-mode]'.")
|
|
1246
|
|
1247 (defun TeX-arg-bibliography (optional &optional prompt)
|
|
1248 "Prompt for a BibTeX database file."
|
|
1249 (message "Searching for BibTeX files...")
|
|
1250 (or BibTeX-global-files
|
|
1251 (setq BibTeX-global-files
|
|
1252 (mapcar 'list (TeX-search-files nil BibTeX-file-extensions t t))))
|
|
1253
|
|
1254 (let ((styles (multi-prompt
|
|
1255 "," t
|
|
1256 (TeX-argument-prompt optional prompt "BibTeX files")
|
|
1257 (append (mapcar 'list
|
|
1258 (TeX-search-files '(".")
|
|
1259 BibTeX-file-extensions
|
|
1260 t t))
|
|
1261 BibTeX-global-files))))
|
|
1262 (apply 'LaTeX-add-bibliographies styles)
|
|
1263 (TeX-argument-insert (mapconcat 'identity styles ",") optional)))
|
|
1264
|
|
1265 (defun TeX-arg-corner (optional &optional prompt)
|
|
1266 "Prompt for a LaTeX side or corner position with completion."
|
|
1267 (TeX-argument-insert
|
|
1268 (completing-read (TeX-argument-prompt optional prompt "Position")
|
|
1269 '(("") ("l") ("r") ("t") ("b") ("tl") ("tr") ("bl") ("br"))
|
|
1270 nil t)
|
|
1271 optional))
|
|
1272
|
|
1273 (defun TeX-arg-lr (optional &optional prompt)
|
|
1274 "Prompt for a LaTeX side with completion."
|
|
1275 (TeX-argument-insert
|
|
1276 (completing-read (TeX-argument-prompt optional prompt "Position")
|
|
1277 '(("") ("l") ("r"))
|
|
1278 nil t)
|
|
1279 optional))
|
|
1280
|
|
1281 (defun TeX-arg-tb (optional &optional prompt)
|
|
1282 "Prompt for a LaTeX side with completion."
|
|
1283 (TeX-argument-insert
|
|
1284 (completing-read (TeX-argument-prompt optional prompt "Position")
|
|
1285 '(("") ("t") ("b"))
|
|
1286 nil t)
|
|
1287 optional))
|
|
1288
|
|
1289 (defun TeX-arg-pagestyle (optional &optional prompt)
|
|
1290 "Prompt for a LaTeX pagestyle with completion."
|
|
1291 (TeX-argument-insert
|
|
1292 (completing-read (TeX-argument-prompt optional prompt "Pagestyle")
|
|
1293 '(("plain") ("empty") ("headings") ("myheadings")))
|
|
1294 optional))
|
|
1295
|
|
1296 (defun TeX-arg-verb (optional &optional ignore)
|
|
1297 "Prompt for delimiter and text."
|
|
1298 (let ((del (read-quoted-char "Delimiter: "))
|
|
1299 (text (read-from-minibuffer "Text: ")))
|
|
1300 (insert del text del)))
|
|
1301
|
|
1302 (defun TeX-arg-pair (optional first second)
|
|
1303 "Insert a pair of number, prompted by FIRST and SECOND.
|
|
1304
|
|
1305 The numbers are surounded by parenthesizes and separated with a
|
|
1306 comma."
|
|
1307 (insert "(" (read-string (concat first ": ")) ","
|
|
1308 (read-string (concat second ": ")) ")"))
|
|
1309
|
|
1310 (defun TeX-arg-size (optional)
|
|
1311 "Insert width and height as a pair."
|
|
1312 (TeX-arg-pair optional "Width" "Height"))
|
|
1313
|
|
1314 (defun TeX-arg-coordinate (optional)
|
|
1315 "Insert x and y coordinate as a pair."
|
|
1316 (TeX-arg-pair optional "X position" "Y position"))
|
|
1317
|
|
1318 (defconst TeX-braces-default-association
|
|
1319 '(("[" . "]")
|
|
1320 ("\\{" . "\\}")
|
|
1321 ("(" . ")")
|
|
1322 ("|" . "|")
|
|
1323 ("\\|" . "\\|")
|
|
1324 ("/" . "/")
|
|
1325 ("\\backslash" . "\\backslash")
|
|
1326 ("\\lfloor" . "\\rfloor")
|
|
1327 ("\\lceil" . "\\rceil")
|
|
1328 ("\\langle" . "\\rangle")))
|
|
1329
|
|
1330 (defvar TeX-braces-user-association nil
|
|
1331 "A list of your personal association of brace symbols for \\left and \\right
|
|
1332
|
|
1333 The car of each entry is the brace used with \\left,
|
|
1334 the cdr is the brace used with \\right.")
|
|
1335
|
|
1336 (defvar TeX-braces-association
|
|
1337 (append TeX-braces-user-association
|
|
1338 TeX-braces-default-association)
|
|
1339 "A list of association of brace symbols for \\left and \\right.
|
|
1340 The car of each entry is the brace used with \\left,
|
|
1341 the cdr is the brace used with \\right.")
|
|
1342
|
|
1343 (defvar TeX-left-right-braces
|
|
1344 '(("[") ("]") ("\\{") ("\\}") ("(") (")") ("|") ("\\|")
|
|
1345 ("/") ("\\backslash") ("\\lfloor") ("\\rfloor")
|
|
1346 ("\\lceil") ("\\rceil") ("\\langle") ("\\rangle")
|
|
1347 ("\\uparrow") ("\\Uparrow") ("\\downarrow") ("\\Downarrow")
|
|
1348 ("\\updownarrow") ("\\Updownarrow") ("."))
|
|
1349 "List of symbols which can follow the \\left or \\right command")
|
|
1350
|
|
1351 (defun TeX-arg-insert-braces (optional &optional prompt)
|
|
1352 (save-excursion
|
|
1353 (backward-word 1)
|
|
1354 (backward-char)
|
|
1355 (newline-and-indent)
|
|
1356 (beginning-of-line 0)
|
|
1357 (if (looking-at "^[ \t]*$")
|
|
1358 (progn (delete-horizontal-space)
|
|
1359 (delete-char 1))))
|
|
1360 (let ((left-brace (completing-read
|
|
1361 (TeX-argument-prompt optional prompt "Which brace")
|
|
1362 TeX-left-right-braces)))
|
|
1363 (insert left-brace)
|
|
1364 (newline-and-indent)
|
|
1365 (save-excursion
|
|
1366 (let ((right-brace (cdr (assoc left-brace
|
|
1367 TeX-braces-association))))
|
|
1368 (newline)
|
|
1369 (insert TeX-esc "right")
|
|
1370 (if (and TeX-arg-right-insert-p
|
|
1371 right-brace)
|
|
1372 (insert right-brace)
|
|
1373 (insert (completing-read
|
|
1374 (TeX-argument-prompt optional prompt "Which brace")
|
|
1375 TeX-left-right-braces)))
|
|
1376 (LaTeX-indent-line)))))
|
|
1377
|
|
1378 ;;; Indentation
|
|
1379
|
|
1380 (defvar LaTeX-indent-level 2
|
|
1381 "*Indentation of begin-end blocks in LaTeX.")
|
|
1382
|
|
1383 (defvar LaTeX-item-indent (- LaTeX-indent-level)
|
|
1384 "*Extra indentation for lines beginning with an item.")
|
|
1385
|
|
1386 (defvar LaTeX-item-regexp "\\(bib\\)?item\\b"
|
|
1387 "*Regular expression matching macros considered items.")
|
|
1388
|
|
1389 (defun LaTeX-indent-line ()
|
|
1390 "Indent the line containing point, as LaTeX source.
|
|
1391 Add LaTeX-indent-level indentation in each \\begin{ - \\end{ block.
|
|
1392 Lines starting with an item is given an extra indentation of
|
|
1393 LaTeX-item-indent."
|
|
1394 (interactive)
|
|
1395 (let ((indent (LaTeX-indent-calculate)))
|
|
1396 (save-excursion
|
|
1397 (if (/= (current-indentation) indent)
|
|
1398 (let ((beg (progn
|
|
1399 (beginning-of-line)
|
|
1400 (point))))
|
|
1401 (back-to-indentation)
|
|
1402 (delete-region beg (point))
|
|
1403 (indent-to indent))))
|
|
1404 (if (< (current-column) indent)
|
|
1405 (back-to-indentation))))
|
|
1406
|
|
1407 (defun LaTeX-fill-region-as-paragraph (from to &optional justify-flag)
|
|
1408 "Fill region as one paragraph: break lines to fit fill-column,
|
|
1409 but leave all lines ending with \\\\ (plus its optional argument) alone.
|
|
1410 Prefix arg means justify too.
|
|
1411 From program, pass args FROM, TO and JUSTIFY-FLAG."
|
|
1412 (interactive "*r\nP")
|
|
1413 (or (assoc (LaTeX-current-environment) LaTeX-indent-environment-list)
|
|
1414 (save-restriction
|
|
1415 (narrow-to-region from to)
|
|
1416 (goto-char from)
|
|
1417 (while (not (eobp))
|
|
1418 (LaTeX-indent-line)
|
|
1419 (forward-line))
|
|
1420 (goto-char from)
|
|
1421 (while (not (eobp))
|
|
1422 (if
|
|
1423 (re-search-forward (concat "^.*"
|
|
1424 (regexp-quote TeX-esc)
|
|
1425 (regexp-quote TeX-esc)
|
|
1426 "\\(\\s-*\\*\\)?"
|
|
1427 "\\(\\s-*\\[[^]]*\\]\\)?\\s-*$")
|
|
1428 nil t)
|
|
1429 (progn
|
|
1430 (goto-char (match-end 0))
|
|
1431 (delete-horizontal-space)
|
|
1432 ;; I doubt very much if we want justify -
|
|
1433 ;; this is a line with \\
|
|
1434 ;; if you think otherwise - uncomment the next line
|
|
1435 ;; (and justify-flag (justify-current-line))
|
|
1436 (forward-char)
|
|
1437 ;; keep our position in a buffer
|
|
1438 (save-excursion
|
|
1439 (LaTeX-fill-region-as-para-do
|
|
1440 from (match-beginning 0) justify-flag))
|
|
1441 (setq from (point)))
|
|
1442 ;; ELSE part follows - loop termination relies on a fact
|
|
1443 ;; that (LaTeX-fill-region-as-para-do) moves point past
|
|
1444 ;; the filled region
|
|
1445 (LaTeX-fill-region-as-para-do from to justify-flag)))
|
|
1446 ;; the following four lines are clearly optional, but I like my
|
|
1447 ;; LaTeX code that way
|
|
1448 (goto-char (point-min))
|
|
1449 (while (search-forward "$$ " nil t)
|
|
1450 (replace-match "$$\n" t t)
|
|
1451 (LaTeX-indent-line)))))
|
|
1452
|
|
1453 (defun LaTeX-fill-region-as-para-do (from to justify-flag)
|
|
1454 "Fill region as one paragraph: break lines to fit fill-column."
|
|
1455 (if (< from to)
|
|
1456 (progn
|
|
1457 ;; (save-restriction) here is likely not needed because
|
|
1458 ;; it was done by a caller, but I am not sure - mj
|
|
1459 (save-restriction
|
|
1460 (goto-char from)
|
|
1461 (skip-chars-forward " \n")
|
|
1462 (LaTeX-indent-line)
|
|
1463 (beginning-of-line)
|
|
1464 (narrow-to-region (point) to)
|
|
1465 (setq from (point))
|
|
1466
|
|
1467 ;; from is now before the text to fill,
|
|
1468 ;; but after any fill prefix on the first line.
|
|
1469
|
|
1470 ;; Make sure sentences ending at end of line get an extra space.
|
|
1471 (if (or (not (boundp 'sentence-end-double-space))
|
|
1472 sentence-end-double-space)
|
|
1473 (progn
|
|
1474 (goto-char from)
|
|
1475 (while (re-search-forward "[.?!][]})\"']*$" nil t)
|
|
1476 (insert ? ))))
|
|
1477 ;; The change all newlines to spaces.
|
|
1478 (subst-char-in-region from (point-max) ?\n ?\ )
|
|
1479 ;; Flush excess spaces, except in the paragraph indentation.
|
|
1480 (goto-char from)
|
|
1481 (skip-chars-forward " \t")
|
|
1482 (while (re-search-forward " *" nil t)
|
|
1483 (delete-region
|
|
1484 (+ (match-beginning 0)
|
|
1485 (if (save-excursion
|
|
1486 (skip-chars-backward " ]})\"'")
|
|
1487 (memq (preceding-char) '(?. ?? ?!)))
|
|
1488 2 1))
|
|
1489 (match-end 0)))
|
|
1490 (goto-char (point-max))
|
|
1491 (delete-horizontal-space)
|
|
1492 (insert " ")
|
|
1493 (goto-char (point-min))
|
|
1494 (let ((prefixcol 0))
|
|
1495 (while (not (eobp))
|
|
1496 (move-to-column (1+ fill-column))
|
|
1497 (if (eobp)
|
|
1498 nil
|
|
1499 (skip-chars-backward "^ \n")
|
|
1500 (if (if (zerop prefixcol)
|
|
1501 (bolp)
|
|
1502 (>= prefixcol (current-column)))
|
|
1503 (skip-chars-forward "^ \n")
|
|
1504 (forward-char -1)))
|
|
1505 (delete-horizontal-space)
|
|
1506 (if (equal (preceding-char) ?\\)
|
|
1507 (insert ? ))
|
|
1508 (insert ?\n)
|
|
1509 (LaTeX-indent-line)
|
|
1510 (setq prefixcol (current-column))
|
|
1511 (and justify-flag (not (eobp))
|
|
1512 (progn
|
|
1513 (forward-line -1)
|
|
1514 (justify-current-line)
|
|
1515 (forward-line 1)))
|
|
1516 )
|
|
1517 (goto-char (point-max))
|
|
1518 (delete-horizontal-space))))))
|
|
1519
|
|
1520 (defun LaTeX-fill-paragraph (prefix)
|
|
1521 "Fill and indent paragraph at or after point.
|
|
1522 Prefix arg means justify as well."
|
|
1523 (interactive "*P")
|
|
1524 (save-excursion
|
|
1525 (beginning-of-line)
|
|
1526 (if (looking-at "[ \t]*%]")
|
|
1527 (re-search-forward "^[ \t]*[^% \t\n]"))
|
|
1528 (forward-paragraph)
|
|
1529 (or (bolp) (newline 1))
|
|
1530 (and (eobp) (open-line 1))
|
|
1531 (let ((end (point-marker))
|
|
1532 (start (progn
|
|
1533 (backward-paragraph)
|
|
1534 (point))))
|
|
1535 (LaTeX-fill-region-as-paragraph start end prefix))))
|
|
1536
|
|
1537 (defun LaTeX-fill-region (from to &optional justify what)
|
|
1538 "Fill and indent each of the paragraphs in the region as LaTeX text.
|
|
1539 Prefix arg (non-nil third arg, if called from program)
|
|
1540 means justify as well. Fourth arg WHAT is a word to be displayed when
|
|
1541 formatting."
|
|
1542 (interactive "*r\nP")
|
|
1543 (save-restriction
|
|
1544 (save-excursion
|
|
1545 (let ((length (- to from))
|
|
1546 (to (set-marker (make-marker) to)))
|
|
1547 (goto-char from)
|
|
1548 (beginning-of-line)
|
|
1549 (while (< (point) to)
|
|
1550 (message "Formatting%s ... %d%%"
|
|
1551 (if (not what)
|
|
1552 ""
|
|
1553 what)
|
|
1554 (/ (* 100 (- (point) from)) length))
|
|
1555 (save-excursion (LaTeX-fill-paragraph justify))
|
|
1556 (forward-paragraph 2)
|
|
1557 (if (not (eobp))
|
|
1558 (backward-paragraph)))
|
|
1559 (set-marker to nil)))
|
|
1560 (message "Finished")))
|
|
1561
|
|
1562 (defun LaTeX-find-matching-end ()
|
|
1563 "Move point to the \\end of the current environment"
|
|
1564 (interactive)
|
|
1565 (let ((regexp (concat (regexp-quote TeX-esc) "\\(begin\\|end\\)\\b"))
|
|
1566 (level 1))
|
|
1567 (beginning-of-line 1)
|
|
1568 (if (looking-at (concat " *" (regexp-quote TeX-esc) "begin\\b"))
|
|
1569 (end-of-line 1))
|
|
1570 (while (and (> level 0) (re-search-forward regexp nil t))
|
|
1571 (if (= (char-after (1+ (match-beginning 0))) ?b);;begin
|
|
1572 (setq level (1+ level))
|
|
1573 (setq level (1- level))))
|
|
1574 (if (= level 0)
|
|
1575 (search-forward "}")
|
|
1576 (error "Can't locate end of current environment"))))
|
|
1577
|
|
1578 (defun LaTeX-find-matching-begin ()
|
|
1579 "Move point to the \\begin of the current environment"
|
|
1580 (interactive)
|
|
1581 (let ((regexp (concat (regexp-quote TeX-esc) "\\(begin\\|end\\)\\b"))
|
|
1582 (level 1))
|
|
1583 (beginning-of-line 1)
|
|
1584 (if (looking-at (concat " *" (regexp-quote TeX-esc) "begin\\b"))
|
|
1585 (end-of-line 1))
|
|
1586 (while (and (> level 0) (re-search-backward regexp nil t))
|
|
1587 (if (= (char-after (1+ (match-beginning 0))) ?e);;end
|
|
1588 (setq level (1+ level))
|
|
1589 (setq level (1- level))))
|
|
1590 (or (= level 0)
|
|
1591 (error "Can't locate beginning of current environment"))))
|
|
1592
|
|
1593 (defun LaTeX-mark-environment ()
|
|
1594 "Set mark to end of current environment and point to the matching begin
|
|
1595 will not work properly if there are unbalanced begin-end pairs in
|
|
1596 comments and verbatim environments"
|
|
1597 (interactive)
|
|
1598 (let ((cur (point)))
|
|
1599 (LaTeX-find-matching-end)
|
|
1600 (beginning-of-line 2)
|
|
1601 (set-mark (point))
|
|
1602 (goto-char cur)
|
|
1603 (LaTeX-find-matching-begin)
|
|
1604 (TeX-activate-region)))
|
|
1605
|
|
1606 (defun LaTeX-fill-environment (justify)
|
|
1607 "Fill and indent current environment as LaTeX text."
|
|
1608 (interactive "*P")
|
|
1609 (save-excursion
|
|
1610 (LaTeX-mark-environment)
|
|
1611 (re-search-forward "{\\([^}]+\\)}")
|
|
1612 (LaTeX-fill-region
|
|
1613 (region-beginning)
|
|
1614 (region-end)
|
|
1615 justify
|
|
1616 (concat " environment " (TeX-match-buffer 1)))))
|
|
1617
|
|
1618 (defun LaTeX-fill-section (justify)
|
|
1619 "Fill and indent current logical section as LaTeX text."
|
|
1620 (interactive "*P")
|
|
1621 (save-excursion
|
|
1622 (LaTeX-mark-section)
|
|
1623 (re-search-forward "{\\([^}]+\\)}")
|
|
1624 (LaTeX-fill-region
|
|
1625 (region-beginning)
|
|
1626 (region-end)
|
|
1627 justify
|
|
1628 (concat " section " (TeX-match-buffer 1)))))
|
|
1629
|
|
1630 (defun LaTeX-mark-section ()
|
|
1631 "Set mark at end of current logical section, and point at top."
|
|
1632 (interactive)
|
|
1633 (re-search-forward (concat "\\(" (LaTeX-outline-regexp)
|
|
1634 "\\|\\'\\)"))
|
|
1635 (re-search-backward "^")
|
|
1636 (set-mark (point))
|
|
1637 (re-search-backward (concat "\\(" (LaTeX-outline-regexp)
|
|
1638 "\\|\\`\\)"))
|
|
1639 (TeX-activate-region))
|
|
1640
|
|
1641 (defun LaTeX-fill-buffer (justify)
|
|
1642 "Fill and indent current buffer as LaTeX text."
|
|
1643 (interactive "*P")
|
|
1644 (save-excursion
|
|
1645 (LaTeX-fill-region
|
|
1646 (point-min)
|
|
1647 (point-max)
|
|
1648 justify
|
|
1649 (concat " buffer " (buffer-name)))))
|
|
1650
|
|
1651 (defvar LaTeX-indent-environment-list
|
|
1652 '(("verbatim" current-indentation)
|
|
1653 ("verbatim*" current-indentation)
|
|
1654 ;; The following should have there own, smart indentation function.
|
|
1655 ;; Some other day.
|
|
1656 ("alltt")
|
|
1657 ("array")
|
|
1658 ("displaymath")
|
|
1659 ("eqnarray")
|
|
1660 ("eqnarray*")
|
|
1661 ("equation")
|
|
1662 ("equation*")
|
|
1663 ("picture")
|
|
1664 ("tabbing")
|
|
1665 ("table")
|
|
1666 ("table*")
|
|
1667 ("tabular")
|
|
1668 ("tabular*"))
|
|
1669 "Alist of environments with special indentation.
|
|
1670 The second element in each entry is the function to calculate the
|
|
1671 indentation level in columns.")
|
|
1672
|
|
1673 (defvar LaTeX-indent-environment-check t
|
|
1674 "*If non-nil, check for any special environments.")
|
|
1675
|
|
1676 (defvar LaTeX-left-comment-regexp "%%%"
|
|
1677 "*Regexp matching comments that should be placed on the left margin.")
|
|
1678
|
|
1679 (defvar LaTeX-right-comment-regexp "%[^%]"
|
|
1680 "*Regexp matching comments that should be placed to the right margin.")
|
|
1681
|
|
1682 (defvar LaTeX-ignore-comment-regexp nil
|
|
1683 "*Regexp matching comments that whose indentation should not be touched.")
|
|
1684
|
|
1685 (defun LaTeX-indent-calculate ()
|
|
1686 ;; Return the correct indentation of line of LaTeX source. (I hope...)
|
|
1687 (save-excursion
|
|
1688 (back-to-indentation)
|
|
1689 (cond ((looking-at (concat (regexp-quote TeX-esc)
|
|
1690 "\\(begin\\|end\\){verbatim\\*?}"))
|
|
1691 ;; \end{verbatim} must be flush left, otherwise an unwanted
|
|
1692 ;; empty line appears in LaTeX's output.
|
|
1693 0)
|
|
1694 ((and LaTeX-left-comment-regexp
|
|
1695 (looking-at LaTeX-left-comment-regexp))
|
|
1696 ;; Comments to the left margin.
|
|
1697 0)
|
|
1698 ((and LaTeX-right-comment-regexp
|
|
1699 (looking-at LaTeX-right-comment-regexp))
|
|
1700 ;; Comments to the right margin.
|
|
1701 comment-column)
|
|
1702 ((and LaTeX-ignore-comment-regexp
|
|
1703 (looking-at LaTeX-ignore-comment-regexp))
|
|
1704 ;; Comments best left alone.
|
|
1705 (current-indentation))
|
|
1706 ((and LaTeX-indent-environment-check
|
|
1707 ;; Special environments.
|
|
1708 (let ((entry (assoc (LaTeX-current-environment)
|
|
1709 LaTeX-indent-environment-list)))
|
|
1710 (and entry
|
|
1711 (nth 1 entry)
|
|
1712 (funcall (nth 1 entry))))))
|
|
1713 ((looking-at (concat (regexp-quote TeX-esc) "end\\b"))
|
|
1714 ;; Backindent at \end.
|
|
1715 (- (LaTeX-indent-calculate-last) LaTeX-indent-level))
|
|
1716 ((looking-at (concat (regexp-quote TeX-esc) "right\\b"))
|
|
1717 ;; Backindent at \right.
|
|
1718 (- (LaTeX-indent-calculate-last) LaTeX-left-right-indent-level))
|
|
1719 ((looking-at (concat (regexp-quote TeX-esc) LaTeX-item-regexp))
|
|
1720 ;; Items.
|
|
1721 (+ (LaTeX-indent-calculate-last) LaTeX-item-indent))
|
|
1722 (t (LaTeX-indent-calculate-last)))))
|
|
1723
|
|
1724 (defvar LaTeX-left-right-indent-level LaTeX-indent-level
|
|
1725 "*The level of indentation produced by a \\left macro.")
|
|
1726
|
|
1727 (defun LaTeX-indent-level-count ()
|
|
1728 ;; Count indentation change caused by all \left, \right, \begin, and
|
|
1729 ;; \end commands in the current line.
|
|
1730 (save-excursion
|
|
1731 (save-restriction
|
|
1732 (let ((count 0))
|
|
1733 (narrow-to-region (point)
|
|
1734 (save-excursion
|
|
1735 (re-search-forward (concat "[^"
|
|
1736 (regexp-quote TeX-esc)
|
|
1737 "]%\\|\n\\|\\'"))
|
|
1738 (backward-char)
|
|
1739 (point)))
|
|
1740 (while (search-forward TeX-esc nil t)
|
|
1741 (cond
|
|
1742 ((looking-at "left\\b")
|
|
1743 (setq count (+ count LaTeX-left-right-indent-level)))
|
|
1744 ((looking-at "right\\b")
|
|
1745 (setq count (- count LaTeX-left-right-indent-level)))
|
|
1746 ((looking-at "begin\\b")
|
|
1747 (setq count (+ count LaTeX-indent-level)))
|
|
1748 ((looking-at "end\\b")
|
|
1749 (setq count (- count LaTeX-indent-level)))
|
|
1750 ((looking-at (regexp-quote TeX-esc))
|
|
1751 (forward-char 1))))
|
|
1752 count))))
|
|
1753
|
|
1754 (defun LaTeX-indent-calculate-last ()
|
|
1755 "Return the correct indentation of a normal line of text.
|
|
1756 The point is supposed to be at the beginning of the current line."
|
|
1757 (save-restriction
|
|
1758 (widen)
|
|
1759 (skip-chars-backward "\n\t ")
|
|
1760 (move-to-column (current-indentation))
|
|
1761
|
|
1762 ;; Ignore comments.
|
|
1763 (while (and (looking-at (regexp-quote comment-start)) (not (bobp)))
|
|
1764 (skip-chars-backward "\n\t ")
|
|
1765 (if (not (bobp))
|
|
1766 (move-to-column (current-indentation))))
|
|
1767
|
|
1768 (cond ((bobp) 0)
|
|
1769 ((looking-at (concat (regexp-quote TeX-esc) "begin{document}"))
|
|
1770 ;; I dislike having all of the document indented...
|
|
1771 (current-indentation))
|
|
1772 ((looking-at (concat (regexp-quote TeX-esc) "begin *"
|
|
1773 (regexp-quote TeX-grop)
|
|
1774 "verbatim\\*?"
|
|
1775 (regexp-quote TeX-grcl)))
|
|
1776 0)
|
|
1777 ((looking-at (concat (regexp-quote TeX-esc) "end"
|
|
1778 (regexp-quote TeX-grop)
|
|
1779 "verbatim\\*?"
|
|
1780 (regexp-quote TeX-grcl)))
|
|
1781 ;; If I see an \end{verbatim} in the previous line I skip
|
|
1782 ;; back to the preceding \begin{verbatim}.
|
|
1783 (save-excursion
|
|
1784 (if (re-search-backward (concat (regexp-quote TeX-esc)
|
|
1785 "begin *"
|
|
1786 (regexp-quote TeX-grop)
|
|
1787 "verbatim\\*?"
|
|
1788 (regexp-quote TeX-grcl)) 0 t)
|
|
1789 (LaTeX-indent-calculate-last)
|
|
1790 0)))
|
|
1791 (t (+ (current-indentation)
|
|
1792 (TeX-brace-count-line)
|
|
1793 (LaTeX-indent-level-count)
|
|
1794 (cond ((looking-at (concat (regexp-quote TeX-esc) "end\\b"))
|
|
1795 LaTeX-indent-level)
|
|
1796 ((looking-at (concat (regexp-quote TeX-esc) "right\\b"))
|
|
1797 LaTeX-left-right-indent-level)
|
|
1798 ((looking-at (concat (regexp-quote TeX-esc)
|
|
1799 LaTeX-item-regexp))
|
|
1800 (- LaTeX-item-indent))
|
|
1801 (t 0)))))))
|
|
1802
|
|
1803 ;;; Math Minor Mode
|
|
1804
|
|
1805 (defvar LaTeX-math-list nil
|
|
1806 "AList of your personal LaTeX math symbols.
|
|
1807
|
|
1808 Each entry should be a list with three elements, KEY, VALUE, and MENU.
|
|
1809 KEY is the key to be redefined (under `LaTeX-math-abbrev-prefix' in
|
|
1810 math minor mode, VALUE can be a string with the name of the macro to
|
|
1811 be inserted, or a function to be called. The optional third element is
|
|
1812 the name of the submenu where the command should be added.
|
|
1813
|
|
1814 See also `LaTeX-math-menu'.")
|
|
1815
|
|
1816 (defconst LaTeX-math-default
|
|
1817 '((?a "alpha" "greek")
|
|
1818 (?b "beta" "greek")
|
|
1819 (?c LaTeX-math-cal "Cal-whatever")
|
|
1820 (?d "delta" "greek")
|
|
1821 (?e "epsilon" "greek")
|
|
1822 (?f "phi" "greek")
|
|
1823 (?g "gamma" "greek")
|
|
1824 (?h "eta" "greek")
|
|
1825 (?k "kappa" "greek")
|
|
1826 (?l "lambda" "greek")
|
|
1827 (?m "mu" "greek")
|
|
1828 (?N "nabla" "greek")
|
|
1829 (?n "nu" "greek")
|
|
1830 (?o "omega" "greek")
|
|
1831 (?p "pi" "greek")
|
|
1832 (?q "theta" "greek")
|
|
1833 (?r "rho" "greek")
|
|
1834 (?s "sigma" "greek")
|
|
1835 (?t "tau" "greek")
|
|
1836 (?u "upsilon" "greek")
|
|
1837 (?x "chi" "greek")
|
|
1838 (?y "psi" "greek")
|
|
1839 (?z "zeta" "greek")
|
|
1840 (?D "Delta" "Greek")
|
|
1841 (?F "Phi" "Greek")
|
|
1842 (?G "Gamma" "Greek")
|
|
1843 (?Q "Theta" "Greek")
|
|
1844 (?L "Lambda" "Greek")
|
|
1845 (?Y "Psi" "Greek")
|
|
1846 (?P "Pi" "Greek")
|
|
1847 (?S "Sigma" "Greek")
|
|
1848 (?U "Upsilon" "Greek")
|
|
1849 (?O "Omega" "Greek")
|
|
1850 (nil "pm" "Binary Op")
|
|
1851 (nil "mp" "Binary Op")
|
|
1852 (?* "times" "Binary Op")
|
|
1853 (nil "div" "Binary Op")
|
|
1854 (nil "ast" "Binary Op")
|
|
1855 (nil "star" "Binary Op")
|
|
1856 (nil "circ" "Binary Op")
|
|
1857 (nil "bullet" "Binary Op")
|
|
1858 (?. "cdot" "Binary Op")
|
|
1859 (?- "cap" "Binary Op")
|
|
1860 (?+ "cup" "Binary Op")
|
|
1861 (nil "uplus" "Binary Op")
|
|
1862 (nil "sqcap" "Binary Op")
|
|
1863 (?| "vee" "Binary Op")
|
|
1864 (?& "wedge" "Binary Op")
|
|
1865 (?\\ "setminus" "Binary Op")
|
|
1866 (nil "wr" "Binary Op")
|
|
1867 (nil "diamond" "Binary Op")
|
|
1868 (nil "bigtriangleup" "Binary Op")
|
|
1869 (nil "bigtriangledown" "Binary Op")
|
|
1870 (nil "triangleleft" "Binary Op")
|
|
1871 (nil "triangleright" "Binary Op")
|
|
1872 (nil "lhd" "Binary Op")
|
|
1873 (nil "rhd" "Binary Op")
|
|
1874 (nil "unlhd" "Binary Op")
|
|
1875 (nil "unrhd" "Binary Op")
|
|
1876 (nil "oplus" "Binary Op")
|
|
1877 (nil "ominus" "Binary Op")
|
|
1878 (nil "otimes" "Binary Op")
|
|
1879 (nil "oslash" "Binary Op")
|
|
1880 (nil "odot" "Binary Op")
|
|
1881 (nil "bigcirc" "Binary Op")
|
|
1882 (nil "dagger" "Binary Op")
|
|
1883 (nil "ddagger" "Binary Op")
|
|
1884 (nil "amalg" "Binary Op")
|
|
1885 (?< "leq" "Relational")
|
|
1886 (?> "geq" "Relational")
|
|
1887 (nil "qed" "Relational")
|
|
1888 (nil "equiv" "Relational")
|
|
1889 (nil "models" "Relational")
|
|
1890 (nil "prec" "Relational")
|
|
1891 (nil "succ" "Relational")
|
|
1892 (nil "sim" "Relational")
|
|
1893 (nil "perp" "Relational")
|
|
1894 (nil "preceq" "Relational")
|
|
1895 (nil "succeq" "Relational")
|
|
1896 (nil "simeq" "Relational")
|
|
1897 (nil "mid" "Relational")
|
|
1898 (nil "ll" "Relational")
|
|
1899 (nil "gg" "Relational")
|
|
1900 (nil "asymp" "Relational")
|
|
1901 (nil "parallel" "Relational")
|
|
1902 (?{ "subset" "Relational")
|
|
1903 (?} "supset" "Relational")
|
|
1904 (nil "approx" "Relational")
|
|
1905 (nil "bowtie" "Relational")
|
|
1906 (?\[ "subseteq" "Relational")
|
|
1907 (?\] "supseteq" "Relational")
|
|
1908 (nil "cong" "Relational")
|
|
1909 (nil "Join" "Relational")
|
|
1910 (nil "sqsubset" "Relational")
|
|
1911 (nil "sqsupset" "Relational")
|
|
1912 (nil "neq" "Relational")
|
|
1913 (nil "smile" "Relational")
|
|
1914 (nil "sqsubseteq" "Relational")
|
|
1915 (nil "sqsupseteq" "Relational")
|
|
1916 (nil "doteq" "Relational")
|
|
1917 (nil "frown" "Relational")
|
|
1918 (?i "in" "Relational")
|
|
1919 (nil "ni" "Relational")
|
|
1920 (nil "propto" "Relational")
|
|
1921 (nil "vdash" "Relational")
|
|
1922 (nil "dashv" "Relational")
|
|
1923 (?\C-b "leftarrow" "Arrows")
|
|
1924 (nil "Leftarrow" "Arrows")
|
|
1925 (?\C-f "rightarrow" "Arrows")
|
|
1926 (nil "Rightarrow" "Arrows")
|
|
1927 (nil "leftrightarrow" "Arrows")
|
|
1928 (nil "Leftrightarrow" "Arrows")
|
|
1929 (nil "mapsto" "Arrows")
|
|
1930 (nil "hookleftarrow" "Arrows")
|
|
1931 (nil "leftharpoonup" "Arrows")
|
|
1932 (nil "leftharpoondown" "Arrows")
|
|
1933 (nil "longleftarrow" "Arrows")
|
|
1934 (nil "Longleftarrow" "Arrows")
|
|
1935 (nil "longrightarrow" "Arrows")
|
|
1936 (nil "Longrightarrow" "Arrows")
|
|
1937 (nil "longleftrightarrow" "Arrows")
|
|
1938 (nil "Longleftrightarrow" "Arrows")
|
|
1939 (nil "longmapsto" "Arrows")
|
|
1940 (nil "hookrightarrow" "Arrows")
|
|
1941 (nil "rightharpoonup" "Arrows")
|
|
1942 (nil "rightharpoondown" "Arrows")
|
|
1943 (?\C-p "uparrow" "Arrows")
|
|
1944 (nil "Uparrow" "Arrows")
|
|
1945 (?\C-n "downarrow" "Arrows")
|
|
1946 (nil "Downarrow" "Arrows")
|
|
1947 (nil "updownarrow" "Arrows")
|
|
1948 (nil "Updownarrow" "Arrows")
|
|
1949 (nil "nearrow" "Arrows")
|
|
1950 (nil "searrow" "Arrows")
|
|
1951 (nil "swarrow" "Arrows")
|
|
1952 (nil "nwarrow" "Arrows")
|
|
1953 (nil "ldots" "Misc Symbol")
|
|
1954 (nil "cdots" "Misc Symbol")
|
|
1955 (nil "vdots" "Misc Symbol")
|
|
1956 (nil "ddots" "Misc Symbol")
|
|
1957 (nil "aleph" "Misc Symbol")
|
|
1958 (nil "prime" "Misc Symbol")
|
|
1959 (?A "forall" "Misc Symbol")
|
|
1960 (?I "infty" "Misc Symbol")
|
|
1961 (nil "hbar" "Misc Symbol")
|
|
1962 (?0 "emptyset" "Misc Symbol")
|
|
1963 (?E "exists" "Misc Symbol")
|
|
1964 (nil "nabla" "Misc Symbol")
|
|
1965 (nil "surd" "Misc Symbol")
|
|
1966 (nil "Box" "Misc Symbol")
|
|
1967 (nil "triangle" "Misc Symbol")
|
|
1968 (nil "Diamond" "Misc Symbol")
|
|
1969 (nil "imath" "Misc Symbol")
|
|
1970 (nil "jmath" "Misc Symbol")
|
|
1971 (nil "ell" "Misc Symbol")
|
|
1972 (nil "neg" "Misc Symbol")
|
|
1973 (?/ "not" "Misc Symbol")
|
|
1974 (nil "top" "Misc Symbol")
|
|
1975 (nil "flat" "Misc Symbol")
|
|
1976 (nil "natural" "Misc Symbol")
|
|
1977 (nil "sharp" "Misc Symbol")
|
|
1978 (nil "wp" "Misc Symbol")
|
|
1979 (nil "bot" "Misc Symbol")
|
|
1980 (nil "clubsuit" "Misc Symbol")
|
|
1981 (nil "diamondsuit" "Misc Symbol")
|
|
1982 (nil "heartsuit" "Misc Symbol")
|
|
1983 (nil "spadesuit" "Misc Symbol")
|
|
1984 (nil "mho" "Misc Symbol")
|
|
1985 (nil "Re" "Misc Symbol")
|
|
1986 (nil "Im" "Misc Symbol")
|
|
1987 (nil "angle" "Misc Symbol")
|
|
1988 (nil "partial" "Misc Symbol")
|
|
1989 (nil "sum" "Var Symbol")
|
|
1990 (nil "prod" "Var Symbol")
|
|
1991 (nil "coprod" "Var Symbol")
|
|
1992 (nil "int" "Var Symbol")
|
|
1993 (nil "oint" "Var Symbol")
|
|
1994 (nil "bigcap" "Var Symbol")
|
|
1995 (nil "bigcup" "Var Symbol")
|
|
1996 (nil "bigsqcup" "Var Symbol")
|
|
1997 (nil "bigvee" "Var Symbol")
|
|
1998 (nil "bigwedge" "Var Symbol")
|
|
1999 (nil "bigodot" "Var Symbol")
|
|
2000 (nil "bigotimes" "Var Symbol")
|
|
2001 (nil "bigoplus" "Var Symbol")
|
|
2002 (nil "biguplus" "Var Symbol")
|
|
2003 (nil "arccos" "Log-like")
|
|
2004 (nil "arcsin" "Log-like")
|
|
2005 (nil "arctan" "Log-like")
|
|
2006 (nil "arg" "Log-like")
|
|
2007 (?\C-c "cos" "Log-like")
|
|
2008 (nil "cosh" "Log-like")
|
|
2009 (nil "cot" "Log-like")
|
|
2010 (nil "coth" "Log-like")
|
|
2011 (nil "csc" "Log-like")
|
|
2012 (nil "deg" "Log-like")
|
|
2013 (?\C-d "det" "Log-like")
|
|
2014 (nil "dim" "Log-like")
|
|
2015 (?\C-e "exp" "Log-like")
|
|
2016 (nil "gcd" "Log-like")
|
|
2017 (nil "hom" "Log-like")
|
|
2018 (?\C-_ "inf" "Log-like")
|
|
2019 (nil "ker" "Log-like")
|
|
2020 (nil "lg" "Log-like")
|
|
2021 (?\C-l "lim" "Log-like")
|
|
2022 (nil "liminf" "Log-like")
|
|
2023 (nil "limsup" "Log-like")
|
|
2024 (nil "ln" "Log-like")
|
|
2025 (nil "log" "Log-like")
|
|
2026 (nil "max" "Log-like")
|
|
2027 (nil "min" "Log-like")
|
|
2028 (nil "Pr" "Log-like")
|
|
2029 (nil "sec" "Log-like")
|
|
2030 (?\C-s "sin" "Log-like")
|
|
2031 (nil "sinh" "Log-like")
|
|
2032 (?\C-^ "sup" "Log-like")
|
|
2033 (?\C-t "tan" "Log-like")
|
|
2034 (nil "tanh" "Log-like")
|
|
2035 (nil "uparrow" "delimiters")
|
|
2036 (nil "Uparrow" "delimiters")
|
|
2037 (nil "downarrow" "delimiters")
|
|
2038 (nil "Downarrow" "delimiters")
|
|
2039 (nil "{" "delimiters")
|
|
2040 (nil "}" "delimiters")
|
|
2041 (nil "updownarrow" "delimiters")
|
|
2042 (nil "Updownarrow" "delimiters")
|
|
2043 (nil "lfloor" "delimiters")
|
|
2044 (nil "rfloor" "delimiters")
|
|
2045 (nil "lceil" "delimiters")
|
|
2046 (nil "rceil" "delimiters")
|
|
2047 (?\( "langle" "delimiters")
|
|
2048 (?\) "rangle" "delimiters")
|
|
2049 (nil "backslash" "delimiters")
|
|
2050 (nil "|" "delimiters")
|
|
2051 (nil "rmoustache" "Delimiters")
|
|
2052 (nil "lmoustache" "Delimiters")
|
|
2053 (nil "rgroup" "Delimiters")
|
|
2054 (nil "lgroup" "Delimiters")
|
|
2055 (nil "arrowvert" "Delimiters")
|
|
2056 (nil "Arrowvert" "Delimiters")
|
|
2057 (nil "bracevert" "Delimiters")
|
|
2058 (nil "widetilde" "Constructs")
|
|
2059 (nil "widehat" "Constructs")
|
|
2060 (nil "overleftarrow" "Constructs")
|
|
2061 (nil "overrightarrow" "Constructs")
|
|
2062 (nil "overline" "Constructs")
|
|
2063 (nil "underline" "Constructs")
|
|
2064 (nil "overbrace" "Constructs")
|
|
2065 (nil "underbrace" "Constructs")
|
|
2066 (nil "sqrt" "Constructs")
|
|
2067 (nil "frac" "Constructs")
|
|
2068 (?^ "hat" "Accents")
|
|
2069 (nil "acute" "Accents")
|
|
2070 (nil "bar" "Accents")
|
|
2071 (nil "dot" "Accents")
|
|
2072 (nil "breve" "Accents")
|
|
2073 (nil "check" "Accents")
|
|
2074 (nil "grave" "Accents")
|
|
2075 (nil "vec" "Accents")
|
|
2076 (nil "ddot" "Accents")
|
|
2077 (?~ "tilde" "Accents")
|
|
2078 (nil "ulcorner" ("AMS" "Hebrew"))
|
|
2079 (nil "urcorner" ("AMS" "Hebrew"))
|
|
2080 (nil "llcorner" ("AMS" "Hebrew"))
|
|
2081 (nil "lrcorner" ("AMS" "Hebrew"))
|
|
2082 (nil "dashrightarrow" ("AMS" "Arrows"))
|
|
2083 (nil "dashleftarrow" ("AMS" "Arrows"))
|
|
2084 (nil "leftleftarrows" ("AMS" "Arrows"))
|
|
2085 (nil "leftrightarrows" ("AMS" "Arrows"))
|
|
2086 (nil "Lleftarrow" ("AMS" "Arrows"))
|
|
2087 (nil "twoheadleftarrow" ("AMS" "Arrows"))
|
|
2088 (nil "leftarrowtail" ("AMS" "Arrows"))
|
|
2089 (nil "looparrowleft" ("AMS" "Arrows"))
|
|
2090 (nil "leftrightharpoons" ("AMS" "Arrows"))
|
|
2091 (nil "curvearrowleft" ("AMS" "Arrows"))
|
|
2092 (nil "circlearrowleft" ("AMS" "Arrows"))
|
|
2093 (nil "Lsh" ("AMS" "Arrows"))
|
|
2094 (nil "upuparrows" ("AMS" "Arrows"))
|
|
2095 (nil "upharpoonleft" ("AMS" "Arrows"))
|
|
2096 (nil "downharpoonleft" ("AMS" "Arrows"))
|
|
2097 (nil "multimap" ("AMS" "Arrows"))
|
|
2098 (nil "leftrightsquigarrow" ("AMS" "Arrows"))
|
|
2099 (nil "looparrowright" ("AMS" "Arrows"))
|
|
2100 (nil "rightleftharpoons" ("AMS" "Arrows"))
|
|
2101 (nil "curvearrowright" ("AMS" "Arrows"))
|
|
2102 (nil "circlearrowright" ("AMS" "Arrows"))
|
|
2103 (nil "Rsh" ("AMS" "Arrows"))
|
|
2104 (nil "downdownarrows" ("AMS" "Arrows"))
|
|
2105 (nil "upharpoonright" ("AMS" "Arrows"))
|
|
2106 (nil "downharpoonright" ("AMS" "Arrows"))
|
|
2107 (nil "rightsquigarrow" ("AMS" "Arrows"))
|
|
2108 (nil "nleftarrow" ("AMS" "Neg Arrows"))
|
|
2109 (nil "nrightarrow" ("AMS" "Neg Arrows"))
|
|
2110 (nil "nLeftarrow" ("AMS" "Neg Arrows"))
|
|
2111 (nil "nRightarrow" ("AMS" "Neg Arrows"))
|
|
2112 (nil "nleftrightarrow" ("AMS" "Neg Arrows"))
|
|
2113 (nil "nLeftrightarrow" ("AMS" "Neg Arrows"))
|
|
2114 (nil "leqq" ("AMS" "Relational I"))
|
|
2115 (nil "leqslant" ("AMS" "Relational I"))
|
|
2116 (nil "eqslantless" ("AMS" "Relational I"))
|
|
2117 (nil "lesssim" ("AMS" "Relational I"))
|
|
2118 (nil "lessapprox" ("AMS" "Relational I"))
|
|
2119 (nil "approxeq" ("AMS" "Relational I"))
|
|
2120 (nil "lessdot" ("AMS" "Relational I"))
|
|
2121 (nil "lll" ("AMS" "Relational I"))
|
|
2122 (nil "lessgtr" ("AMS" "Relational I"))
|
|
2123 (nil "lesseqgtr" ("AMS" "Relational I"))
|
|
2124 (nil "lesseqqgtr" ("AMS" "Relational I"))
|
|
2125 (nil "doteqdot" ("AMS" "Relational I"))
|
|
2126 (nil "risingdotseq" ("AMS" "Relational I"))
|
|
2127 (nil "fallingdotseq" ("AMS" "Relational I"))
|
|
2128 (nil "backsim" ("AMS" "Relational I"))
|
|
2129 (nil "backsimeq" ("AMS" "Relational I"))
|
|
2130 (nil "subseteqq" ("AMS" "Relational I"))
|
|
2131 (nil "Subset" ("AMS" "Relational I"))
|
|
2132 (nil "sqsubset" ("AMS" "Relational I"))
|
|
2133 (nil "preccurlyeq" ("AMS" "Relational I"))
|
|
2134 (nil "curlyeqprec" ("AMS" "Relational I"))
|
|
2135 (nil "precsim" ("AMS" "Relational I"))
|
|
2136 (nil "precapprox" ("AMS" "Relational I"))
|
|
2137 (nil "vartriangleleft" ("AMS" "Relational I"))
|
|
2138 (nil "trianglelefteq" ("AMS" "Relational I"))
|
|
2139 (nil "vDash" ("AMS" "Relational I"))
|
|
2140 (nil "Vvdash" ("AMS" "Relational I"))
|
|
2141 (nil "smallsmile" ("AMS" "Relational I"))
|
|
2142 (nil "smallfrown" ("AMS" "Relational I"))
|
|
2143 (nil "bumpeq" ("AMS" "Relational I"))
|
|
2144 (nil "Bumpeq" ("AMS" "Relational I"))
|
|
2145 (nil "geqq" ("AMS" "Relational II"))
|
|
2146 (nil "geqslant" ("AMS" "Relational II"))
|
|
2147 (nil "eqslantgtr" ("AMS" "Relational II"))
|
|
2148 (nil "gtrsim" ("AMS" "Relational II"))
|
|
2149 (nil "gtrapprox" ("AMS" "Relational II"))
|
|
2150 (nil "gtrdot" ("AMS" "Relational II"))
|
|
2151 (nil "ggg" ("AMS" "Relational II"))
|
|
2152 (nil "gtrless" ("AMS" "Relational II"))
|
|
2153 (nil "gtreqless" ("AMS" "Relational II"))
|
|
2154 (nil "gtreqqless" ("AMS" "Relational II"))
|
|
2155 (nil "eqcirc" ("AMS" "Relational II"))
|
|
2156 (nil "circeq" ("AMS" "Relational II"))
|
|
2157 (nil "triangleq" ("AMS" "Relational II"))
|
|
2158 (nil "thicksim" ("AMS" "Relational II"))
|
|
2159 (nil "thickapprox" ("AMS" "Relational II"))
|
|
2160 (nil "supseteqq" ("AMS" "Relational II"))
|
|
2161 (nil "Supset" ("AMS" "Relational II"))
|
|
2162 (nil "sqsupset" ("AMS" "Relational II"))
|
|
2163 (nil "succcurlyeq" ("AMS" "Relational II"))
|
|
2164 (nil "curlyeqsucc" ("AMS" "Relational II"))
|
|
2165 (nil "succsim" ("AMS" "Relational II"))
|
|
2166 (nil "succapprox" ("AMS" "Relational II"))
|
|
2167 (nil "vartriangleright" ("AMS" "Relational II"))
|
|
2168 (nil "trianglerighteq" ("AMS" "Relational II"))
|
|
2169 (nil "Vdash" ("AMS" "Relational II"))
|
|
2170 (nil "shortmid" ("AMS" "Relational II"))
|
|
2171 (nil "shortparallel" ("AMS" "Relational II"))
|
|
2172 (nil "between" ("AMS" "Relational II"))
|
|
2173 (nil "pitchfork" ("AMS" "Relational II"))
|
|
2174 (nil "varpropto" ("AMS" "Relational II"))
|
|
2175 (nil "blacktriangleleft" ("AMS" "Relational II"))
|
|
2176 (nil "therefore" ("AMS" "Relational II"))
|
|
2177 (nil "backepsilon" ("AMS" "Relational II"))
|
|
2178 (nil "blacktriangleright" ("AMS" "Relational II"))
|
|
2179 (nil "because" ("AMS" "Relational II"))
|
|
2180 (nil "nless" ("AMS" "Neg Rel I"))
|
|
2181 (nil "nleq" ("AMS" "Neg Rel I"))
|
|
2182 (nil "nleqslant" ("AMS" "Neg Rel I"))
|
|
2183 (nil "nleqq" ("AMS" "Neg Rel I"))
|
|
2184 (nil "lneq" ("AMS" "Neg Rel I"))
|
|
2185 (nil "lneqq" ("AMS" "Neg Rel I"))
|
|
2186 (nil "lvertneqq" ("AMS" "Neg Rel I"))
|
|
2187 (nil "lnsim" ("AMS" "Neg Rel I"))
|
|
2188 (nil "lnapprox" ("AMS" "Neg Rel I"))
|
|
2189 (nil "nprec" ("AMS" "Neg Rel I"))
|
|
2190 (nil "npreceq" ("AMS" "Neg Rel I"))
|
|
2191 (nil "precnsim" ("AMS" "Neg Rel I"))
|
|
2192 (nil "precnapprox" ("AMS" "Neg Rel I"))
|
|
2193 (nil "nsim" ("AMS" "Neg Rel I"))
|
|
2194 (nil "nshortmid" ("AMS" "Neg Rel I"))
|
|
2195 (nil "nmid" ("AMS" "Neg Rel I"))
|
|
2196 (nil "nvdash" ("AMS" "Neg Rel I"))
|
|
2197 (nil "nvDash" ("AMS" "Neg Rel I"))
|
|
2198 (nil "ntriangleleft" ("AMS" "Neg Rel I"))
|
|
2199 (nil "ntrianglelefteq" ("AMS" "Neg Rel I"))
|
|
2200 (nil "nsubseteq" ("AMS" "Neg Rel I"))
|
|
2201 (nil "subsetneq" ("AMS" "Neg Rel I"))
|
|
2202 (nil "varsubsetneq" ("AMS" "Neg Rel I"))
|
|
2203 (nil "subsetneqq" ("AMS" "Neg Rel I"))
|
|
2204 (nil "varsubsetneqq" ("AMS" "Neg Rel I"))
|
|
2205 (nil "ngtr" ("AMS" "Neg Rel II"))
|
|
2206 (nil "ngeq" ("AMS" "Neg Rel II"))
|
|
2207 (nil "ngeqslant" ("AMS" "Neg Rel II"))
|
|
2208 (nil "ngeqq" ("AMS" "Neg Rel II"))
|
|
2209 (nil "gneq" ("AMS" "Neg Rel II"))
|
|
2210 (nil "gneqq" ("AMS" "Neg Rel II"))
|
|
2211 (nil "gvertneqq" ("AMS" "Neg Rel II"))
|
|
2212 (nil "gnsim" ("AMS" "Neg Rel II"))
|
|
2213 (nil "gnapprox" ("AMS" "Neg Rel II"))
|
|
2214 (nil "nsucc" ("AMS" "Neg Rel II"))
|
|
2215 (nil "nsucceq" ("AMS" "Neg Rel II"))
|
|
2216 (nil "succnsim" ("AMS" "Neg Rel II"))
|
|
2217 (nil "succnapprox" ("AMS" "Neg Rel II"))
|
|
2218 (nil "ncong" ("AMS" "Neg Rel II"))
|
|
2219 (nil "nshortparallel" ("AMS" "Neg Rel II"))
|
|
2220 (nil "nparallel" ("AMS" "Neg Rel II"))
|
|
2221 (nil "nvDash" ("AMS" "Neg Rel II"))
|
|
2222 (nil "nVDash" ("AMS" "Neg Rel II"))
|
|
2223 (nil "ntriangleright" ("AMS" "Neg Rel II"))
|
|
2224 (nil "ntrianglerighteq" ("AMS" "Neg Rel II"))
|
|
2225 (nil "nsupseteq" ("AMS" "Neg Rel II"))
|
|
2226 (nil "nsupseteqq" ("AMS" "Neg Rel II"))
|
|
2227 (nil "supsetneq" ("AMS" "Neg Rel II"))
|
|
2228 (nil "varsupsetneq" ("AMS" "Neg Rel II"))
|
|
2229 (nil "supsetneqq" ("AMS" "Neg Rel II"))
|
|
2230 (nil "varsupsetneqq" ("AMS" "Neg Rel II"))
|
|
2231 (nil "dotplus" ("AMS" "Binary Op"))
|
|
2232 (nil "smallsetminus" ("AMS" "Binary Op"))
|
|
2233 (nil "Cap" ("AMS" "Binary Op"))
|
|
2234 (nil "Cup" ("AMS" "Binary Op"))
|
|
2235 (nil "barwedge" ("AMS" "Binary Op"))
|
|
2236 (nil "veebar" ("AMS" "Binary Op"))
|
|
2237 (nil "doublebarwedge" ("AMS" "Binary Op"))
|
|
2238 (nil "boxminus" ("AMS" "Binary Op"))
|
|
2239 (nil "boxtimes" ("AMS" "Binary Op"))
|
|
2240 (nil "boxdot" ("AMS" "Binary Op"))
|
|
2241 (nil "boxplus" ("AMS" "Binary Op"))
|
|
2242 (nil "divideontimes" ("AMS" "Binary Op"))
|
|
2243 (nil "ltimes" ("AMS" "Binary Op"))
|
|
2244 (nil "rtimes" ("AMS" "Binary Op"))
|
|
2245 (nil "leftthreetimes" ("AMS" "Binary Op"))
|
|
2246 (nil "rightthreetimes" ("AMS" "Binary Op"))
|
|
2247 (nil "curlywedge" ("AMS" "Binary Op"))
|
|
2248 (nil "curlyvee" ("AMS" "Binary Op"))
|
|
2249 (nil "circleddash" ("AMS" "Binary Op"))
|
|
2250 (nil "circledast" ("AMS" "Binary Op"))
|
|
2251 (nil "circledcirc" ("AMS" "Binary Op"))
|
|
2252 (nil "centerdot" ("AMS" "Binary Op"))
|
|
2253 (nil "intercal" ("AMS" "Binary Op"))
|
|
2254 (nil "hbar" ("AMS" "Misc"))
|
|
2255 (nil "hslash" ("AMS" "Misc"))
|
|
2256 (nil "vartriangle" ("AMS" "Misc"))
|
|
2257 (nil "triangledown" ("AMS" "Misc"))
|
|
2258 (nil "square" ("AMS" "Misc"))
|
|
2259 (nil "lozenge" ("AMS" "Misc"))
|
|
2260 (nil "circledS" ("AMS" "Misc"))
|
|
2261 (nil "angle" ("AMS" "Misc"))
|
|
2262 (nil "measuredangle" ("AMS" "Misc"))
|
|
2263 (nil "nexists" ("AMS" "Misc"))
|
|
2264 (nil "mho" ("AMS" "Misc"))
|
|
2265 (nil "Finv" ("AMS" "Misc"))
|
|
2266 (nil "Game" ("AMS" "Misc"))
|
|
2267 (nil "Bbbk" ("AMS" "Misc"))
|
|
2268 (nil "backprime" ("AMS" "Misc"))
|
|
2269 (nil "varnothing" ("AMS" "Misc"))
|
|
2270 (nil "blacktriangle" ("AMS" "Misc"))
|
|
2271 (nil "blacktriangledown" ("AMS" "Misc"))
|
|
2272 (nil "blacksquare" ("AMS" "Misc"))
|
|
2273 (nil "blacklozenge" ("AMS" "Misc"))
|
|
2274 (nil "bigstar" ("AMS" "Misc"))
|
|
2275 (nil "sphericalangle" ("AMS" "Misc"))
|
|
2276 (nil "complement" ("AMS" "Misc"))
|
|
2277 (nil "eth" ("AMS" "Misc"))
|
|
2278 (nil "diagup" ("AMS" "Misc"))
|
|
2279 (nil "diagdown" ("AMS" "Misc"))
|
|
2280 (nil "Hat" ("AMS" "Accents"))
|
|
2281 (nil "Check" ("AMS" "Accents"))
|
|
2282 (nil "Tilde" ("AMS" "Accents"))
|
|
2283 (nil "Acute" ("AMS" "Accents"))
|
|
2284 (nil "Grave" ("AMS" "Accents"))
|
|
2285 (nil "Dot" ("AMS" "Accents"))
|
|
2286 (nil "Ddot" ("AMS" "Accents"))
|
|
2287 (nil "Breve" ("AMS" "Accents"))
|
|
2288 (nil "Bar" ("AMS" "Accents"))
|
|
2289 (nil "Vec" ("AMS" "Accents"))
|
|
2290 (nil "dddot" ("AMS" "Accents"))
|
|
2291 (nil "ddddot" ("AMS" "Accents"))
|
|
2292 (nil "bigl" ("AMS" "Delimiters"))
|
|
2293 (nil "bigr" ("AMS" "Delimiters"))
|
|
2294 (nil "Bigl" ("AMS" "Delimiters"))
|
|
2295 (nil "Bigr" ("AMS" "Delimiters"))
|
|
2296 (nil "biggl" ("AMS" "Delimiters"))
|
|
2297 (nil "biggr" ("AMS" "Delimiters"))
|
|
2298 (nil "Biggl" ("AMS" "Delimiters"))
|
|
2299 (nil "Biggr" ("AMS" "Delimiters"))
|
|
2300 (nil "lvert" ("AMS" "Delimiters"))
|
|
2301 (nil "rvert" ("AMS" "Delimiters"))
|
|
2302 (nil "lVert" ("AMS" "Delimiters"))
|
|
2303 (nil "rVert" ("AMS" "Delimiters"))
|
|
2304 (nil "nobreakdash" ("AMS" "Special"))
|
|
2305 (nil "leftroot" ("AMS" "Special"))
|
|
2306 (nil "uproot" ("AMS" "Special"))
|
|
2307 (nil "accentedsymbol" ("AMS" "Special"))
|
|
2308 (nil "xleftarrow" ("AMS" "Special"))
|
|
2309 (nil "xrightarrow" ("AMS" "Special"))
|
|
2310 (nil "overset" ("AMS" "Special"))
|
|
2311 (nil "underset" ("AMS" "Special"))
|
|
2312 (nil "dfrac" ("AMS" "Special"))
|
|
2313 (nil "genfrac" ("AMS" "Special"))
|
|
2314 (nil "tfrac" ("AMS" "Special"))
|
|
2315 (nil "binom" ("AMS" "Special"))
|
|
2316 (nil "dbinom" ("AMS" "Special"))
|
|
2317 (nil "tbinom" ("AMS" "Special"))
|
|
2318 (nil "smash" ("AMS" "Special"))
|
|
2319 (nil "eucal" ("AMS" "Special"))
|
|
2320 (nil "boldsymbol" ("AMS" "Special"))
|
|
2321 (nil "text" ("AMS" "Special"))
|
|
2322 (nil "intertext" ("AMS" "Special"))
|
|
2323 (nil "substack" ("AMS" "Special"))
|
|
2324 (nil "subarray" ("AMS" "Special"))
|
|
2325 (nil "sideset" ("AMS" "Special"))))
|
|
2326
|
|
2327 (defvar LaTeX-math-abbrev-prefix "`"
|
|
2328 "Prefix key for use in LaTeX-math-mode.")
|
|
2329
|
|
2330 (defvar LaTeX-math-keymap (make-sparse-keymap)
|
|
2331 "Keymap used for LaTeX-math-mode commands.")
|
|
2332
|
|
2333 (defvar LaTeX-math-menu
|
|
2334 '("Math"
|
|
2335 ("Greek") ("greek") ("Binary Op") ("Relational") ("Arrows")
|
|
2336 ("Misc Symbol") ("Var Symbol") ("Log-like") ("delimiters")
|
|
2337 ("Delimiters") ("Constructs") ("Accents") ("AMS"))
|
|
2338 "Menu containing LaTeX math commands.
|
|
2339 The menu entries will be generated dynamically, but you can specify
|
|
2340 the sequence by initializing this variable.")
|
|
2341
|
|
2342 (define-key LaTeX-math-keymap
|
|
2343 (concat LaTeX-math-abbrev-prefix LaTeX-math-abbrev-prefix)
|
|
2344 'LaTeX-math-insert-prefix)
|
|
2345
|
|
2346 (let ((math (reverse (append LaTeX-math-list LaTeX-math-default)))
|
|
2347 (map (lookup-key LaTeX-math-keymap LaTeX-math-abbrev-prefix)))
|
|
2348 (while math
|
|
2349 (let* ((entry (car math))
|
|
2350 (key (nth 0 entry))
|
|
2351 value menu name)
|
|
2352 (setq math (cdr math))
|
|
2353 (if (listp (cdr entry))
|
|
2354 (setq value (nth 1 entry)
|
|
2355 menu (nth 2 entry))
|
|
2356 (setq value (cdr entry)
|
|
2357 menu nil))
|
|
2358 (if (stringp value)
|
|
2359 (progn
|
|
2360 (setq name (intern (concat "LaTeX-math-" value)))
|
|
2361 (fset name (list 'lambda (list 'arg) (list 'interactive "*P")
|
|
2362 (list 'LaTeX-math-insert value 'arg))))
|
|
2363 (setq name value))
|
|
2364 (if key
|
|
2365 (progn
|
|
2366 (setq key (if (numberp key) (char-to-string key) (vector key)))
|
|
2367 (define-key map key name)))
|
|
2368 (if menu
|
|
2369 (let ((parent LaTeX-math-menu))
|
|
2370 (if (listp menu)
|
|
2371 (progn
|
|
2372 (while (cdr menu)
|
|
2373 (let ((sub (assoc (car menu) LaTeX-math-menu)))
|
|
2374 (if sub
|
|
2375 (setq parent sub)
|
|
2376 (setcdr parent (cons (list (car menu)) (cdr parent))))
|
|
2377 (setq menu (cdr menu))))
|
|
2378 (setq menu (car menu))))
|
|
2379 (let ((sub (assoc menu parent)))
|
|
2380 (if sub
|
|
2381 (if (stringp value)
|
|
2382 (setcdr sub (cons (vector value name t) (cdr sub)))
|
|
2383 (error "Cannot have multiple special math menu items"))
|
|
2384 (setcdr parent
|
|
2385 (cons (if (stringp value)
|
|
2386 (list menu (vector value name t))
|
|
2387 (vector menu name t))
|
|
2388 (cdr parent))))))))))
|
|
2389
|
|
2390 (easy-menu-define LaTeX-math-mode-menu
|
|
2391 LaTeX-math-keymap
|
|
2392 "Menu used in math minor mode."
|
|
2393 LaTeX-math-menu)
|
|
2394
|
|
2395 (defvar LaTeX-math-mode nil
|
|
2396 "Is LaTeX-math-mode on or off? non nil means on.")
|
|
2397
|
|
2398 (make-variable-buffer-local 'LaTeX-math-mode)
|
|
2399
|
|
2400 (or (assoc 'LaTeX-math-mode minor-mode-alist)
|
|
2401 (setq minor-mode-alist (cons '(LaTeX-math-mode " Math") minor-mode-alist)))
|
|
2402
|
|
2403 (or (assoc 'LaTeX-math-mode minor-mode-map-alist)
|
|
2404 (setq minor-mode-map-alist
|
|
2405 (cons (cons 'LaTeX-math-mode LaTeX-math-keymap)
|
|
2406 minor-mode-map-alist)))
|
|
2407
|
|
2408 (defun LaTeX-math-mode (&optional arg)
|
|
2409 "A minor mode with easy acces to TeX math macros.
|
|
2410
|
|
2411 Easy insertion of LaTeX math symbols. If you give a prefix argument,
|
|
2412 the symbols will be surrounded by dollar signs. The following
|
|
2413 commands are defined:
|
|
2414
|
|
2415 \\{LaTeX-math-keymap}"
|
|
2416 (interactive "P")
|
|
2417 (setq LaTeX-math-mode
|
|
2418 (not (or (and (null arg) LaTeX-math-mode)
|
|
2419 (<= (prefix-numeric-value arg) 0))))
|
|
2420 (if LaTeX-math-mode
|
|
2421 (easy-menu-add LaTeX-math-mode-menu LaTeX-math-keymap)
|
|
2422 (easy-menu-remove LaTeX-math-mode-menu))
|
|
2423 (set-buffer-modified-p (buffer-modified-p)))
|
|
2424
|
|
2425 (fset 'latex-math-mode 'LaTeX-math-mode)
|
|
2426
|
|
2427 (defun LaTeX-math-insert-prefix ()
|
|
2428 "Insert the value of `LaTeX-math-abbrev-prefix'."
|
|
2429 (interactive "*")
|
|
2430 (let (LaTeX-math-mode)
|
|
2431 (call-interactively (key-binding LaTeX-math-abbrev-prefix))))
|
|
2432
|
|
2433 (defun LaTeX-math-insert (string dollar)
|
|
2434 ;; Inserts \STRING{}. If DOLLAR is non-nil, put $'s around it.
|
|
2435 (if dollar (insert "$"))
|
|
2436 (TeX-insert-macro string)
|
|
2437 (if dollar (insert "$")))
|
|
2438
|
|
2439 (defun LaTeX-math-cal (char dollar)
|
|
2440 "Inserts a {\\cal CHAR}. If DOLLAR is non-nil, put $'s around it."
|
|
2441 (interactive "*c\nP")
|
|
2442 (if dollar (insert "$"))
|
|
2443 (if (member "latex2e" (TeX-style-list))
|
|
2444 (insert "\\mathcal{" (char-to-string char) "}")
|
|
2445 (insert "{\\cal " (char-to-string char) "}"))
|
|
2446 (if dollar (insert "$")))
|
|
2447
|
|
2448 (provide 'latex)
|
|
2449
|
|
2450 ;;; Keymap
|
|
2451
|
|
2452 (defvar LaTeX-mode-map
|
|
2453 (let ((map (copy-keymap TeX-mode-map)))
|
|
2454
|
|
2455 ;; Standard
|
|
2456 (define-key map "\n" 'reindent-then-newline-and-indent)
|
|
2457
|
|
2458 ;; From latex.el
|
|
2459 (define-key map "\t" 'LaTeX-indent-line)
|
|
2460 (define-key map "\eq" 'LaTeX-fill-paragraph) ;*** Alias
|
|
2461 ;; This key is now used by Emacs for face settings.
|
|
2462 ;; (define-key map "\eg" 'LaTeX-fill-region) ;*** Alias
|
|
2463 (define-key map "\e\C-e" 'LaTeX-find-matching-end)
|
|
2464 (define-key map "\e\C-a" 'LaTeX-find-matching-begin)
|
|
2465
|
|
2466 (define-key map "\C-c\C-q\C-p" 'LaTeX-fill-paragraph)
|
|
2467 (define-key map "\C-c\C-q\C-r" 'LaTeX-fill-region)
|
|
2468 (define-key map "\C-c\C-q\C-s" 'LaTeX-fill-section)
|
|
2469 (define-key map "\C-c\C-q\C-e" 'LaTeX-fill-environment)
|
|
2470
|
|
2471 (define-key map "\C-c." 'LaTeX-mark-environment) ;*** Dubious
|
|
2472 (define-key map "\C-c*" 'LaTeX-mark-section) ;*** Dubious
|
|
2473
|
|
2474 (define-key map "\C-c\C-e" 'LaTeX-environment)
|
|
2475 (define-key map "\C-c\n" 'LaTeX-insert-item)
|
|
2476 (or (key-binding "\e\r")
|
|
2477 (define-key map "\e\r" 'LaTeX-insert-item)) ;*** Alias
|
|
2478 (define-key map "\C-c]" 'LaTeX-close-environment)
|
|
2479 (define-key map "\C-c\C-s" 'LaTeX-section)
|
|
2480
|
|
2481 ;; Outline commands...
|
|
2482 ;; We want to use the right prefix, if possible.
|
|
2483 (let ((outline (cond ((not (boundp 'outline-minor-mode-prefix))
|
|
2484 (lookup-key map "\C-c"))
|
|
2485 ((keymapp (lookup-key map outline-minor-mode-prefix))
|
|
2486 (lookup-key map outline-minor-mode-prefix))
|
|
2487 (t
|
|
2488 (define-key map
|
|
2489 outline-minor-mode-prefix (make-sparse-keymap))
|
|
2490 (lookup-key map outline-minor-mode-prefix)))))
|
|
2491 (define-key outline "\C-z" 'LaTeX-hide-environment)
|
|
2492 (define-key outline "\C-x" 'LaTeX-show-environment))
|
|
2493
|
|
2494 (define-key map "\C-c~" 'LaTeX-math-mode) ;*** Dubious
|
|
2495
|
|
2496 map)
|
|
2497 "Keymap used in LaTeX-mode.")
|
|
2498
|
|
2499 (defvar LaTeX-environment-menu-name "Insert Environment (C-c C-e)")
|
|
2500
|
|
2501 (defun LaTeX-environment-menu-entry (entry)
|
|
2502 ;; Create an entry for the environment menu.
|
|
2503 (vector (car entry) (list 'LaTeX-environment-menu (car entry)) t))
|
|
2504
|
|
2505 (defvar LaTeX-environment-modify-menu-name "Change Environment (C-u C-c C-e)")
|
|
2506
|
|
2507 (defun LaTeX-environment-modify-menu-entry (entry)
|
|
2508 ;; Create an entry for the change environment menu.
|
|
2509 (vector (car entry) (list 'LaTeX-modify-environment (car entry)) t))
|
|
2510
|
|
2511 (defun LaTeX-section-enable-symbol (LEVEL)
|
|
2512 ;; Symbol used to enable section LEVEL in the menu bar.
|
|
2513 (intern (concat "LaTeX-section-" (int-to-string (nth 1 entry)) "-enable")))
|
|
2514
|
|
2515 (defun LaTeX-section-enable (entry)
|
|
2516 ;; Enable or disable section ENTRY from LaTeX-section-list.
|
|
2517 (let ((level (nth 1 entry)))
|
|
2518 (set (LaTeX-section-enable-symbol level)
|
|
2519 (>= level LaTeX-largest-level))))
|
|
2520
|
|
2521 (defun LaTeX-section-menu (level)
|
|
2522 ;; Insert section from menu.
|
|
2523 (let ((LaTeX-section-hook (delq 'LaTeX-section-heading
|
|
2524 (copy-sequence LaTeX-section-hook))))
|
|
2525 (LaTeX-section level)))
|
|
2526
|
|
2527 (defun LaTeX-section-menu-entry (entry)
|
|
2528 ;; Create an entry for the section menu.
|
|
2529 (let ((enable (LaTeX-section-enable-symbol (nth 1 entry))))
|
|
2530 (set enable t)
|
|
2531 (vector (car entry) (list 'LaTeX-section-menu (nth 1 entry)) enable)))
|
|
2532
|
|
2533 (defun LaTeX-section-menu-create ()
|
|
2534 ;; Create a menu over LaTeX sections.
|
|
2535 (append '("Section (C-c C-s)")
|
|
2536 (mapcar 'LaTeX-section-menu-entry LaTeX-section-list)))
|
|
2537
|
|
2538 (defvar LaTeX-menu-changed nil)
|
|
2539 ;; Need to update LaTeX menu.
|
|
2540 (make-variable-buffer-local 'LaTeX-menu-changed)
|
|
2541
|
|
2542 (defun LaTeX-menu-update ()
|
|
2543 ;; Update entries on AUC TeX menu.
|
|
2544 (or (not (eq major-mode 'latex-mode))
|
|
2545 (null LaTeX-menu-changed)
|
|
2546 (not (fboundp 'easy-menu-change))
|
|
2547 (progn
|
|
2548 (TeX-update-style)
|
|
2549 (setq LaTeX-menu-changed nil)
|
|
2550 (message "Updating section menu...")
|
|
2551 (mapcar 'LaTeX-section-enable LaTeX-section-list)
|
|
2552 (message "Updating environment menu...")
|
|
2553 (easy-menu-change '("LaTeX") LaTeX-environment-menu-name
|
|
2554 (mapcar 'LaTeX-environment-menu-entry
|
|
2555 (LaTeX-environment-list)))
|
|
2556 (message "Updating modify environment menu...")
|
|
2557 (easy-menu-change '("LaTeX") LaTeX-environment-modify-menu-name
|
|
2558 (mapcar 'LaTeX-environment-modify-menu-entry
|
|
2559 (LaTeX-environment-list)))
|
|
2560 (message "Updating...done"))))
|
|
2561
|
|
2562 (add-hook 'activate-menubar-hook 'LaTeX-menu-update)
|
|
2563
|
|
2564 (easy-menu-define LaTeX-mode-menu
|
|
2565 LaTeX-mode-map
|
|
2566 "Menu used in LaTeX mode."
|
|
2567 (list "LaTeX"
|
|
2568 (list LaTeX-environment-menu-name "Bug.")
|
|
2569 (list LaTeX-environment-modify-menu-name "Bug.")
|
|
2570 (LaTeX-section-menu-create)
|
|
2571 ["Macro..." TeX-insert-macro t]
|
|
2572 ["Complete" TeX-complete-symbol t]
|
|
2573 ["Item" LaTeX-insert-item t]
|
|
2574 (list "Insert Font"
|
|
2575 ["Emphasize" (TeX-font nil ?\C-e) :keys "C-c C-f C-e"]
|
|
2576 ["Bold" (TeX-font nil ?\C-b) :keys "C-c C-f C-b"]
|
|
2577 ["Typewriter" (TeX-font nil ?\C-t) :keys "C-c C-f C-t"]
|
|
2578 ["Small Caps" (TeX-font nil ?\C-c) :keys "C-c C-f C-c"]
|
|
2579 ["Sans Serif" (TeX-font nil ?\C-f) :keys "C-c C-f C-f"]
|
|
2580 ["Italic" (TeX-font nil ?\C-i) :keys "C-c C-f C-i"]
|
|
2581 ["Slanted" (TeX-font nil ?\C-s) :keys "C-c C-f C-s"]
|
|
2582 ["Roman" (TeX-font nil ?\C-r) :keys "C-c C-f C-r"])
|
|
2583 (list "Change Font"
|
|
2584 ["Emphasize" (TeX-font t ?\C-e) :keys "C-u C-c C-f C-e"]
|
|
2585 ["Bold" (TeX-font t ?\C-b) :keys "C-u C-c C-f C-b"]
|
|
2586 ["Typewriter" (TeX-font t ?\C-t) :keys "C-u C-c C-f C-t"]
|
|
2587 ["Small Caps" (TeX-font t ?\C-c) :keys "C-u C-c C-f C-c"]
|
|
2588 ["Sans Serif" (TeX-font t ?\C-f) :keys "C-u C-c C-f C-f"]
|
|
2589 ["Italic" (TeX-font t ?\C-i) :keys "C-u C-c C-f C-i"]
|
|
2590 ["Slanted" (TeX-font t ?\C-s) :keys "C-u C-c C-f C-s"]
|
|
2591 ["Roman" (TeX-font t ?\C-r) :keys "C-u C-c C-f C-r"])
|
|
2592 ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
|
|
2593 "-"
|
|
2594 ["Next Error" TeX-next-error t]
|
|
2595 (list "TeX Output"
|
|
2596 ["Kill Job" TeX-kill-job t]
|
|
2597 ["Debug Bad Boxes" TeX-toggle-debug-boxes
|
|
2598 :style toggle :selected TeX-debug-bad-boxes ]
|
|
2599 ["Switch to Original File" TeX-home-buffer t]
|
|
2600 ["Recenter Output Buffer" TeX-recenter-output-buffer t])
|
|
2601 (list "Formatting and Marking"
|
|
2602 ["Format Environment" LaTeX-fill-environment t]
|
|
2603 ["Format Paragraph" LaTeX-fill-paragraph t]
|
|
2604 ["Format Region" LaTeX-fill-region t]
|
|
2605 ["Format Section" LaTeX-fill-section t]
|
|
2606 ["Mark Environment" LaTeX-mark-environment t]
|
|
2607 ["Mark Section" LaTeX-mark-section t]
|
|
2608 ["Beginning of Environment" LaTeX-find-matching-begin t]
|
|
2609 ["End of Environment" LaTeX-find-matching-end t]
|
|
2610 ["Hide Environment" LaTeX-hide-environment t]
|
|
2611 ["Show Environment" LaTeX-show-environment t])
|
|
2612 (list "Miscellaneous"
|
|
2613 ["Uncomment Region" TeX-un-comment-region t]
|
|
2614 ["Comment Region" TeX-comment-region t]
|
|
2615 ["Switch to Master file" TeX-home-buffer t]
|
|
2616 ["Save Document" TeX-save-document t]
|
|
2617 ["Math Mode" LaTeX-math-mode
|
|
2618 :style toggle :selected LaTeX-math-mode ]
|
|
2619 ["Documentation" TeX-goto-info-page t]
|
|
2620 ["Submit bug report" TeX-submit-bug-report t]
|
|
2621 [ "Convert 209 to 2e" LaTeX-209-to-2e
|
|
2622 :active (member "latex2" (TeX-style-list)) ]
|
|
2623 ["Reset Buffer" TeX-normal-mode t]
|
|
2624 ["Reset AUC TeX" (TeX-normal-mode t) :keys "C-u C-c C-n"])))
|
|
2625
|
|
2626 (defvar LaTeX-font-list
|
|
2627 '((?\C-b "\\textbf{" "}")
|
|
2628 (?\C-c "\\textsc{" "}")
|
|
2629 (?\C-e "\\emph{" "}")
|
|
2630 (?\C-f "\\textsf{" "}")
|
|
2631 (?\C-i "\\textit{" "}")
|
|
2632 (?\C-m "\\textmd{" "}")
|
|
2633 (?\C-n "\\textnormal{" "}")
|
|
2634 (?\C-r "\\textrm{" "}")
|
|
2635 (?\C-s "\\textsl{" "}")
|
|
2636 (?\C-t "\\texttt{" "}")
|
|
2637 (?\C-u "\\textup{" "}")
|
|
2638 (?\C-d "" "" t))
|
|
2639 "Font commands used with LaTeX2e. See `TeX-font-list'.")
|
|
2640
|
|
2641 ;;; Mode
|
|
2642
|
|
2643 (defvar TeX-arg-cite-note-p nil
|
|
2644 "*If non-nil, ask for optional note in citations.")
|
|
2645
|
|
2646 (defvar TeX-arg-footnote-number-p nil
|
|
2647 "*If non-nil, ask for optional number in footnotes.")
|
|
2648
|
|
2649 (defvar TeX-arg-item-label-p nil
|
|
2650 "*If non-nil, always ask for optional label in items.
|
|
2651 Otherwise, only ask in description environments.")
|
|
2652
|
|
2653 (defvar TeX-arg-right-insert-p t
|
|
2654 "*If non-nil, always insert automatically the corresponding
|
|
2655 \\right if \\left is inserted.")
|
|
2656
|
|
2657 (defvar LaTeX-paragraph-commands
|
|
2658 (concat "\\[\\|\\]\\|" ; display math delimitors
|
|
2659 "begin\\b\\|end\\b\\|part\\b\\|chapter\\b\\|label\\b\\|"
|
|
2660 "caption\\b\\|section\\b\\|subsection\\b\\|subsubsection\\b\\|"
|
|
2661 "par\\b\\|noindent\\b\\|paragraph\\b\\|include\\b\\|"
|
|
2662 "includeonly\\b\\|tableofcontents\\b\\|appendix\\b")
|
|
2663 "Regexp matching names of LaTeX macros that should have their own line.")
|
|
2664
|
|
2665 ;;; Do not ;;;###autoload because of conflict with standard tex-mode.el.
|
|
2666 (defun latex-mode ()
|
|
2667 "Major mode for editing files of input for LaTeX.
|
|
2668 See info under AUC TeX for full documentation.
|
|
2669
|
|
2670 Special commands:
|
|
2671 \\{LaTeX-mode-map}
|
|
2672
|
|
2673 Entering LaTeX mode calls the value of text-mode-hook,
|
|
2674 then the value of TeX-mode-hook, and then the value
|
|
2675 of LaTeX-mode-hook."
|
|
2676 (interactive)
|
|
2677 (LaTeX-common-initialization)
|
|
2678 (setq mode-name "LaTeX")
|
|
2679 (setq major-mode 'latex-mode)
|
|
2680 (setq TeX-command-default "LaTeX")
|
|
2681 (run-hooks 'text-mode-hook 'TeX-mode-hook 'LaTeX-mode-hook)
|
|
2682
|
|
2683 ;; Defeat filladapt if auto-fill-mode is set in text-mode-hook.
|
|
2684 (and (boundp 'filladapt-function-table)
|
|
2685 (boundp 'auto-fill-function)
|
|
2686 (eq auto-fill-function 'do-auto-fill)
|
|
2687 (setq auto-fill-function
|
|
2688 (cdr (assoc 'do-auto-fill filladapt-function-table)))))
|
|
2689
|
|
2690 (defvar LaTeX-header-end
|
|
2691 (concat (regexp-quote TeX-esc) "begin *" TeX-grop "document" TeX-grcl)
|
|
2692 "Default end of header marker for LaTeX documents.")
|
|
2693
|
|
2694 (defvar LaTeX-trailer-start
|
|
2695 (concat (regexp-quote TeX-esc) "end *" TeX-grop "document" TeX-grcl)
|
|
2696 "Default start of trailer marker for LaTeX documents.")
|
|
2697
|
|
2698 (defun LaTeX2e-font-replace (start end)
|
|
2699 "Replace LaTeX2e font specification around point with START and END."
|
|
2700 (save-excursion
|
|
2701 (catch 'done
|
|
2702 (while t
|
|
2703 (if (/= ?\\ (following-char))
|
|
2704 (skip-chars-backward "a-zA-Z "))
|
|
2705 (skip-chars-backward "\\\\")
|
|
2706 (if (looking-at "\\\\\\(emph\\|text[a-z]+\\){")
|
|
2707 (throw 'done t)
|
|
2708 (up-list -1))))
|
|
2709 (forward-sexp 2)
|
|
2710 (save-excursion
|
|
2711 (replace-match start t t))
|
|
2712 (delete-backward-char 1)
|
|
2713 (insert end)))
|
|
2714
|
|
2715 (defun LaTeX-common-initialization ()
|
|
2716 ;; Common initialization for LaTeX derived modes.
|
|
2717 (VirTeX-common-initialization)
|
|
2718 (set-syntax-table LaTeX-mode-syntax-table)
|
|
2719 (make-local-variable 'indent-line-function)
|
|
2720 (setq indent-line-function 'LaTeX-indent-line)
|
|
2721 (use-local-map LaTeX-mode-map)
|
|
2722 (easy-menu-add TeX-mode-menu LaTeX-mode-map)
|
|
2723 (easy-menu-add LaTeX-mode-menu LaTeX-mode-map)
|
|
2724
|
|
2725 (or LaTeX-largest-level
|
|
2726 (setq LaTeX-largest-level (LaTeX-section-level "section")))
|
|
2727
|
|
2728 (setq TeX-header-end LaTeX-header-end
|
|
2729 TeX-trailer-start LaTeX-trailer-start)
|
|
2730
|
|
2731 (require 'outline)
|
|
2732 (make-local-variable 'outline-level)
|
|
2733 (setq outline-level 'LaTeX-outline-level)
|
|
2734 (make-local-variable 'outline-regexp)
|
|
2735 (setq outline-regexp (LaTeX-outline-regexp t))
|
|
2736
|
|
2737 (make-local-variable 'TeX-auto-full-regexp-list)
|
|
2738 (setq TeX-auto-full-regexp-list
|
|
2739 (append LaTeX-auto-regexp-list plain-TeX-auto-regexp-list))
|
|
2740
|
|
2741 (setq paragraph-start
|
|
2742 (concat
|
|
2743 "\\("
|
|
2744 "^.*[^" TeX-esc "\n]%.*$\\|"
|
|
2745 "^%.*$\\|"
|
|
2746 "^[ \t]*$\\|"
|
|
2747 "^[ \t]*"
|
|
2748 (regexp-quote TeX-esc)
|
|
2749 "\\("
|
|
2750 LaTeX-paragraph-commands
|
|
2751 "\\|item\\b"
|
|
2752 "\\)"
|
|
2753 "\\|"
|
|
2754 "^[ \t]*\\$\\$" ; display math delimitor
|
|
2755 "\\)" ))
|
|
2756 (setq paragraph-separate
|
|
2757 (concat
|
|
2758 "\\("
|
|
2759 "^.*[^" TeX-esc "\n]%.*$\\|"
|
|
2760 "^%.*$\\|"
|
|
2761 "^[ \t]*$\\|"
|
|
2762 "^[ \t]*"
|
|
2763 (regexp-quote TeX-esc)
|
|
2764 "\\("
|
|
2765 LaTeX-paragraph-commands
|
|
2766 "\\)"
|
|
2767 "\\)"))
|
|
2768 (setq selective-display t)
|
|
2769
|
|
2770 (make-local-variable 'LaTeX-item-list)
|
|
2771 (setq LaTeX-item-list '(("description" . LaTeX-item-argument)
|
|
2772 ("thebibliography" . LaTeX-item-bib)))
|
|
2773
|
|
2774 (setq TeX-complete-list
|
|
2775 (append '(("\\\\cite\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
|
|
2776 1 LaTeX-bibitem-list "}")
|
|
2777 ("\\\\cite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
|
|
2778 ("\\\\cite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
|
|
2779 2 LaTeX-bibitem-list)
|
|
2780 ("\\\\nocite{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-bibitem-list "}")
|
|
2781 ("\\\\nocite{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
|
|
2782 2 LaTeX-bibitem-list)
|
|
2783 ("\\\\ref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
|
|
2784 ("\\\\eqref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
|
|
2785 ("\\\\pageref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")
|
|
2786 ("\\\\begin{\\([A-Za-z]*\\)" 1 LaTeX-environment-list "}")
|
|
2787 ("\\\\end{\\([A-Za-z]*\\)" 1 LaTeX-environment-list "}")
|
|
2788 ("\\\\renewcommand{\\\\\\([A-Za-z]*\\)"
|
|
2789 1 LaTeX-symbol-list "}")
|
|
2790 ("\\\\renewenvironment{\\([A-Za-z]*\\)"
|
|
2791 1 LaTeX-environment-list "}"))
|
|
2792 TeX-complete-list))
|
|
2793
|
|
2794 (LaTeX-add-environments
|
|
2795 '("document" LaTeX-env-document)
|
|
2796 '("enumerate" LaTeX-env-item)
|
|
2797 '("itemize" LaTeX-env-item)
|
|
2798 '("list" LaTeX-env-list)
|
|
2799 '("trivlist" LaTeX-env-item)
|
|
2800 '("picture" LaTeX-env-picture)
|
|
2801 '("tabular" LaTeX-env-array)
|
|
2802 '("tabular*" LaTeX-env-array)
|
|
2803 '("array" LaTeX-env-array)
|
|
2804 '("eqnarray" LaTeX-env-label)
|
|
2805 '("equation" LaTeX-env-label)
|
|
2806 '("minipage" LaTeX-env-minipage)
|
|
2807
|
|
2808 ;; The following have no special support, but are included in
|
|
2809 ;; case the auto files are missing.
|
|
2810
|
|
2811 "sloppypar" "picture" "tabbing" "verbatim" "verbatim*"
|
|
2812 "flushright" "flushleft" "displaymath" "math" "quote" "quotation"
|
|
2813 "abstract" "center" "titlepage" "verse" "eqnarray*"
|
|
2814
|
|
2815 ;; The following are not defined in latex.el, but in a number of
|
|
2816 ;; other style files. I'm to lazy to copy them to all the
|
|
2817 ;; corresponding .el files right now.
|
|
2818
|
|
2819 ;; This means that AUC TeX will complete e.g.
|
|
2820 ;; ``thebibliography'' in a letter, but I guess we can live with
|
|
2821 ;; that.
|
|
2822
|
|
2823 '("description" LaTeX-env-item)
|
|
2824 '("figure" LaTeX-env-figure)
|
|
2825 '("figure*" LaTeX-env-figure)
|
|
2826 '("table" LaTeX-env-figure)
|
|
2827 '("table*" LaTeX-env-figure)
|
|
2828 '("thebibliography" LaTeX-env-bib)
|
|
2829 '("theindex" LaTeX-env-item))
|
|
2830
|
|
2831 (TeX-add-symbols
|
|
2832 '("addtocounter" TeX-arg-counter "Value")
|
|
2833 '("alph" TeX-arg-counter)
|
|
2834 '("arabic" TeX-arg-counter)
|
|
2835 '("fnsymbol" TeX-arg-define-counter)
|
|
2836 '("newcounter" TeX-arg-define-counter
|
|
2837 [ TeX-arg-counter "Within counter" ])
|
|
2838 '("roman" TeX-arg-counter)
|
|
2839 '("setcounter" TeX-arg-counter "Value")
|
|
2840 '("usecounter" TeX-arg-counter)
|
|
2841 '("value" TeX-arg-counter)
|
|
2842 '("stepcounter" TeX-arg-counter)
|
|
2843 '("refstepcounter" TeX-arg-counter)
|
|
2844 '("label" TeX-arg-define-label)
|
|
2845 '("pageref" TeX-arg-label)
|
|
2846 '("ref" TeX-arg-label)
|
|
2847 '("newcommand" TeX-arg-define-macro [ "Number of arguments" ] t)
|
|
2848 '("renewcommand" TeX-arg-macro [ "Number of arguments" ] t)
|
|
2849 '("newenvironment" TeX-arg-define-environment
|
|
2850 [ "Number of arguments"] t t)
|
|
2851 '("renewenvironment" TeX-arg-environment
|
|
2852 [ "Number of arguments"] t t)
|
|
2853 '("newtheorem" TeX-arg-define-environment
|
|
2854 [ TeX-arg-environment "Numbered like" ]
|
|
2855 t [ (TeX-arg-eval progn (if (eq (save-excursion
|
|
2856 (backward-char 2)
|
|
2857 (preceding-char)) ?\])
|
|
2858 ()
|
|
2859 (TeX-arg-counter t "Within counter"))
|
|
2860 "") ])
|
|
2861 '("newfont" TeX-arg-define-macro t)
|
|
2862 '("circle" "Diameter")
|
|
2863 '("circle*" "Diameter")
|
|
2864 '("dashbox" "Dash Length" TeX-arg-size
|
|
2865 [ TeX-arg-corner ] t)
|
|
2866 '("frame" t)
|
|
2867 '("framebox" (TeX-arg-conditional
|
|
2868 (string-equal (LaTeX-current-environment) "picture")
|
|
2869 (TeX-arg-size [ TeX-arg-corner ] t)
|
|
2870 ([ "Length" ] [ TeX-arg-lr ] t)))
|
|
2871 '("line" (TeX-arg-pair "X slope" "Y slope") "Length")
|
|
2872 '("linethickness" "Dimension")
|
|
2873 '("makebox" (TeX-arg-conditional
|
|
2874 (string-equal (LaTeX-current-environment) "picture")
|
|
2875 (TeX-arg-size [ TeX-arg-corner ] t)
|
|
2876 ([ "Length" ] [ TeX-arg-lr ] t)))
|
|
2877 '("multiput"
|
|
2878 TeX-arg-coordinate
|
|
2879 (TeX-arg-pair "X delta" "Y delta")
|
|
2880 "Number of copies"
|
|
2881 t)
|
|
2882 '("oval" TeX-arg-size [ TeX-arg-corner "Portion" ])
|
|
2883 '("put" TeX-arg-coordinate t)
|
|
2884 '("savebox" TeX-arg-define-savebox
|
|
2885 (TeX-arg-conditional
|
|
2886 (string-equal (LaTeX-current-environment) "picture")
|
|
2887 (TeX-arg-size [ TeX-arg-corner ] t)
|
|
2888 ([ "Length" ] [ TeX-arg-lr ] t)))
|
|
2889 '("shortstack" [ TeX-arg-lr ] t)
|
|
2890 '("vector" (TeX-arg-pair "X slope" "Y slope") "Length")
|
|
2891 '("cline" "Span `i-j'")
|
|
2892 '("multicolumn" "Columns" "Position" t)
|
|
2893 '("item"
|
|
2894 (TeX-arg-conditional (or TeX-arg-item-label-p
|
|
2895 (string-equal (LaTeX-current-environment)
|
|
2896 "description"))
|
|
2897 ([ "Item label" ])
|
|
2898 ())
|
|
2899 (TeX-arg-literal " "))
|
|
2900 '("bibitem" [ "Bibitem label" ] TeX-arg-define-cite)
|
|
2901 '("cite"
|
|
2902 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) ())
|
|
2903 TeX-arg-cite)
|
|
2904 '("nocite" TeX-arg-cite)
|
|
2905 '("bibliographystyle" TeX-arg-bibstyle)
|
|
2906 '("bibliography" TeX-arg-bibliography)
|
|
2907 '("footnote"
|
|
2908 (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
|
|
2909 t)
|
|
2910 '("footnotetext"
|
|
2911 (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
|
|
2912 t)
|
|
2913 '("footnotemark"
|
|
2914 (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil))
|
|
2915 '("newlength" TeX-arg-define-macro)
|
|
2916 '("setlength" TeX-arg-macro "Length")
|
|
2917 '("addtolength" TeX-arg-macro "Length")
|
|
2918 '("settowidth" TeX-arg-macro t)
|
|
2919 '("\\" [ "Space" ])
|
|
2920 '("\\*" [ "Space" ])
|
|
2921 '("hyphenation" t)
|
|
2922 '("linebreak" [ "How much [0 - 4]" ])
|
|
2923 '("nolinebreak" [ "How much [0 - 4]" ])
|
|
2924 '("nopagebreak" [ "How much [0 - 4]" ])
|
|
2925 '("pagebreak" [ "How much [0 - 4]" ])
|
|
2926 '("stackrel" t nil)
|
|
2927 '("frac" t nil)
|
|
2928 '("lefteqn" t)
|
|
2929 '("overbrace" t)
|
|
2930 '("overline" t)
|
|
2931 '("sqrt" [ "Root" ] t)
|
|
2932 '("underbrace" t)
|
|
2933 '("underline" t)
|
|
2934 '("author" t)
|
|
2935 '("date" t)
|
|
2936 '("thanks" t)
|
|
2937 '("title" t)
|
|
2938 '("pagenumbering" (TeX-arg-eval
|
|
2939 completing-read "Numbering style: "
|
|
2940 '(("arabic") ("roman") ("Roman") ("alph") ("Alph"))))
|
|
2941 '("pagestyle" TeX-arg-pagestyle)
|
|
2942 '("markboth" t nil)
|
|
2943 '("markright" t)
|
|
2944 '("thispagestyle" TeX-arg-pagestyle)
|
|
2945 '("addvspace" "Length")
|
|
2946 '("fbox" t)
|
|
2947 '("hspace*" "Length")
|
|
2948 '("hspace" "Length")
|
|
2949 '("mbox" t)
|
|
2950 '("newsavebox" TeX-arg-define-savebox)
|
|
2951 '("parbox" [ TeX-arg-tb] "Width" t)
|
|
2952 '("raisebox" "Raise" [ "Height above" ] [ "Depth below" ] t)
|
|
2953 '("rule" [ "Raise" ] "Width" "Thickness")
|
|
2954 '("sbox" TeX-arg-define-savebox t)
|
|
2955 '("usebox" TeX-arg-savebox)
|
|
2956 '("vspace*" "Length")
|
|
2957 '("vspace" "Length")
|
|
2958 '("documentstyle" TeX-arg-document)
|
|
2959 '("include" (TeX-arg-input-file "File" t))
|
|
2960 '("includeonly" t)
|
|
2961 '("input" TeX-arg-input-file)
|
|
2962 '("addcontentsline" TeX-arg-file
|
|
2963 (TeX-arg-eval
|
|
2964 completing-read "Numbering style: " LaTeX-section-list)
|
|
2965 t)
|
|
2966 '("addtocontents" TeX-arg-file t)
|
|
2967 '("typeout" t)
|
|
2968 '("typein" [ TeX-arg-define-macro ] t)
|
|
2969 '("verb" TeX-arg-verb)
|
|
2970 '("verb*" TeX-arg-verb)
|
|
2971 '("extracolsep" t)
|
|
2972 '("index" t)
|
|
2973 '("glossary" t)
|
|
2974 '("numberline" "Section number" "Heading")
|
|
2975 '("caption" t)
|
|
2976 '("marginpar" [ "Left margin text" ] "Text")
|
|
2977 '("left" TeX-arg-insert-braces)
|
|
2978
|
|
2979 ;; These have no special support, but are included in case the
|
|
2980 ;; auto files are missing.
|
|
2981
|
|
2982 "LaTeX" "SLiTeX" "samepage" "newline" "smallskip" "medskip"
|
|
2983 "bigskip" "stretch" "nonumber" "centering" "raggedright"
|
|
2984 "raggedleft" "kill" "pushtabs" "poptabs" "protect" "arraystretch"
|
|
2985 "hline" "vline" "cline" "thinlines" "thicklines" "and" "makeindex"
|
|
2986 "makeglossary" "reversemarginpar" "normalmarginpar"
|
|
2987 "raggedbottom" "flushbottom" "sloppy" "fussy" "newpage"
|
|
2988 "clearpage" "cleardoublepage" "twocolumn" "onecolumn")
|
|
2989
|
|
2990 (TeX-run-style-hooks "LATEX")
|
|
2991
|
|
2992 (make-local-variable 'TeX-font-list)
|
|
2993 (make-local-variable 'TeX-font-replace-function)
|
|
2994 (if (string-equal LaTeX-version "2")
|
|
2995 ()
|
|
2996 (setq TeX-font-list LaTeX-font-list)
|
|
2997 (setq TeX-font-replace-function 'LaTeX2e-font-replace)
|
|
2998 (TeX-add-symbols
|
|
2999 '("newcommand" TeX-arg-define-macro
|
|
3000 [ "Number of arguments" ] [ "Default value for first argument" ] t)
|
|
3001 '("renewcommand" TeX-arg-macro
|
|
3002 [ "Number of arguments" ] [ "Default value for first argument" ] t)
|
|
3003 '("usepackage" [ "Options" ] (TeX-arg-input-file "Package"))
|
|
3004 '("documentclass" TeX-arg-document)))
|
|
3005
|
|
3006 (TeX-add-style-hook "latex2e"
|
|
3007 ;; Use new fonts for `\documentclass' documents.
|
|
3008 (function (lambda ()
|
|
3009 (setq TeX-font-list LaTeX-font-list)
|
|
3010 (setq TeX-font-replace-function 'LaTeX2e-font-replace)
|
|
3011 (if (equal LaTeX-version "2")
|
|
3012 (setq TeX-command-default "LaTeX2e"))
|
|
3013 (run-hooks 'LaTeX2e-hook))))
|
|
3014
|
|
3015 (TeX-add-style-hook "latex2"
|
|
3016 ;; Use old fonts for `\documentstyle' documents.
|
|
3017 (function (lambda ()
|
|
3018 (setq TeX-font-list (default-value 'TeX-font-list))
|
|
3019 (setq TeX-font-replace-function
|
|
3020 (default-value 'TeX-font-replace-function))
|
|
3021 (run-hooks 'LaTeX2-hook)))))
|
|
3022
|
|
3023 (defvar LaTeX-builtin-opts
|
|
3024 '("12pt" "11pt" "10pt" "twocolumn" "twoside" "draft")
|
|
3025 "Built in options for LaTeX standard styles")
|
|
3026
|
|
3027 (defun LaTeX-209-to-2e ()
|
|
3028 "Make a stab at changing 2.09 doc header to 2e style."
|
|
3029 (interactive)
|
|
3030 (TeX-home-buffer)
|
|
3031 (let (optstr optlist 2eoptlist 2epackages docline docstyle)
|
|
3032 (goto-char (point-min))
|
|
3033 (if
|
|
3034 (search-forward-regexp
|
|
3035 "\\documentstyle\\[\\([^]]*\\)\\]{\\([^}]*\\)}"
|
|
3036 (point-max) t)
|
|
3037 (setq optstr (buffer-substring (match-beginning 1) (match-end 1))
|
|
3038 docstyle (buffer-substring (match-beginning 2)
|
|
3039 (match-end 2))
|
|
3040 optlist (TeX-split-string "," optstr))
|
|
3041 (if (search-forward-regexp
|
|
3042 "\\documentstyle{\\([^}]*\\)}"
|
|
3043 (point-max) t)
|
|
3044 (setq docstyle (buffer-substring (match-beginning 1)
|
|
3045 (match-end 1)))
|
|
3046 (error "No documentstyle defined")))
|
|
3047 (beginning-of-line 1)
|
|
3048 (setq docline (point))
|
|
3049 (insert "%%%")
|
|
3050 (while optlist
|
|
3051 (if (member (car optlist) LaTeX-builtin-opts)
|
|
3052 (setq 2eoptlist (cons (car optlist) 2eoptlist))
|
|
3053 (setq 2epackages (cons (car optlist) 2epackages)))
|
|
3054 (setq optlist (cdr optlist)))
|
|
3055 ;;(message (format "%S %S" 2eoptlist 2epackages))
|
|
3056 (goto-char docline)
|
|
3057 (next-line 1)
|
|
3058 (insert "\\documentclass")
|
|
3059 (if 2eoptlist
|
|
3060 (insert "["
|
|
3061 (mapconcat (function (lambda (x) x))
|
|
3062 (nreverse 2eoptlist) ",") "]"))
|
|
3063 (insert "{" docstyle "}\n")
|
|
3064 (if 2epackages
|
|
3065 (insert "\\usepackage{"
|
|
3066 (mapconcat (function (lambda (x) x))
|
|
3067 (nreverse 2epackages) "}\n\\usepackage{") "}\n"))
|
|
3068 (if (equal docstyle "slides")
|
|
3069 (progn
|
|
3070 (goto-char (point-min))
|
|
3071 (while (re-search-forward "\\\\blackandwhite{" nil t)
|
|
3072 (replace-match "\\\\input{" nil nil)))))
|
|
3073 (TeX-normal-mode nil))
|
|
3074
|
|
3075 ;;; latex.el ends here
|