comparison lisp/auctex/tex.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents 7d55a9ba150c
children
comparison
equal deleted inserted replaced
152:4c132ee2d62b 153:25f70ba0133c
1 ;;; tex.el --- Support for TeX documents. 1 ;;; tex.el --- Support for TeX documents.
2 2
3 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk> 3 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk>
4 ;; Version: 9.7l 4 ;; Version: 9.7p
5 ;; Keywords: wp 5 ;; Keywords: wp
6 ;; X-URL: http://sunsite.auc.dk/auctex 6 ;; X-URL: http://sunsite.auc.dk/auctex
7 7
8 ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc. 8 ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
9 ;; Copyright (C) 1987 Lars Peter Fischer 9 ;; Copyright (C) 1987 Lars Peter Fischer
24 ;; along with this program; if not, write to the Free Software 24 ;; along with this program; if not, write to the Free Software
25 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 26
27 ;;; Code: 27 ;;; Code:
28 28
29 (eval-and-compile
30 (condition-case ()
31 (require 'custom)
32 (error nil))
33 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
34 nil ;; We've got what we needed
35 ;; We have the old custom-library, hack around it!
36 (defmacro defgroup (&rest args)
37 nil)
38 (defmacro defcustom (var value doc &rest args)
39 (` (defvar (, var) (, value) (, doc))))))
40
41 (defgroup AUC-TeX nil
42 "A (La)TeX environment."
43 :tag "AUC TeX"
44 :link '(custom-manual "(auctex)Top")
45 :link '(url-link :tag "Home Page" "http://sunsite.auc.dk/auctex/")
46 :prefix "TeX-"
47 :group 'tex)
48
49 (defgroup TeX-file nil
50 "Files used by AUC TeX."
51 :group 'AUC-TeX)
52
53 (defgroup TeX-command nil
54 "Calling external commands from AUC TeX."
55 :group 'AUC-TeX)
56
57 (defgroup LaTeX nil
58 "LaTeX support in AUC TeX."
59 :tag "LaTeX"
60 :group 'AUC-TeX)
61
29 ;;; Site Customization 62 ;;; Site Customization
30 ;; 63 ;;
31 ;; The following variables are likely to need to be changed for your 64 ;; The following variables are likely to need to be changed for your
32 ;; site. It is suggested that you do this by *not* changing this 65 ;; site. It is suggested that you do this by *not* changing this
33 ;; file, but instead copy those definitions you need to change to 66 ;; file, but instead copy those definitions you need to change to
34 ;; `tex-site.el'. 67 ;; `tex-site.el'.
35 68
36 (defvar TeX-lisp-directory (concat data-directory "auctex/") 69 (defcustom TeX-lisp-directory (concat data-directory "auctex/")
37 "*The directory where the AUC TeX lisp files are located.") 70 "*The directory where the AUC TeX lisp files are located."
71 :group 'TeX-file
72 :type 'directory)
38 73
39 ;; Change this to point to the place where the TeX macros are stored 74 ;; Change this to point to the place where the TeX macros are stored
40 ;; at yourt site. [Ignore when bundled with XEmacs] 75 ;; at yourt site. [Ignore when bundled with XEmacs]
41 (defvar TeX-macro-global '("/usr/lib/texmf/tex/") 76 (defcustom TeX-macro-global '("/usr/lib/texmf/tex/")
42 "*Directories containing the sites TeX macro files and style files. 77 "*Directories containing the sites TeX macro files and style files.
43 78 The directory names *must* end with a slash."
44 The directory names *must* end with a slash.") 79 :group 'TeX-file
80 :type '(repeat (directory :format "%v")))
45 81
46 ;; How to print. 82 ;; How to print.
47 83
48 (defvar TeX-print-command "dvips %s -P%p" 84 (defcustom TeX-print-command "dvips %s -P%p"
49 "*Command used to print a file. 85 "*Command used to print a file.
50 86
51 First %p is expanded to the printer name, then ordinary expansion is 87 First %p is expanded to the printer name, then ordinary expansion is
52 performed as specified in TeX-expand-list.") 88 performed as specified in TeX-expand-list."
53 89 :group 'TeX-command
54 (defvar TeX-queue-command "lpq -P%p" 90 :type 'string)
91
92 (defcustom TeX-queue-command "lpq -P%p"
55 "*Command used to show the status of a printer queue. 93 "*Command used to show the status of a printer queue.
56 94
57 First %p is expanded to the printer name, then ordinary expansion is 95 First %p is expanded to the printer name, then ordinary expansion is
58 performed as specified in TeX-expand-list.") 96 performed as specified in TeX-expand-list."
97 :group 'TeX-command
98 :type 'string)
59 99
60 ;; This is the major configuration variable. Most sites will only 100 ;; This is the major configuration variable. Most sites will only
61 ;; need to change the second string in each entry, which is the name 101 ;; need to change the second string in each entry, which is the name
62 ;; of a command to send to the shell. If you use other formatters 102 ;; of a command to send to the shell. If you use other formatters
63 ;; like AMSLaTeX or AMSTeX, you can add those to the list. See 103 ;; like AMSLaTeX or AMSTeX, you can add those to the list. See
64 ;; TeX-expand-list for a description of the % escapes 104 ;; TeX-expand-list for a description of the % escapes
65 105
66 (defvar TeX-command-list 106 (defcustom TeX-command-list
67 ;; You may have to remove the single quotes around the command 107 ;; You may have to remove the single quotes around the command
68 ;; arguments if you use DOS. 108 ;; arguments if you use DOS.
69 (list (list "TeX" "tex '\\nonstopmode\\input %t'" 'TeX-run-TeX nil t) 109 (list (list "TeX" "tex '\\nonstopmode\\input %t'" 'TeX-run-TeX nil t)
70 (list "TeX Interactive" "tex %t" 'TeX-run-interactive nil t) 110 (list "TeX Interactive" "tex %t" 'TeX-run-interactive nil t)
71 (list "LaTeX" "%l '\\nonstopmode\\input{%t}'" 111 (list "LaTeX" "%l '\\nonstopmode\\input{%t}'"
89 (list "Other" "" 'TeX-run-command t t) 129 (list "Other" "" 'TeX-run-command t t)
90 ;; Not part of standard TeX. 130 ;; Not part of standard TeX.
91 (list "Makeinfo" "makeinfo %t" 'TeX-run-compile nil t) 131 (list "Makeinfo" "makeinfo %t" 'TeX-run-compile nil t)
92 (list "AmSTeX" "amstex '\\nonstopmode\\input %t'" 132 (list "AmSTeX" "amstex '\\nonstopmode\\input %t'"
93 'TeX-run-TeX nil t)) 133 'TeX-run-TeX nil t))
94 "*List of commands to execute on the current document. 134 "List of commands to execute on the current document.
95 135
96 Each element is a list, whose first element is the name of the command 136 Each element is a list, whose first element is the name of the command
97 as it will be presented to the user. 137 as it will be presented to the user.
98 138
99 The second element is the string handed to the shell after being 139 The second element is the string handed to the shell after being
137 create an asynchronous process. 177 create an asynchronous process.
138 178
139 If the fourth element is non-nil, the user will get a chance to 179 If the fourth element is non-nil, the user will get a chance to
140 modify the expanded string. 180 modify the expanded string.
141 181
142 The fifth element is obsolete and ignored.") 182 The fifth element is obsolete and ignored."
183 :group 'TeX-command
184 :type '(repeat (group (string :tag "Name")
185 (string :tag "Command")
186 (choice :tag "How"
187 :value TeX-run-command
188 (function-item TeX-run-command)
189 (function-item TeX-run-format)
190 (function-item TeX-run-TeX)
191 (function-item TeX-run-LaTeX)
192 (function-item TeX-run-interactive)
193 (function-item TeX-run-BibTeX)
194 (function-item TeX-run-compile)
195 (function-item TeX-run-shell)
196 (function-item TeX-run-discard)
197 (function-item TeX-run-background)
198 (function-item TeX-run-dviout)
199 (function :tag "Other"))
200 (boolean :tag "Prompt")
201 (sexp :format "End\n"))))
202
143 203
144 ;; You may want to change the default LaTeX version for your site. 204 ;; You may want to change the default LaTeX version for your site.
145 (defvar LaTeX-version "2e" 205 (defcustom LaTeX-version "2e"
146 "Default LaTeX version. Currently recognized is \"2\" and \"2e\".") 206 "Default LaTeX version. Currently recognized is \"2\" and \"2e\"."
207 :group 'LaTeX
208 :type '(radio (const :format "%v\n%h"
209 :doc "\
210 The executable `latex' is LaTeX version 2."
211 "2")
212 (const :format "%v\n%h"
213 :doc "\
214 The executable `latex' is LaTeX version 2e.
215 Do *not* select this if you need to run `latex2e' in order to get
216 LaTeX version 2e."
217 "2e")
218 (string :tag "Other")))
219
147 220
148 ;; You may want special options to the view command depending on the 221 ;; You may want special options to the view command depending on the
149 ;; style options. Only works if parsing is enabled. 222 ;; style options. Only works if parsing is enabled.
150 223
151 (defvar LaTeX-command-style 224 (defcustom LaTeX-command-style
152 (if (string-equal LaTeX-version "2") 225 (if (string-equal LaTeX-version "2")
153 ;; There is a lot of different LaTeX 2 based formats. 226 ;; There is a lot of different LaTeX 2 based formats.
154 '(("^latex2e$" "latex2e") 227 '(("^latex2e$" "latex2e")
155 ("^foils$" "foiltex") 228 ("^foils$" "foiltex")
156 ("^ams" "amslatex") 229 ("^ams" "amslatex")
157 ("^slides$" "slitex") 230 ("^slides$" "slitex")
158 ("^plfonts\\|plhb$" "platex") 231 ("^plfonts\\|plhb$" "platex")
159 ("." "latex")) 232 ("." "latex"))
160 ;; They have all been combined in LaTeX 2e. 233 ;; They have all been combined in LaTeX 2e.
161 '(("." "latex"))) 234 '(("." "latex")))
162 "*List of style options and LaTeX commands. 235 "List of style options and LaTeX commands.
163 236
164 If the first element (a regular expresion) matches the name of one of 237 If the first element (a regular expresion) matches the name of one of
165 the style files, any occurrence of the string %l in a command in 238 the style files, any occurrence of the string %l in a command in
166 TeX-command-list will be replaced with the second element. The first 239 TeX-command-list will be replaced with the second element. The first
167 match is used, if no match is found the %l is replaced with the empty 240 match is used, if no match is found the %l is replaced with the empty
168 string.") 241 string."
242 :group 'TeX-command
243 :type '(repeat (group :value ("" "")
244 regexp (string :tag "Style"))))
169 245
170 ;; Enter the names of the printers available at your site, or nil if 246 ;; Enter the names of the printers available at your site, or nil if
171 ;; you only have one printer. 247 ;; you only have one printer.
172 248
173 (defvar TeX-printer-list 249 (defcustom TeX-printer-list
174 '(("Local" "dvips -f %s | lpr" "lpq") 250 '(("Local" "dvips -f %s | lpr" "lpq")
175 ("lw") ("ps")) 251 ("lw") ("ps"))
176 "*List of available printers. 252 "List of available printers.
177 253
178 The first element of each entry is the printer name. 254 The first element of each entry is the printer name.
179 255
180 The second element is the command used to print to this 256 The second element is the command used to print to this
181 printer. It defaults to the value of TeX-print-command. 257 printer. It defaults to the value of TeX-print-command.
183 The third element is the command used to examine the print queue for 259 The third element is the command used to examine the print queue for
184 this printer. It defaults to the value of TeX-queue-command. 260 this printer. It defaults to the value of TeX-queue-command.
185 261
186 Any occurence of `%p' in the second or third element is expanded to 262 Any occurence of `%p' in the second or third element is expanded to
187 the printer name given in the first element, then ordinary expansion 263 the printer name given in the first element, then ordinary expansion
188 is performed as specified in TeX-expand-list.") 264 is performed as specified in TeX-expand-list."
265 :group 'TeX-command
266 :type '(repeat (group (string :tag "Name")
267 (option (group :inline t
268 :extra-offset -4
269 (choice :tag "Print"
270 (const :tag "default")
271 (string :format "%v"))
272 (option (choice :tag "Queue"
273 (const :tag "default")
274 (string
275 :format "%v"))))))))
189 276
190 ;; The name of the most used printer. 277 ;; The name of the most used printer.
191 278
192 (defvar TeX-printer-default (or (getenv "PRINTER") 279 (defcustom TeX-printer-default (or (getenv "PRINTER")
193 (and TeX-printer-list 280 (and TeX-printer-list
194 (car (car TeX-printer-list))) 281 (car (car TeX-printer-list)))
195 "lw") 282 "lw")
196 "*Default printer to use with TeX-command.") 283 "*Default printer to use with TeX-command."
284 :group 'TeX-command
285 :type 'string)
197 286
198 ;; You may want special options to the view command depending on the 287 ;; You may want special options to the view command depending on the
199 ;; style options. Only works if parsing is enabled. 288 ;; style options. Only works if parsing is enabled.
200 289
201 (defvar TeX-view-style '(("^a5$" "xdvi %d -paper a5") 290 (defcustom TeX-view-style '(("^a5$" "xdvi %d -paper a5")
202 ("^landscape$" "xdvi %d -paper a4r -s 4") 291 ("^landscape$" "xdvi %d -paper a4r -s 4")
203 ;; The latest xdvi can show embedded postscript. 292 ;; The latest xdvi can show embedded postscript.
204 ;; If you don't have that, uncomment next line. 293 ;; If you don't have that, uncomment next line.
205 ;; ("^epsf$" "ghostview %f") 294 ;; ("^epsf$" "ghostview %f")
206 ("." "xdvi %d")) 295 ("." "xdvi %d"))
207 "*List of style options and view options. 296 "List of style options and view options.
208 297
209 If the first element (a regular expresion) matches the name of one of 298 If the first element (a regular expresion) matches the name of one of
210 the style files, any occurrence of the string %v in a command in 299 the style files, any occurrence of the string %v in a command in
211 TeX-command-list will be replaced with the second element. The first 300 TeX-command-list will be replaced with the second element. The first
212 match is used, if no match is found the %v is replaced with the empty 301 match is used, if no match is found the %v is replaced with the empty
213 string.") 302 string."
303 :group 'TeX-command
304 :type '(repeat (group regexp (string :tag "Command"))))
214 305
215 ;; This is the list of expansion for the commands in 306 ;; This is the list of expansion for the commands in
216 ;; TeX-command-list. Not likely to be changed, but you may e.g. want 307 ;; TeX-command-list. Not likely to be changed, but you may e.g. want
217 ;; to handle .ps files. 308 ;; to handle .ps files.
218 309
219 (defvar TeX-expand-list 310 (defcustom TeX-expand-list
220 (list (list "%p" 'TeX-printer-query) ;%p must be the first entry 311 (list (list "%p" 'TeX-printer-query) ;%p must be the first entry
221 (list "%q" (function (lambda () 312 (list "%q" (function (lambda ()
222 (TeX-printer-query TeX-queue-command 2)))) 313 (TeX-printer-query TeX-queue-command 2))))
223 (list "%v" 'TeX-style-check TeX-view-style) 314 (list "%v" 'TeX-style-check TeX-view-style)
224 (list "%l" 'TeX-style-check LaTeX-command-style) 315 (list "%l" 'TeX-style-check LaTeX-command-style)
225 (list "%s" 'file nil t) 316 (list "%s" 'file nil t)
226 (list "%t" 'file 't t) 317 (list "%t" 'file 't t)
227 (list "%d" 'file "dvi" t) 318 (list "%d" 'file "dvi" t)
228 (list "%f" 'file "ps" t)) 319 (list "%f" 'file "ps" t))
229 "*List of expansion strings for TeX command names. 320 "List of expansion strings for TeX command names.
230 321
231 Each entry is a list with two or more elements. The first element is 322 Each entry is a list with two or more elements. The first element is
232 the string to be expanded. The second element is the name of a 323 the string to be expanded. The second element is the name of a
233 function returning the expanded string when called with the remaining 324 function returning the expanded string when called with the remaining
234 elements as arguments. The special value `file' will be expanded to 325 elements as arguments. The special value `file' will be expanded to
235 the name of the file being processed, with an optional extension.") 326 the name of the file being processed, with an optional extension."
327 :group 'TeX-command
328 :type '(repeat (group (string :tag "Key")
329 (sexp :tag "Expander")
330 (repeat :inline t
331 :tag "Arguments"
332 (sexp :format "%v")))))
236 333
237 ;; End of Site Customization. 334 ;; End of Site Customization.
238 335
239 ;;; Import 336 ;;; Import
240 337
484 ;;; Version 581 ;;; Version
485 582
486 ;; These two variables are automatically updated with "make dist", so 583 ;; These two variables are automatically updated with "make dist", so
487 ;; be careful before changing anything. 584 ;; be careful before changing anything.
488 585
489 (defconst AUC-TeX-version "9.7l" 586 (defconst AUC-TeX-version "9.7p"
490 "AUC TeX version number") 587 "AUC TeX version number")
491 588
492 (defconst AUC-TeX-date "Tue Mar 4 11:29:28 MET 1997" 589 (defconst AUC-TeX-date "Thu Apr 17 14:25:49 MET DST 1997"
493 "AUC TeX release date") 590 "AUC TeX release date")
494 591
495 ;;; Buffer 592 ;;; Buffer
496 593
497 (defvar TeX-display-help t 594 (defgroup TeX-output nil
498 "*Non-nil means popup help when stepping thrugh errors with \\[TeX-next-error]") 595 "Parsing TeX output."
499 596 :prefix "TeX-"
500 (defvar TeX-debug-bad-boxes nil 597 :group 'AUC-TeX)
501 "*Non-nil means also find overfull/underfull boxes warnings with TeX-next-error") 598
502 599 (defcustom TeX-display-help t
503 (defvar TeX-command-BibTeX "BibTeX" 600 "*Non-nil means popup help when stepping thrugh errors with
504 "*The name of the BibTeX entry in TeX-command-list.") 601 \\[TeX-next-error]"
602 :group 'TeX-output
603 :type 'boolean)
604
605 (defcustom TeX-debug-bad-boxes nil
606 "*Non-nil means also find overfull/underfull boxes warnings with
607 TeX-next-error"
608 :group 'TeX-output
609 :type 'boolean)
610
611 (defgroup TeX-command-name nil
612 "Names for external commands in AUC TeX."
613 :group 'TeX-command)
614
615 (defcustom TeX-command-BibTeX "BibTeX"
616 "*The name of the BibTeX entry in TeX-command-list."
617 :group 'TeX-command-name
618 :type 'string)
505 (make-variable-buffer-local 'TeX-command-BibTeX) 619 (make-variable-buffer-local 'TeX-command-BibTeX)
506 620
507 (defvar TeX-command-Show "View" 621 (defcustom TeX-command-Show "View"
508 "*The default command to show (view or print) a TeX file. 622 "*The default command to show (view or print) a TeX file.
509 Must be the car of an entry in TeX-command-list.") 623 Must be the car of an entry in TeX-command-list."
624 :group 'TeX-command-name
625 :type 'string)
510 (make-variable-buffer-local 'TeX-command-Show) 626 (make-variable-buffer-local 'TeX-command-Show)
511 627
512 (defvar TeX-command-Print "Print" 628 (defcustom TeX-command-Print "Print"
513 "The name of the Print entry in TeX-command-Print.") 629 "The name of the Print entry in TeX-command-Print."
514 630 :group 'TeX-command-name
515 (defvar TeX-command-Queue "Queue" 631 :type 'string)
516 "The name of the Queue entry in TeX-command-Queue.") 632
633 (defcustom TeX-command-Queue "Queue"
634 "The name of the Queue entry in TeX-command-Queue."
635 :group 'TeX-command-name
636 :type 'string)
517 637
518 (autoload 'TeX-region-create "tex-buf" no-doc nil) 638 (autoload 'TeX-region-create "tex-buf" no-doc nil)
519 (autoload 'TeX-save-document "tex-buf" no-doc t) 639 (autoload 'TeX-save-document "tex-buf" no-doc t)
520 (autoload 'TeX-home-buffer "tex-buf" no-doc t) 640 (autoload 'TeX-home-buffer "tex-buf" no-doc t)
521 (autoload 'TeX-command-region "tex-buf" no-doc t) 641 (autoload 'TeX-command-region "tex-buf" no-doc t)
544 (make-variable-buffer-local 'TeX-command-default) 664 (make-variable-buffer-local 'TeX-command-default)
545 665
546 666
547 ;;; Master File 667 ;;; Master File
548 668
549 (defvar TeX-one-master "\\.tex$" 669 (defcustom TeX-one-master "\\.tex$"
550 "*Regular expression matching ordinary TeX files. 670 "*Regular expression matching ordinary TeX files.
551 671
552 You should set this variable to match the name of all files, where 672 You should set this variable to match the name of all files, where
553 automatically adding a file variable with the name of the master file 673 automatically adding a file variable with the name of the master file
554 is a good idea. When AUC TeX add the name of the master file as a 674 is a good idea. When AUC TeX add the name of the master file as a
555 file variable, it does not need to ask next time you edit the file. 675 file variable, it does not need to ask next time you edit the file.
556 676
557 If you dislike AUC TeX automatically modifying your files, you can set 677 If you dislike AUC TeX automatically modifying your files, you can set
558 this variable to \"<none>\".") 678 this variable to \"<none>\"."
679 :group 'TeX-command
680 :type 'regexp)
559 681
560 (defun TeX-master-file (&optional extension nondirectory) 682 (defun TeX-master-file (&optional extension nondirectory)
561 "Return the name of the master file for the current document. 683 "Return the name of the master file for the current document.
562 684
563 If optional argument EXTENSION is non-nil, add that file extension to 685 If optional argument EXTENSION is non-nil, add that file extension to
657 (abbreviate-file-name 779 (abbreviate-file-name
658 (expand-file-name 780 (expand-file-name
659 (concat (file-name-directory buffer-file-name) 781 (concat (file-name-directory buffer-file-name)
660 (file-name-directory (TeX-master-file)))))) 782 (file-name-directory (TeX-master-file))))))
661 783
662 (defvar TeX-master t 784 (defcustom TeX-master t
663 "*The master file associated with the current buffer. 785 "*The master file associated with the current buffer.
664 If the file being edited is actually included from another file, you 786 If the file being edited is actually included from another file, you
665 can tell AUC TeX the name of the master file by setting this variable. 787 can tell AUC TeX the name of the master file by setting this variable.
666 If there are multiple levels of nesting, specify the top level file. 788 If there are multiple levels of nesting, specify the top level file.
667 789
672 794
673 If the variable is 'shared, AUC TeX will query for the name, but not 795 If the variable is 'shared, AUC TeX will query for the name, but not
674 change the file. 796 change the file.
675 797
676 It is suggested that you use the File Variables (see the info node in 798 It is suggested that you use the File Variables (see the info node in
677 the Emacs manual) to set this variable permanently for each file.") 799 the Emacs manual) to set this variable permanently for each file."
800 :group 'TeX-command
801 :group 'TeX-parse
802 :type '(choice (const :tag "Query" nil)
803 (const :tag "This file" t)
804 (const :tag "Shared" shared)
805 (string :format "%v")))
678 806
679 (make-variable-buffer-local 'TeX-master) 807 (make-variable-buffer-local 'TeX-master)
680 808
681 (defvar TeX-convert-master t 809 (defvar TeX-convert-master t
682 "*If not nil, automatically convert ``Master:'' lines to file variables. 810 "*If not nil, automatically convert ``Master:'' lines to file variables.
707 ;;; Style Paths 835 ;;; Style Paths
708 836
709 (or (string-match "/\\'" TeX-lisp-directory) 837 (or (string-match "/\\'" TeX-lisp-directory)
710 (setq TeX-lisp-directory (concat TeX-lisp-directory "/"))) 838 (setq TeX-lisp-directory (concat TeX-lisp-directory "/")))
711 839
712 (defvar TeX-auto-global (concat TeX-lisp-directory "auto/") 840 (defcustom TeX-auto-global (concat TeX-lisp-directory "auto/")
713 "*Directory containing automatically generated information. 841 "*Directory containing automatically generated information.
714 Must end with a slash. 842 Must end with a slash.
715 843
716 For storing automatic extracted information about the TeX macros 844 For storing automatic extracted information about the TeX macros
717 shared by all users of a site.") 845 shared by all users of a site."
718 846 :group 'TeX-file
719 (defvar TeX-style-global (concat TeX-lisp-directory "style/") 847 :type 'directory)
848
849 (defcustom TeX-style-global (concat TeX-lisp-directory "style/")
720 "*Directory containing hand generated TeX information. 850 "*Directory containing hand generated TeX information.
721 Must end with a slash. 851 Must end with a slash.
722 852
723 These correspond to TeX macros shared by all users of a site.") 853 These correspond to TeX macros shared by all users of a site."
724 854 :group 'TeX-file
725 (defvar TeX-auto-local "auto/" 855 :type 'directory)
856
857 (defcustom TeX-auto-local "auto/"
726 "*Directory containing automatically generated TeX information. 858 "*Directory containing automatically generated TeX information.
727 Must end with a slash. 859 Must end with a slash.
728 860
729 This correspond to TeX macros found in the current directory.") 861 This correspond to TeX macros found in the current directory."
730 862 :group 'TeX-file
731 (defvar TeX-style-local "style/" 863 :type 'string)
864
865 (defcustom TeX-style-local "style/"
732 "*Directory containing hand generated TeX information. 866 "*Directory containing hand generated TeX information.
733 Must end with a slash. 867 Must end with a slash.
734 868
735 These correspond to TeX macros found in the current directory.") 869 These correspond to TeX macros found in the current directory."
870 :group 'TeX-file
871 :type 'string)
736 872
737 (defun TeX-split-string (regexp string) 873 (defun TeX-split-string (regexp string)
738 "Returns a list of strings. given REGEXP the STRING is split into 874 "Returns a list of strings. given REGEXP the STRING is split into
739 sections which in string was seperated by REGEXP. 875 sections which in string was seperated by REGEXP.
740 876
782 (member entry TeX-macro-global) 918 (member entry TeX-macro-global)
783 (string-equal "/" entry) 919 (string-equal "/" entry)
784 (setq answers (cons entry answers)))) 920 (setq answers (cons entry answers))))
785 answers)) 921 answers))
786 922
787 (defvar TeX-macro-private (append (TeX-parse-path "TEXINPUTS") 923 (defcustom TeX-macro-private (append (TeX-parse-path "TEXINPUTS")
788 (TeX-parse-path "BIBINPUTS")) 924 (TeX-parse-path "BIBINPUTS"))
789 "*Directories where you store your personal TeX macros. 925 "Directories where you store your personal TeX macros.
790 Each must end with a slash.") 926 Each must end with a slash."
791 927 :group 'TeX-file
792 (defvar TeX-auto-private (mapcar (function (lambda (entry) 928 :type '(repeat (file :format "%v")))
793 (concat entry TeX-auto-local))) 929
794 TeX-macro-private) 930 (defcustom TeX-auto-private (mapcar (function (lambda (entry)
795 "*List of directories containing automatically generated information. 931 (concat entry TeX-auto-local)))
932 TeX-macro-private)
933 "List of directories containing automatically generated information.
796 Must end with a slash. 934 Must end with a slash.
797 935
798 These correspond to the personal TeX macros.") 936 These correspond to the personal TeX macros."
937 :group 'TeX-file
938 :type '(repeat (file :format "%v")))
799 939
800 (if (stringp TeX-auto-private) ;Backward compatibility 940 (if (stringp TeX-auto-private) ;Backward compatibility
801 (setq TeX-auto-private (list TeX-auto-private))) 941 (setq TeX-auto-private (list TeX-auto-private)))
802 942
803 (defvar TeX-style-private (mapcar (function (lambda (entry) 943 (defcustom TeX-style-private (mapcar (function (lambda (entry)
804 (concat entry 944 (concat entry
805 TeX-style-local))) 945 TeX-style-local)))
806 TeX-macro-private) 946 TeX-macro-private)
807 "*List of directories containing hand generated information. 947 "List of directories containing hand generated information.
808 Must end with a slash. 948 Must end with a slash.
809 949
810 These correspond to the personal TeX macros.") 950 These correspond to the personal TeX macros."
951 :group 'TeX-file
952 :type '(repeat (file :format "%v")))
811 953
812 (if (stringp TeX-style-private) ;Backward compatibility 954 (if (stringp TeX-style-private) ;Backward compatibility
813 (setq TeX-style-private (list TeX-style-private))) 955 (setq TeX-style-private (list TeX-style-private)))
814 956
815 (defvar TeX-style-path 957 (defcustom TeX-style-path
816 (let ((path)) 958 (let ((path))
817 (mapcar (function (lambda (file) (if file (setq path (cons file path))))) 959 (mapcar (function (lambda (file) (if file (setq path (cons file path)))))
818 (append (list TeX-auto-global TeX-style-global) 960 (append (list TeX-auto-global TeX-style-global)
819 TeX-auto-private TeX-style-private 961 TeX-auto-private TeX-style-private
820 (list TeX-auto-local TeX-style-local))) 962 (list TeX-auto-local TeX-style-local)))
821 path) 963 path)
822 "*List of directories to search for AUC TeX style files.") 964 "List of directories to search for AUC TeX style files."
823 965 :group 'TeX-file
824 (defvar TeX-check-path (append (list "./") TeX-macro-private TeX-macro-global) 966 :type '(repeat (file :format "%v")))
825 "*Directory path to search for dependencies. 967
968 (defcustom TeX-check-path
969 (append (list "./") TeX-macro-private TeX-macro-global)
970 "Directory path to search for dependencies.
826 971
827 If nil, just check the current file. 972 If nil, just check the current file.
828 Used when checking if any files have changed.") 973 Used when checking if any files have changed."
974 :group 'TeX-file
975 :type '(repeat (file :format "%v")))
829 976
830 ;;; Style Files 977 ;;; Style Files
831 978
832 (defvar TeX-style-hook-list nil 979 (defvar TeX-style-hook-list nil
833 "List of TeX style hooks currently loaded. 980 "List of TeX style hooks currently loaded.
834 981
835 Each entry is a list where the first element is the name of the style, 982 Each entry is a list where the first element is the name of the style,
836 and the remaining elements are hooks to be run when that style is 983 and the remaining elements are hooks to be run when that style is
837 active.") 984 active.")
838 985
839 (defvar TeX-byte-compile nil 986 (defcustom TeX-byte-compile nil
840 "*Not nil means try to byte compile auto files before loading.") 987 "*Not nil means try to byte compile auto files before loading."
988 :group 'TeX-parse
989 :type 'boolean)
841 990
842 (defun TeX-load-style (style) 991 (defun TeX-load-style (style)
843 "Search for and load each definition for style in TeX-style-path." 992 "Search for and load each definition for style in TeX-style-path."
844 (cond ((assoc style TeX-style-hook-list)) ; We already found it 993 (cond ((assoc style TeX-style-hook-list)) ; We already found it
845 ((string-match "\\`\\(.+/\\)\\([^/]*\\)\\'" style) ;Complex path 994 ((string-match "\\`\\(.+/\\)\\([^/]*\\)\\'" style) ;Complex path
892 (let ((entry TeX-style-hook-list)) 1041 (let ((entry TeX-style-hook-list))
893 (while (not (equal (car (car (cdr entry))) style)) 1042 (while (not (equal (car (car (cdr entry))) style))
894 (setq entry (cdr entry))) 1043 (setq entry (cdr entry)))
895 (setcdr entry (cdr (cdr entry))))))) 1044 (setcdr entry (cdr (cdr entry)))))))
896 1045
897 (defvar TeX-virgin-style (if (and TeX-auto-global 1046 (defcustom TeX-virgin-style (if (and TeX-auto-global
898 (file-directory-p TeX-auto-global)) 1047 (file-directory-p TeX-auto-global))
899 "virtex" 1048 "virtex"
900 "NoVirtexSymbols") 1049 "NoVirtexSymbols")
901 "Style all documents use.") 1050 "Style all documents use."
1051 :group 'TeX-parse
1052 :type 'string)
902 1053
903 (defvar TeX-active-styles nil 1054 (defvar TeX-active-styles nil
904 "List of styles currently active in the document.") 1055 "List of styles currently active in the document.")
905 1056
906 (make-variable-buffer-local 'TeX-active-styles) 1057 (make-variable-buffer-local 'TeX-active-styles)
919 (substring style (match-beginning 2) (match-end 2)))) 1070 (substring style (match-beginning 2) (match-end 2))))
920 (mapcar 'funcall 1071 (mapcar 'funcall
921 (cdr-safe (assoc style TeX-style-hook-list)))))) 1072 (cdr-safe (assoc style TeX-style-hook-list))))))
922 styles)) 1073 styles))
923 1074
924 (defvar TeX-parse-self nil 1075 (defcustom TeX-parse-self nil
925 "*Parse file after loading it if no style hook is found for it.") 1076 "Parse file after loading it if no style hook is found for it."
1077 :group 'TeX-parse
1078 :type 'boolean)
926 1079
927 (defvar TeX-style-hook-applied-p nil 1080 (defvar TeX-style-hook-applied-p nil
928 "Nil, unless the style specific hooks have been applied.") 1081 "Nil, unless the style specific hooks have been applied.")
929 (make-variable-buffer-local 'TeX-style-hook-applied-p) 1082 (make-variable-buffer-local 'TeX-style-hook-applied-p)
930 1083
982 1135
983 ;;; Symbols 1136 ;;; Symbols
984 1137
985 ;; Must be before keymaps. 1138 ;; Must be before keymaps.
986 1139
987 (defvar TeX-complete-word 'ispell-complete-word 1140 (defgroup TeX-macro nil
988 "*Function to call for completing non-macros in tex-mode.") 1141 "Support for TeX macros in AUC TeX."
1142 :prefix "TeX-"
1143 :group 'TeX)
1144
1145 (defcustom TeX-complete-word 'ispell-complete-word
1146 "*Function to call for completing non-macros in tex-mode."
1147 :group 'TeX-macro)
989 1148
990 (defvar TeX-complete-list nil 1149 (defvar TeX-complete-list nil
991 "List of ways to complete the preceding text. 1150 "List of ways to complete the preceding text.
992 1151
993 Each entry is a list with the following elements: 1152 Each entry is a list with the following elements:
1040 (with-output-to-temp-buffer "*Completions*" 1199 (with-output-to-temp-buffer "*Completions*"
1041 (display-completion-list list))) 1200 (display-completion-list list)))
1042 (message "Making completion list...done")))) 1201 (message "Making completion list...done"))))
1043 (funcall (nth 1 entry))))) 1202 (funcall (nth 1 entry)))))
1044 1203
1045 (defvar TeX-default-macro "ref" 1204 (defcustom TeX-default-macro "ref"
1046 "*The default macro when creating new ones with TeX-insert-macro.") 1205 "*The default macro when creating new ones with TeX-insert-macro."
1206 :group 'TeX-macro
1207 :type 'string)
1047 1208
1048 (make-variable-buffer-local 'TeX-default-macro) 1209 (make-variable-buffer-local 'TeX-default-macro)
1049 1210
1050 (defvar TeX-insert-braces t 1211 (defcustom TeX-insert-braces t
1051 "*If non-nil, append a empty pair of braces after inserting a macro.") 1212 "*If non-nil, append a empty pair of braces after inserting a macro."
1213 :group 'TeX-macro
1214 :type 'string)
1052 1215
1053 (defun TeX-math-mode-p () 1216 (defun TeX-math-mode-p ()
1054 "Are we in TeX math mode?" 1217 "Are we in TeX math mode?"
1055 ;; This should check for dollar signs, but thats to hard for now. 1218 ;; This should check for dollar signs, but thats to hard for now.
1056 (and (boundp 'LaTeX-math-mode) LaTeX-math-mode)) 1219 (and (boundp 'LaTeX-math-mode) LaTeX-math-mode))
1250 3. A regexp typically matched in the beginning of the file. 1413 3. A regexp typically matched in the beginning of the file.
1251 1414
1252 When entering tex-mode, each regexp is tried in turn in order to find 1415 When entering tex-mode, each regexp is tried in turn in order to find
1253 when major mode to enter.") 1416 when major mode to enter.")
1254 1417
1255 (defvar TeX-default-mode 'latex-mode 1418 (defcustom TeX-default-mode 'latex-mode
1256 "*Mode to enter for a new file when it can't be determined whether 1419 "*Mode to enter for a new file when it can't be determined whether
1257 the file is plain TeX or LaTeX or what.") 1420 the file is plain TeX or LaTeX or what."
1258 1421 :group 'AUC-TeX
1259 (defvar TeX-force-default-mode nil 1422 :type '(radio (function-item latex-mode)
1260 "*If set to nil, try to infer the mode of the file from its content.") 1423 (function-item plain-tex-mode)
1424 (function :tag "Other")))
1425
1426 (defcustom TeX-force-default-mode nil
1427 "*If set to nil, try to infer the mode of the file from its
1428 content."
1429 :group 'AUC-TeX
1430 :type 'boolean)
1261 1431
1262 ;;; Do not ;;;###autoload because of conflict with standard tex-mode.el. 1432 ;;; Do not ;;;###autoload because of conflict with standard tex-mode.el.
1263 (defun tex-mode () 1433 (defun tex-mode ()
1264 "Major mode for editing files of input for TeX or LaTeX. 1434 "Major mode for editing files of input for TeX or LaTeX.
1265 Tries to guess whether this file is for plain TeX or LaTeX. 1435 Tries to guess whether this file is for plain TeX or LaTeX.
1442 (append (list (cons 'ams-tex-mode plain-tex-patterns)) 1612 (append (list (cons 'ams-tex-mode plain-tex-patterns))
1443 hilit-patterns-alist))))) 1613 hilit-patterns-alist)))))
1444 1614
1445 ;;; Parsing 1615 ;;; Parsing
1446 1616
1617 (defgroup TeX-parse nil
1618 "Parsing TeX files from AUC TeX."
1619 :group 'AUC-TeX)
1620
1447 (defvar TeX-auto-parser '((styles TeX-auto-file TeX-run-style-hooks))) 1621 (defvar TeX-auto-parser '((styles TeX-auto-file TeX-run-style-hooks)))
1448 ;; Alist of parsed information. 1622 ;; Alist of parsed information.
1449 ;; Each entry is a list with the following elements: 1623 ;; Each entry is a list with the following elements:
1450 ;; 1624 ;;
1451 ;; 0. Name of information type. 1625 ;; 0. Name of information type.
1558 (TeX-auto-write)) 1732 (TeX-auto-write))
1559 (error nil)) 1733 (error nil))
1560 ;; Continue with the other write file hooks. 1734 ;; Continue with the other write file hooks.
1561 nil) 1735 nil)
1562 1736
1563 (defvar TeX-auto-save nil 1737 (defcustom TeX-auto-save nil
1564 "*Automatically save style information when saving the buffer.") 1738 "*Automatically save style information when saving the buffer."
1565 1739 :group 'TeX-parse
1566 (defvar TeX-auto-untabify t 1740 :type 'boolean)
1567 "*Automatically untabify when saving the buffer.") 1741
1742 (defcustom TeX-auto-untabify t
1743 "*Automatically untabify when saving the buffer."
1744 :group 'TeX-parse
1745 :type 'boolean)
1568 1746
1569 (defun TeX-auto-write () 1747 (defun TeX-auto-write ()
1570 ;; Save all relevant TeX information from the current buffer. 1748 ;; Save all relevant TeX information from the current buffer.
1571 (if TeX-auto-untabify 1749 (if TeX-auto-untabify
1572 (untabify (point-min) (point-max))) 1750 (untabify (point-min) (point-max)))
1586 (save-excursion 1764 (save-excursion
1587 (TeX-update-style) 1765 (TeX-update-style)
1588 (TeX-auto-store file)) 1766 (TeX-auto-store file))
1589 (message "Can't write style information."))))) 1767 (message "Can't write style information.")))))
1590 1768
1591 (defvar TeX-macro-default (car-safe TeX-macro-private) 1769 (defcustom TeX-macro-default (car-safe TeX-macro-private)
1592 "*Default directory to search for TeX macros.") 1770 "*Default directory to search for TeX macros."
1593 1771 :group 'TeX-file
1594 (defvar TeX-auto-default (car-safe TeX-auto-private) 1772 :type 'directory)
1595 "*Default directory to place automatically generated TeX information.") 1773
1774 (defcustom TeX-auto-default (car-safe TeX-auto-private)
1775 "*Default directory to place automatically generated TeX information."
1776 :group 'TeX-file
1777 :type 'directory)
1596 1778
1597 ;;;###autoload 1779 ;;;###autoload
1598 (defun TeX-auto-generate (tex auto) 1780 (defun TeX-auto-generate (tex auto)
1599 "Generate style file for TEX and store it in AUTO. 1781 "Generate style file for TEX and store it in AUTO.
1600 If TEX is a directory, generate style files for all files in the directory." 1782 If TEX is a directory, generate style files for all files in the directory."
1621 (mapcar (function (lambda (file) 1803 (mapcar (function (lambda (file)
1622 (if (or TeX-file-recurse 1804 (if (or TeX-file-recurse
1623 (not (file-directory-p file))) 1805 (not (file-directory-p file)))
1624 (TeX-auto-generate file auto)))) 1806 (TeX-auto-generate file auto))))
1625 files))) 1807 files)))
1808 ((not (file-newer-than-file-p tex
1809 (concat auto (if (string-match "/$" auto) "" "/")
1810 (TeX-strip-extension tex TeX-all-extensions t) ".el"))))
1626 ((TeX-match-extension tex (append TeX-file-extensions 1811 ((TeX-match-extension tex (append TeX-file-extensions
1627 BibTeX-file-extensions)) 1812 BibTeX-file-extensions))
1628 (save-excursion 1813 (save-excursion
1629 (set-buffer (find-file-noselect tex)) 1814 (set-buffer (find-file-noselect tex))
1630 (message "Parsing %s..." tex) 1815 (message "Parsing %s..." tex)
1639 1824
1640 ;;;###autoload 1825 ;;;###autoload
1641 (defun TeX-auto-generate-global () 1826 (defun TeX-auto-generate-global ()
1642 "Create global auto directory for global TeX macro definitions." 1827 "Create global auto directory for global TeX macro definitions."
1643 (interactive) 1828 (interactive)
1644 (make-directory (if (string-match "/$" TeX-auto-global) 1829 (if (file-directory-p
1830 (if (string-match "/$" TeX-auto-global)
1831 (substring TeX-auto-global 0 -1)
1832 TeX-auto-global))
1833 nil
1834 (make-directory (if (string-match "/$" TeX-auto-global)
1645 (substring TeX-auto-global 0 -1) 1835 (substring TeX-auto-global 0 -1)
1646 TeX-auto-global)) 1836 TeX-auto-global)))
1647 (mapcar (function (lambda (macro) (TeX-auto-generate macro TeX-auto-global))) 1837 (mapcar (function (lambda (macro) (TeX-auto-generate macro TeX-auto-global)))
1648 TeX-macro-global) 1838 TeX-macro-global)
1649 (byte-recompile-directory TeX-auto-global 0)) 1839 (byte-recompile-directory TeX-auto-global 0))
1650 1840
1651 (defun TeX-auto-store (file) 1841 (defun TeX-auto-store (file)
1729 "List of hooks to be called before parsing a TeX file.") 1919 "List of hooks to be called before parsing a TeX file.")
1730 1920
1731 (defvar TeX-auto-cleanup-hook nil 1921 (defvar TeX-auto-cleanup-hook nil
1732 "List of hooks to be called after parsing a TeX file.") 1922 "List of hooks to be called after parsing a TeX file.")
1733 1923
1734 (defvar TeX-auto-parse-length 999999 1924 (defcustom TeX-auto-parse-length 999999
1735 "*Maximal length of TeX file that will be parsed.") 1925 "*Maximal length of TeX file that will be parsed."
1926 :group 'TeX-parse
1927 :type 'integer)
1736 (make-variable-buffer-local 'TeX-auto-parse-length) 1928 (make-variable-buffer-local 'TeX-auto-parse-length)
1737 1929
1738 (defun TeX-auto-parse () 1930 (defun TeX-auto-parse ()
1739 "Parse TeX information in current buffer. 1931 "Parse TeX information in current buffer.
1740 1932
1807 ;;; Utilities 1999 ;;; Utilities
1808 ;; 2000 ;;
1809 ;; Some of these functions has little to do with TeX, but nonetheless we 2001 ;; Some of these functions has little to do with TeX, but nonetheless we
1810 ;; should use the "TeX-" prefix to avoid name clashes. 2002 ;; should use the "TeX-" prefix to avoid name clashes.
1811 2003
1812 (defvar TeX-auto-regexp-list 'TeX-auto-full-regexp-list 2004 (defcustom TeX-auto-regexp-list 'TeX-auto-full-regexp-list
1813 "*List of regular expresions used for parsing the current file.") 2005 "*List of regular expresions used for parsing the current file."
2006 :type '(radio (variable-item TeX-auto-empty-regexp-list)
2007 (variable-item TeX-auto-full-regexp-list)
2008 (variable-item plain-TeX-auto-regexp-list)
2009 (variable-item LaTeX-auto-minimal-regexp-list)
2010 (variable-item LaTeX-auto-label-regexp-list)
2011 (variable-item LaTeX-auto-regexp-list)
2012 (symbol :tag "Other")
2013 (repeat :tag "Specify"
2014 (group (regexp :tag "Match")
2015 (sexp :tag "Groups")
2016 symbol)))
2017 :group 'TeX-parse)
1814 (make-variable-buffer-local 'TeX-auto-regexp-list) 2018 (make-variable-buffer-local 'TeX-auto-regexp-list)
1815 2019
1816 (defvar TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "texinfo") 2020 (defgroup TeX-file-extension nil
1817 "*File extensions used by manually generated TeX files.") 2021 "File extensions recognized by AUC TeX."
1818 2022 :group 'TeX-file)
1819 (defvar TeX-all-extensions '("[^.\n]+") 2023
1820 "All possible file extensions.") 2024 (defcustom TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "texinfo")
1821 2025 "*File extensions used by manually generated TeX files."
1822 (defvar TeX-default-extension "tex" 2026 :group 'TeX-file-extension
1823 "*Default extension for TeX files.") 2027 :type '(repeat (string :format "%v")))
2028
2029 (defcustom TeX-all-extensions '("[^.\n]+")
2030 "All possible file extensions."
2031 :group 'TeX-file-extension
2032 :type '(repeat (regexp :format "%v")))
2033
2034 (defcustom TeX-default-extension "tex"
2035 "*Default extension for TeX files."
2036 :group 'TeX-file-extension
2037 :type 'string)
1824 2038
1825 (make-variable-buffer-local 'TeX-default-extension) 2039 (make-variable-buffer-local 'TeX-default-extension)
1826 2040
1827 (defvar BibTeX-file-extensions '("bib") 2041 (defcustom BibTeX-file-extensions '("bib")
1828 "Valid file extensions for BibTeX files.") 2042 "Valid file extensions for BibTeX files."
1829 2043 :group 'TeX-file-extension
1830 (defvar BibTeX-style-extensions '("bst") 2044 :type '(repeat (string :format "%v")))
1831 "Valid file extensions for BibTeX styles.") 2045
1832 2046 (defcustom BibTeX-style-extensions '("bst")
1833 (defvar TeX-ignore-file "\\(^\\|/\\)\\(\\.\\|\\.\\.\\|RCS\\|SCCS\\|CVS\\)$" 2047 "Valid file extensions for BibTeX styles."
2048 :group 'TeX-file-extension
2049 :type '(repeat (string :format "%v")))
2050
2051 (defcustom TeX-ignore-file "\\(^\\|/\\)\\(\\.\\|\\.\\.\\|RCS\\|SCCS\\|CVS\\)$"
1834 "*Regular expression matching file names to ignore. 2052 "*Regular expression matching file names to ignore.
1835 2053
1836 These files or directories will not be considered when searching for 2054 These files or directories will not be considered when searching for
1837 TeX files in a directory.") 2055 TeX files in a directory."
1838 2056 :group 'TeX-parse
1839 (defvar TeX-file-recurse t 2057 :type 'regexp)
1840 "*If not nil, search TeX directories recursivly.") 2058
2059 (defcustom TeX-file-recurse t
2060 "*If not nil, search TeX directories recursivly."
2061 :group 'TeX-parse
2062 :type 'boolean)
1841 2063
1842 (defun TeX-match-extension (file &optional extensions) 2064 (defun TeX-match-extension (file &optional extensions)
1843 "Return non-nil if FILE has an one of EXTENSIONS. 2065 "Return non-nil if FILE has an one of EXTENSIONS.
1844 2066
1845 If EXTENSIONS is not specified or nil, the value of 2067 If EXTENSIONS is not specified or nil, the value of
2089 (t 2311 (t
2090 (vector name (list 'TeX-command-menu name) t))))) 2312 (vector name (list 'TeX-command-menu name) t)))))
2091 2313
2092 ;;; Keymap 2314 ;;; Keymap
2093 2315
2094 (defvar TeX-electric-escape nil 2316 (defcustom TeX-electric-escape nil
2095 "If this is non-nil when AUC TeX is loaded, the TeX escape 2317 "If this is non-nil when AUC TeX is loaded, the TeX escape
2096 character ``\\'' will be bound to `TeX-electric-macro'.") 2318 character ``\\'' will be bound to `TeX-electric-macro'."
2319 :group 'TeX-macro
2320 :type 'boolean)
2097 2321
2098 (defvar TeX-mode-map nil 2322 (defvar TeX-mode-map nil
2099 "Keymap for common TeX and LaTeX commands.") 2323 "Keymap for common TeX and LaTeX commands.")
2100 2324
2101 (if TeX-mode-map 2325 (if TeX-mode-map
2226 (or (looking-at comment-start-skip) 2450 (or (looking-at comment-start-skip)
2227 (re-search-forward comment-start-skip pos t)))))) 2451 (re-search-forward comment-start-skip pos t))))))
2228 2452
2229 ;;; Indentation 2453 ;;; Indentation
2230 2454
2455 (defgroup TeX-indentation nil
2456 "Indentation of TeX buffers in AUC TeX."
2457 :group 'AUC-TeX)
2458
2231 (defun TeX-brace-count-line () 2459 (defun TeX-brace-count-line ()
2232 "Count number of open/closed braces." 2460 "Count number of open/closed braces."
2233 (save-excursion 2461 (save-excursion
2234 (save-restriction 2462 (save-restriction
2235 (let ((count 0)) 2463 (let ((count 0))
2245 (setq count (+ count TeX-brace-indent-level))) 2473 (setq count (+ count TeX-brace-indent-level)))
2246 ((string= "}" (TeX-match-buffer 1)) 2474 ((string= "}" (TeX-match-buffer 1))
2247 (setq count (- count TeX-brace-indent-level))))) 2475 (setq count (- count TeX-brace-indent-level)))))
2248 count)))) 2476 count))))
2249 2477
2250 (defvar TeX-brace-indent-level 2 2478 (defcustom TeX-brace-indent-level 2
2251 "*The level of indentation produced by a open brace.") 2479 "*The level of indentation produced by a open brace."
2480 :group 'TeX-indentation
2481 :type 'integer)
2252 2482
2253 (defun TeX-comment-indent () 2483 (defun TeX-comment-indent ()
2254 (if (looking-at "%%%") 2484 (if (looking-at "%%%")
2255 (current-column) 2485 (current-column)
2256 (skip-chars-backward " \t") 2486 (skip-chars-backward " \t")
2257 (max (if (bolp) 0 (1+ (current-column))) 2487 (max (if (bolp) 0 (1+ (current-column)))
2258 comment-column))) 2488 comment-column)))
2259 2489
2260 ;;; Fonts 2490 ;;; Fonts
2261 2491
2262 (defvar TeX-font-list '((?\C-b "{\\bf " "}") 2492 (defcustom TeX-font-list '((?\C-b "{\\bf " "}")
2263 (?\C-c "{\\sc " "}") 2493 (?\C-c "{\\sc " "}")
2264 (?\C-e "{\\em " "\\/}") 2494 (?\C-e "{\\em " "\\/}")
2265 (?\C-i "{\\it " "\\/}") 2495 (?\C-i "{\\it " "\\/}")
2266 (?\C-r "{\\rm " "}") 2496 (?\C-r "{\\rm " "}")
2267 (?\C-s "{\\sl " "\\/}") 2497 (?\C-s "{\\sl " "\\/}")
2268 (?\C-t "{\\tt " "}") 2498 (?\C-t "{\\tt " "}")
2269 (?\C-d "" "" t)) 2499 (?\C-d "" "" t))
2270 "*List of fonts used by TeX-font. 2500 "List of fonts used by TeX-font.
2271 2501
2272 Each entry is a list with three elements. The first element is the 2502 Each entry is a list with three elements. The first element is the
2273 key to active the font. The second element is the string to insert 2503 key to active the font. The second element is the string to insert
2274 before point, and the third element is the string to insert after 2504 before point, and the third element is the string to insert after
2275 point. An optional fourth element means always replace if not nil.") 2505 point. An optional fourth element means always replace if not nil."
2506 :group 'TeX-macro
2507 :type '(repeat (group (character :tag "Key")
2508 (string :tag "Prefix")
2509 (string :tag "Suffix")
2510 (option (sexp :format "Replace\n"
2511 :value t)))))
2276 2512
2277 (defvar TeX-font-replace-function 'TeX-font-replace 2513 (defvar TeX-font-replace-function 'TeX-font-replace
2278 "Determines the function which is called when a font should be replaced.") 2514 "Determines the function which is called when a font should be replaced.")
2279 2515
2280 (defun TeX-describe-font-entry (entry) 2516 (defun TeX-describe-font-entry (entry)
2502 (save-buffer) 2738 (save-buffer)
2503 (TeX-auto-write))) 2739 (TeX-auto-write)))
2504 (normal-mode) 2740 (normal-mode)
2505 (TeX-update-style)) 2741 (TeX-update-style))
2506 2742
2507 (defvar TeX-open-quote "``" 2743 (defgroup TeX-quote nil
2508 "*String inserted by typing \\[TeX-insert-quote] to open a quotation.") 2744 "Quoting in AUC TeX."
2509 2745 :group 'AUC-TeX)
2510 (defvar TeX-close-quote "''" 2746
2511 "*String inserted by typing \\[TeX-insert-quote] to close a quotation.") 2747 (defcustom TeX-open-quote "``"
2512 2748 "*String inserted by typing \\[TeX-insert-quote] to open a quotation."
2513 (defvar TeX-quote-after-quote nil 2749 :group 'TeX-quote
2750 :type 'string)
2751
2752 (defcustom TeX-close-quote "''"
2753 "*String inserted by typing \\[TeX-insert-quote] to close a quotation."
2754 :group 'TeX-quote
2755 :type 'string)
2756
2757 (defcustom TeX-quote-after-quote nil
2514 "*Behaviour of \\[TeX-insert-quote]. Nil means standard behaviour; 2758 "*Behaviour of \\[TeX-insert-quote]. Nil means standard behaviour;
2515 when non-nil, opening and closing quotes are inserted only after \".") 2759 when non-nil, opening and closing quotes are inserted only after \"."
2760 :group 'TeX-quote
2761 :type 'boolean)
2516 2762
2517 ;;;###autoload 2763 ;;;###autoload
2518 (defun TeX-insert-quote (arg) 2764 (defun TeX-insert-quote (arg)
2519 "Insert the appropriate quote marks for TeX. 2765 "Insert the appropriate quote marks for TeX.
2520 Inserts the value of `TeX-open-quote' (normally ``) or `TeX-close-quote' 2766 Inserts the value of `TeX-open-quote' (normally ``) or `TeX-close-quote'