diff lisp/auctex/latex.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents ec9a17fef872
children
line wrap: on
line diff
--- a/lisp/auctex/latex.el	Mon Aug 13 09:37:21 2007 +0200
+++ b/lisp/auctex/latex.el	Mon Aug 13 09:38:25 2007 +0200
@@ -1,7 +1,7 @@
 ;;; latex.el --- Support for LaTeX documents.
 ;; 
 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk>
-;; Version: 9.7l
+;; Version: 9.7p
 ;; Keywords: wp
 ;; X-URL: http://sunsite.auc.dk/auctex
 
@@ -38,14 +38,18 @@
 
 ;;; Style
 
-(defvar LaTeX-default-style "article"
-  "*Default when creating new documents.")
+(defcustom LaTeX-default-style "article"
+  "*Default when creating new documents."
+  :group 'LaTeX-environment
+  :type 'string)
 
   (make-variable-buffer-local 'LaTeX-default-style)
 
-(defvar LaTeX-default-options nil
-  "*Default options to documentstyle.
-A list of strings.")
+(defcustom LaTeX-default-options nil
+  "Default options to documentstyle.
+A list of strings."
+  :group 'LaTeX-environment
+  :type '(repeat (string :format "%v")))
 
  (make-variable-buffer-local 'LaTeX-default-options)
 
@@ -116,9 +120,10 @@
 	   (LaTeX-largest-level)))))
 
 (defun LaTeX-down-section ()
-  "Return the value of a section one level under the current. Tries to
-find what kind of section that have been used earlier in the text, If
-this fail, it will just return one less than the current section."
+  "Return the value of a section one level under the current. 
+Tries to find what kind of section that have been used earlier in the
+text, if this fail, it will just return one less than the current
+section." 
   (save-excursion 
     (let ((current (LaTeX-current-section))
 	  (next nil)
@@ -173,12 +178,15 @@
 	(nth 1 entry)
       nil)))
 
-(defvar TeX-outline-extra nil
-  "*List of extra TeX outline levels.
+(defcustom TeX-outline-extra nil
+  "List of extra TeX outline levels.
 
 Each element is a list with two entries.  The first entry is the
 regular expression matching a header, and the second is the level of
-the header.  See LaTeX-section-list for existing header levels.")
+the header.  See LaTeX-section-list for existing header levels."
+  :group 'LaTeX
+  :type '(repeat (group (regexp :tag "Match")
+			(integer :tag "Level"))))
 
 (defun LaTeX-outline-regexp (&optional anywhere)
   "Return regexp for LaTeX sections.  
@@ -244,13 +252,13 @@
 (add-hook 'TeX-remove-style-hook
 	  (function (lambda () (setq LaTeX-largest-level nil))))
 
-(defvar LaTeX-section-hook
+(defcustom LaTeX-section-hook
   '(LaTeX-section-heading
     LaTeX-section-title
 ;; LaTeX-section-toc		; Most people won't want this
     LaTeX-section-section
     LaTeX-section-label)
-  "*List of hooks to run when a new section is inserted.
+  "List of hooks to run when a new section is inserted.
 
 The following variables are set before the hooks are run
 
@@ -288,27 +296,44 @@
 	 LaTeX-section-section
 	 LaTeX-section-label))
 
-in your .emacs file.")
+in your .emacs file."
+  :type 'hook
+  :options '(LaTeX-section-heading
+	     LaTeX-section-title
+	     LaTeX-section-toc
+	     LaTeX-section-section
+	     LaTeX-section-label))
 
-(defvar LaTeX-section-label
+
+(defcustom LaTeX-section-label
   '(("chapter" . "cha:")
     ("section" . "sec:")
     ("subsection" . "sec:"))
-  "*Default prefix when asking for a label.
+  "Default prefix when asking for a label.
 
 If it is a string, it it used unchanged for all kinds of sections. 
 If it is nil, no label is inserted.
 If it is a list, the list is searched for a member whose car is equal
 to the name of the sectioning command being inserted.  The cdr is then
 used as the prefix.  If the name is not found, or if the cdr is nil,
-no label is inserted.")
+no label is inserted."
+  :group 'LaTeX-label
+  :type '(choice (const :tag "none" nil)
+		 (string :format "%v" :tag "Common")
+		 (repeat :menu-tag "Level specific"
+			 :format "\n%v%i"
+			 (cons :format "%v"
+			       (string :tag "Type")
+			       (choice :tag "Prefix"
+				       (const :tag "none" nil)
+				       (string  :format "%v"))))))
 
 ;;; Section Hooks.
 
 (defun LaTeX-section-heading ()
   "Hook to prompt for LaTeX section name.
 Insert this hook into LaTeX-section-hook to allow the user to change
-the name of the sectioning command inserted with M-x LaTeX-section."
+the name of the sectioning command inserted with `\\[LaTeX-section]'."
   (let ((string (completing-read
 		 (concat "Select level: (default " name ") ")
 		 LaTeX-section-list
@@ -322,7 +347,7 @@
 (defun LaTeX-section-title ()
   "Hook to prompt for LaTeX section title.
 Insert this hook into LaTeX-section-hook to allow the user to change
-the title of the section inserted with M-x LaTeX-section."
+the title of the section inserted with `\\[LaTeX-section]."
   (setq title (read-string "What title: ")))
 
 (defun LaTeX-section-toc ()
@@ -363,8 +388,14 @@
 
 ;;; Environments
 
-(defvar LaTeX-default-environment "itemize"
-  "*The default environment when creating new ones with LaTeX-environment.")
+(defgroup LaTeX-environment nil
+  "Environments in AUC TeX."
+  :group 'LaTeX-macro)
+
+(defcustom LaTeX-default-environment "itemize"
+  "*The default environment when creating new ones with LaTeX-environment."
+  :group 'LaTeX-environment
+  :type 'string)
  (make-variable-buffer-local 'LaTeX-default-environment)
 
 (defun LaTeX-environment (arg)
@@ -576,32 +607,63 @@
   (run-hooks 'LaTeX-document-style-hook)
   (setq LaTeX-document-style-hook nil))
 
-(defvar LaTeX-float "htbp"
+(defcustom LaTeX-float "htbp"
   "*Default float when creating figure and table environments.
-Set to nil if you don't want any float.")
+Set to nil if you don't want any float."
+  :group 'LaTeX-environment
+  :type '(choice (const :tag "none" nil)
+		 (string :format "%v")))
  (make-variable-buffer-local 'LaTeX-float)
 
-(defvar LaTeX-label-function nil
+(defgroup LaTeX-label nil
+  "Adding labels for LaTeX commands in AUC TeX."
+  :group 'LaTeX)
+
+(defcustom LaTeX-label-function nil
   "*A function inserting a label at point.
 Sole argument of the function is the environment. The function has to return
-the label inserted, or nil if no label was inserted.")
+the label inserted, or nil if no label was inserted."
+  :group 'LaTeX-label
+  :type 'function)
 
-(defvar LaTeX-figure-label "fig:"
-  "*Default prefix to figure labels.")
+(defcustom LaTeX-figure-label "fig:"
+  "*Default prefix to figure labels."
+  :group 'LaTeX-label
+  :group 'LaTeX-environment
+  :type 'string)
  (make-variable-buffer-local 'LaTeX-figure-label)
 
-(defvar LaTeX-table-label "tab:"
-  "*Default prefix to table labels.")
+(defcustom LaTeX-table-label "tab:"
+  "*Default prefix to table labels."
+  :group 'LaTeX-label
+  :group 'LaTeX-environment
+  :type 'string)
  (make-variable-buffer-local 'LaTeX-table-label)
 
-(defvar LaTeX-default-format ""
-  "Specifies the default format string for array and tabular environments.")
+(defcustom LaTeX-default-format ""
+  "Specifies the default format string for array and tabular environments."
+  :group 'LaTeX-environment
+  :type 'string)
  (make-variable-buffer-local 'LaTeX-default-format)
 
-(defvar LaTeX-default-position ""
-  "Specifies the default position string for array and tabular environments.")
+(defcustom LaTeX-default-position ""
+  "Specifies the default position string for array and tabular environments."
+  :group 'LaTeX-environment
+  :type 'string)
  (make-variable-buffer-local 'LaTeX-default-position)
 
+(defcustom LaTeX-equation-label "eq:"
+  "*Default prefix to equation labels."
+  :group 'LaTeX-label
+  :type 'string)
+ (make-variable-buffer-local 'LaTeX-equation-label)
+
+(defcustom LaTeX-eqnarray-label LaTeX-equation-label
+  "*Default prefix to eqnarray labels."
+  :group 'LaTeX-label
+  :type 'string)
+ (make-variable-buffer-local 'LaTeX-eqnarray-label)
+
 (defun LaTeX-env-item (environment)
   "Insert ENVIRONMENT and the first item."
   (LaTeX-insert-environment environment)
@@ -628,6 +690,10 @@
 	     (cond
 	      ((string= "figure" environment) LaTeX-figure-label)
 	      ((string= "table"  environment) LaTeX-table-label)
+	      ((string= "figure*" environment) LaTeX-figure-label)
+	      ((string= "table*"  environment) LaTeX-table-label)
+	      ((string= "equation" environment) LaTeX-equation-label)
+	      ((string= "eqnarray"  environment) LaTeX-eqnarray-label)
 	      ((assoc environment LaTeX-section-list)
 	       (cond
 		((stringp LaTeX-section-label) LaTeX-section-label)
@@ -681,12 +747,13 @@
       (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
       (end-of-line 0)
       (LaTeX-indent-line))
-    
-    (if (string= environment "table") (LaTeX-env-array "tabular"))))
+
+    (if (member environment '("table" "table*"))
+	(LaTeX-env-array "tabular"))))
 
 (defun LaTeX-env-array (environment)
-  "Insert ENVIRONMENT with position and column specifications 
-like array and tabular."
+  "Insert ENVIRONMENT with position and column specifications.
+Just like array and tabular."
   (let ((pos (read-string "Position: "))
 	(fmt (read-string "Format: " LaTeX-default-format)))
     (setq LaTeX-default-position pos)
@@ -1145,12 +1212,14 @@
   "Prompt for a LaTeX savebox."
   (TeX-arg-savebox optional prompt t))
 
-(defvar LaTeX-style-list '(("book")
-			   ("article")
-			   ("letter")
-			   ("slides")
-			   ("report"))
-  "*List of document styles.")
+(defcustom LaTeX-style-list '(("book")
+			      ("article")
+			      ("letter")
+			      ("slides")
+			      ("report"))
+  "List of document styles."
+  :group 'LaTeX-environment
+  :type '(repeat (group (string :format "%v"))))
 
   (make-variable-buffer-local 'LaTeX-style-list)
 
@@ -1178,7 +1247,7 @@
   (TeX-update-style))
 
 (defvar TeX-global-input-files nil
-  "*List of the non-local TeX input files. 
+  "List of the non-local TeX input files. 
 
 Initialized once at the first time you prompt for an input file.
 May be reset with `C-u \\[TeX-normal-mode]'.")
@@ -1214,7 +1283,7 @@
     (TeX-argument-insert file optionel)))
 
 (defvar BibTeX-global-style-files nil
-  "*Association list of BibTeX style files.
+  "Association list of BibTeX style files.
 
 Initialized once at the first time you prompt for an input file.
 May be reset with `C-u \\[TeX-normal-mode]'.")
@@ -1239,7 +1308,7 @@
    optional))
 
 (defvar BibTeX-global-files nil
-  "*Association list of BibTeX files.
+  "Association list of BibTeX files.
 
 Initialized once at the first time you prompt for an BibTeX file.
 May be reset with `C-u \\[TeX-normal-mode]'.")
@@ -1327,11 +1396,17 @@
     ("\\lceil" . "\\rceil")
     ("\\langle" . "\\rangle")))
 
-(defvar TeX-braces-user-association nil
-  "A list of your personal association of brace symbols for \\left and \\right
+(defcustom TeX-braces-user-association nil
+  "A list of your personal association of brace symbols.
+These are used for \\left and \\right.
 
 The car of each entry is the brace used with \\left,
-the cdr is the brace used with \\right.")
+the cdr is the brace used with \\right."
+  :group 'LaTeX-macro
+  :group 'LaTeX-math
+  :type '(repeat (cons :format "%v"
+		       (string :tag "Left")
+		       (string :tag "Right"))))
 
 (defvar TeX-braces-association
   (append TeX-braces-user-association
@@ -1377,14 +1452,25 @@
 
 ;;; Indentation
 
-(defvar LaTeX-indent-level 2
-  "*Indentation of begin-end blocks in LaTeX.")
+(defgroup LaTeX-indentation nil
+  "Indentation of LaTeX code in AUC TeX"
+  :group 'LaTeX
+  :group 'TeX-indentation)
+
+(defcustom LaTeX-indent-level 2
+  "*Indentation of begin-end blocks in LaTeX."
+  :group 'LaTeX-indentation
+  :type 'integer)
 
-(defvar LaTeX-item-indent (- LaTeX-indent-level)
-  "*Extra indentation for lines beginning with an item.")
+(defcustom LaTeX-item-indent (- LaTeX-indent-level)
+  "*Extra indentation for lines beginning with an item."
+  :group 'LaTeX-indentation
+  :type 'integer)
 
-(defvar LaTeX-item-regexp "\\(bib\\)?item\\b"
-  "*Regular expression matching macros considered items.")
+(defcustom LaTeX-item-regexp "\\(bib\\)?item\\b"
+  "*Regular expression matching macros considered items."
+  :group 'LaTeX-indentation
+  :type 'regexp)
 
 (defun LaTeX-indent-line ()
   "Indent the line containing point, as LaTeX source.
@@ -1405,9 +1491,9 @@
 	(back-to-indentation))))
 
 (defun LaTeX-fill-region-as-paragraph (from to &optional justify-flag)
-  "Fill region as one paragraph: break lines to fit fill-column,
-but leave all lines ending with \\\\ (plus its optional argument) alone.
-Prefix arg means justify too.
+  "Fill region as one paragraph.
+Break lines to fit fill-column, but leave all lines ending with \\\\
+\(plus its optional argument) alone. Prefix arg means justify too.
 From program, pass args FROM, TO and JUSTIFY-FLAG."
   (interactive "*r\nP")
   (or (assoc (LaTeX-current-environment) LaTeX-indent-environment-list)
@@ -1670,17 +1756,26 @@
 The second element in each entry is the function to calculate the
 indentation level in columns.")
 
-(defvar LaTeX-indent-environment-check t
-  "*If non-nil, check for any special environments.")
+(defcustom LaTeX-indent-environment-check t
+  "*If non-nil, check for any special environments."
+  :group 'LaTeX-indentation
+  :type 'boolean)
 
-(defvar LaTeX-left-comment-regexp "%%%"
-  "*Regexp matching comments that should be placed on the left margin.")
+(defcustom LaTeX-left-comment-regexp "%%%"
+  "*Regexp matching comments that should be placed on the left margin."
+  :group 'LaTeX-indentation
+  :type 'regexp)
 
-(defvar LaTeX-right-comment-regexp "%[^%]"
-  "*Regexp matching comments that should be placed to the right margin.")
+(defcustom LaTeX-right-comment-regexp "%[^%]"
+  "*Regexp matching comments that should be placed to the right margin."
+  :group 'LaTeX-indentation
+  :type 'regexp)
 
-(defvar LaTeX-ignore-comment-regexp nil
-  "*Regexp matching comments that whose indentation should not be touched.")
+(defcustom LaTeX-ignore-comment-regexp nil
+  "*Regexp matching comments that whose indentation should not be touched."
+  :group 'LaTeX-indentation
+  :type '(choice (const :tag "none" nil)
+		 (regexp :format "%v")))
 
 (defun LaTeX-indent-calculate ()
   ;; Return the correct indentation of line of LaTeX source. (I hope...)
@@ -1721,8 +1816,10 @@
 	   (+ (LaTeX-indent-calculate-last) LaTeX-item-indent))
 	  (t (LaTeX-indent-calculate-last)))))
 
-(defvar LaTeX-left-right-indent-level LaTeX-indent-level
-  "*The level of indentation produced by a \\left macro.")
+(defcustom LaTeX-left-right-indent-level LaTeX-indent-level
+  "*The level of indentation produced by a \\left macro."
+  :group 'LaTeX-indentation
+  :type 'integer)
 
 (defun LaTeX-indent-level-count ()
   ;; Count indentation change caused by all \left, \right, \begin, and
@@ -1802,7 +1899,11 @@
 
 ;;; Math Minor Mode
 
-(defvar LaTeX-math-list nil
+(defgroup LaTeX-math nil
+  "Mathematics in AUC TeX."
+  :group 'LaTeX-macro)
+
+(defcustom LaTeX-math-list nil
   "AList of your personal LaTeX math symbols.  
 
 Each entry should be a list with three elements, KEY, VALUE, and MENU.
@@ -1811,7 +1912,15 @@
 be inserted, or a function to be called.  The optional third element is
 the name of the submenu where the command should be added.
 
-See also `LaTeX-math-menu'.")
+See also `LaTeX-math-menu'."
+  :group 'LaTeX-math
+  :type '(repeat (group (choice (const :tag "none")
+				(character :format "%v\n"))
+			(string :tag "Symbol")
+			(choice :tag "Menu"
+				(string :tag "Name" :format "%v")
+				(repeat :tag "Path"
+					(string :format "%v"))))))
 
 (defconst LaTeX-math-default
   '((?a "alpha" "greek")
@@ -2075,10 +2184,11 @@
     (nil "vec" "Accents")
     (nil "ddot" "Accents")
     (?~ "tilde" "Accents")
-    (nil "ulcorner" ("AMS" "Hebrew"))
-    (nil "urcorner" ("AMS" "Hebrew"))
-    (nil "llcorner" ("AMS" "Hebrew"))
-    (nil "lrcorner" ("AMS" "Hebrew"))
+    (nil "digamma" ("AMS" "Hebrew"))
+    (nil "varkappa" ("AMS" "Hebrew"))
+    (nil "beth" ("AMS" "Hebrew"))
+    (nil "daleth" ("AMS" "Hebrew"))
+    (nil "gimel" ("AMS" "Hebrew"))
     (nil "dashrightarrow" ("AMS" "Arrows"))
     (nil "dashleftarrow" ("AMS" "Arrows"))
     (nil "leftleftarrows" ("AMS" "Arrows"))
@@ -2301,6 +2411,10 @@
     (nil "rvert" ("AMS" "Delimiters"))
     (nil "lVert" ("AMS" "Delimiters"))
     (nil "rVert" ("AMS" "Delimiters"))
+    (nil "ulcorner" ("AMS" "Delimiters"))
+    (nil "urcorner" ("AMS" "Delimiters"))
+    (nil "llcorner" ("AMS" "Delimiters"))
+    (nil "lrcorner" ("AMS" "Delimiters"))
     (nil "nobreakdash" ("AMS" "Special"))
     (nil "leftroot" ("AMS" "Special"))
     (nil "uproot" ("AMS" "Special"))
@@ -2324,8 +2438,10 @@
     (nil "subarray" ("AMS" "Special"))
     (nil "sideset" ("AMS" "Special"))))
 
-(defvar LaTeX-math-abbrev-prefix "`"
-  "Prefix key for use in LaTeX-math-mode.")
+(defcustom LaTeX-math-abbrev-prefix "`"
+  "Prefix key for use in `LaTeX-math-mode'."
+  :group 'LaTeX-math
+  :type 'string)
 
 (defvar LaTeX-math-keymap (make-sparse-keymap)
   "Keymap used for LaTeX-math-mode commands.")
@@ -2393,7 +2509,7 @@
   LaTeX-math-menu)
 
 (defvar LaTeX-math-mode nil
-  "Is LaTeX-math-mode on or off? non nil means on.")
+  "Is `LaTeX-math-mode' on or off?  Non nil means on.")
 
  (make-variable-buffer-local 'LaTeX-math-mode)
 
@@ -2623,7 +2739,7 @@
 	      ["Reset Buffer" TeX-normal-mode t]
 	      ["Reset AUC TeX" (TeX-normal-mode t) :keys "C-u C-c C-n"])))
 
-(defvar LaTeX-font-list
+(defcustom LaTeX-font-list
   '((?\C-b "\\textbf{" "}")
     (?\C-c "\\textsc{" "}")
     (?\C-e "\\emph{" "}")
@@ -2636,23 +2752,43 @@
     (?\C-t "\\texttt{" "}")
     (?\C-u "\\textup{" "}")
     (?\C-d "" "" t))
-  "Font commands used with LaTeX2e.  See `TeX-font-list'.")
+  "Font commands used with LaTeX2e.  See `TeX-font-list'."
+  :group 'LaTeX-macro
+  :type '(repeat (group (character :tag "Key")
+			(string :tag "Prefix")
+			(string :tag "Suffix")
+			(option (sexp :format "Replace\n" 
+				      :value t)))))
 
 ;;; Mode
 
-(defvar TeX-arg-cite-note-p nil
-  "*If non-nil, ask for optional note in citations.")
+(defgroup LaTeX-macro nil
+  "Special support for LaTeX macros in AUC TeX."
+  :prefix "TeX-"
+  :group 'LaTeX
+  :group 'TeX-macro)
 
-(defvar TeX-arg-footnote-number-p nil
-  "*If non-nil, ask for optional number in footnotes.")
+(defcustom TeX-arg-cite-note-p nil
+  "*If non-nil, ask for optional note in citations."
+  :type 'boolean
+  :group 'LaTeX-macro)
 
-(defvar TeX-arg-item-label-p nil
-  "*If non-nil, always ask for optional label in items.
-Otherwise, only ask in description environments.")
+(defcustom TeX-arg-footnote-number-p nil
+  "*If non-nil, ask for optional number in footnotes."
+  :type 'boolean
+  :group 'LaTeX-macro)
 
-(defvar TeX-arg-right-insert-p t
-  "*If non-nil, always insert automatically the corresponding
-\\right if \\left is inserted.")
+(defcustom TeX-arg-item-label-p nil
+  "*If non-nil, always ask for optional label in items.
+Otherwise, only ask in description environments."
+  :type 'boolean
+  :group 'LaTeX-macro)
+
+(defcustom TeX-arg-right-insert-p t
+  "*If non-nil, always insert automatically the corresponding \\right.
+This happens when \\left is inserted."
+  :type 'boolean
+  :group 'LaTeX-macro)
 
 (defvar LaTeX-paragraph-commands
   (concat "\\[\\|\\]\\|"  ; display math delimitors
@@ -2670,9 +2806,9 @@
 Special commands:
 \\{LaTeX-mode-map}
 
-Entering LaTeX mode calls the value of text-mode-hook,
-then the value of TeX-mode-hook, and then the value
-of LaTeX-mode-hook."
+Entering LaTeX mode calls the value of `text-mode-hook',
+then the value of `TeX-mode-hook', and then the value
+of `LaTeX-mode-hook'."
   (interactive)
   (LaTeX-common-initialization)
   (setq mode-name "LaTeX")
@@ -3034,14 +3170,14 @@
 	(search-forward-regexp
 	 "\\documentstyle\\[\\([^]]*\\)\\]{\\([^}]*\\)}"
 	 (point-max) t)
-	(setq optstr (buffer-substring (match-beginning 1) (match-end 1))
-	      docstyle (buffer-substring (match-beginning 2)
+	(setq optstr (buffer-substring-no-properties (match-beginning 1) (match-end 1))
+	      docstyle (buffer-substring-no-properties (match-beginning 2)
 	      (match-end 2))
 	      optlist (TeX-split-string "," optstr))
       (if (search-forward-regexp
 	   "\\documentstyle{\\([^}]*\\)}"
 	   (point-max) t)
-	  (setq docstyle (buffer-substring (match-beginning 1)
+	  (setq docstyle (buffer-substring-no-properties (match-beginning 1)
 	  (match-end 1)))
 	(error "No documentstyle defined")))
     (beginning-of-line 1)