branch: externals/auctex commit c1dcb84b2695a5ee484eeb3695905c5634d36a8b Merge: 08ae29b 8d69d3b Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into simplify-TeX-parse-error --- ChangeLog | 26 ++++++++++++ doc/auctex.texi | 50 +++++++---------------- doc/changes.texi | 5 -- latex.el | 115 ++++++++++++++++++--------------------------------- style/amsmath.el | 12 +++-- style/longtable.el | 11 +++-- 6 files changed, 95 insertions(+), 124 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f71fa0..71ccc62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2014-08-14 Mos� Giordano <m...@gnu.org> + + * latex.el (LaTeX-insert-label): Remove. + (LaTeX-label): Add a new mandatory argument. Do not use + `LaTeX-insert-label'. Determine the prefix at the beginning of + the function and insert the label only if the prefix is non nil. + (LaTeX-section-label, LaTeX-env-figure, LaTeX-env-label): Use the + second mandatory argument of `LaTeX-label'. + + * style/amsmath.el: Update copyright years. + ("amsmath"): Append the environments to `LaTeX-label-alist' + instead of prepeding them. Use the second mandatory argument of + the `LaTeX-label' function. + + * style/longtable.el: Update copyright years. + ("longtable"): Move addition of "longtable" environment to + `LaTeX-label-alist' inside the style hook. Append the environment + to the alist instead of prepending it. Use the second mandatory + argument of the `LaTeX-label' function. + + * doc/auctex.texi (Sectioning, Environments): Remove references to + `LaTeX-insert-label'. + (Environments): Document `LaTeX-label-alist'. + + * doc/changes.texi: Remove references to `LaTeX-insert-label'. + 2014-08-12 Mos� Giordano <m...@gnu.org> * latex.el (LaTeX-insert-label): Rename from diff --git a/doc/auctex.texi b/doc/auctex.texi index d85a4d3..84ac235 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -734,12 +734,6 @@ Prefix to all section references. @end deffn -@vindex LaTeX-insert-label -The @code{LaTeX-insert-label} user option controls whether -@code{LaTeX-section} should automatically insert a label for the given -sectioning command. By default, a label for all sectioning commands -will be prompted. @xref{Environments}, for more information. - The precise behavior of @code{LaTeX-section} is defined by the contents of @code{LaTeX-section-hook}. @@ -857,35 +851,21 @@ environment is inserted. @AUCTeX{} helps you adding labels to environments which use them, such as @samp{equation}, @samp{figure}, @samp{table}, etc@dots{} When you insert one of the supported environments with @kbd{C-c C-e}, you will be -automatically prompted for a label. If you want to select the -environments for which to automatically insert or not the label, -customize the @code{LaTeX-insert-label} variable. -@defopt LaTeX-insert-label -Control whether @code{LaTeX-section} (@kbd{C-c C-s}) or -@code{LaTeX-environment} (@kbd{C-c C-e}) should insert a label. If nil, -never insert a label, if t always insert a label and this the default. - -This variable may also be a cons cell, to whitelist or blacklist the -sections or environments for which a label should or should not be -inserted. The car can be either nil or t. In the former case, -@code{LaTeX-section} and @code{LaTeX-environment} never insert labels -except for the sections and environments listed in the cdr; in the -latter case those functions always insert labels except for the sections -and environments listed in the cdr. In any cases, you can manually -insert a label at point with @kbd{C-c C-m label @key{RET}}, as usual. - -For example, the value -@lisp -(t . "paragraph" "equation") -@end lisp -makes @AUCTeX{} always prompt you for a label except for the -@samp{paragraph} section, and th @samp{equation} environment. Instead -with the value -@lisp -(nil . "part" "chapter" "caption" "figure") -@end lisp -you will be prompted for a label only for @samp{part} and @samp{chapter} -sections, and @samp{caption} and @samp{figure} environments. +automatically prompted for a label. You can select the prefix to be +used for such environments with the @code{LaTeX-label-alist} variable. +@defopt LaTeX-label-alist +List the prefixes to be used for the label of each supported +environment. + +This is an alist whose car is the environment name, and the cdr either +the prefix or a symbol referring to one. + +If the name is not found, or if the cdr is nil, no label is +automatically inserted for that environment. + +If you want to automatically insert a label for a environment but with +an empty prefix, use the empty string @code{""} as the cdr of the +corresponding entry. @end defopt As a default selection, @AUCTeX{} will suggest the environment last diff --git a/doc/changes.texi b/doc/changes.texi index a717217..6d2e7b5 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -128,11 +128,6 @@ per file basis using the @code{TeX-command-extra-options} option. @item Now @kbd{C-c C-e document @key{RET}}, in an empty document, prompts for @samp{\usepackage} macros in addition to @samp{\documentclass}. - -@item -You can customize for which sections and environments a label should be -automatically inserted or not through the new user option -@code{LaTeX-insert-label}. @end itemize @heading News since 11.87 diff --git a/latex.el b/latex.el index 52ea574..c2685d7 100644 --- a/latex.el +++ b/latex.el @@ -487,7 +487,7 @@ Insert this hook into `LaTeX-section-hook' to prompt for a label to be inserted after the sectioning command. The behaviour of this hook is controlled by variable `LaTeX-section-label'." - (and (LaTeX-label name) + (and (LaTeX-label name 'section) (LaTeX-newline))) ;;; Environments @@ -835,29 +835,6 @@ the label inserted, or nil if no label was inserted." :group 'LaTeX-label :type 'function) -(defcustom LaTeX-insert-label t - "Control whether `LaTeX-label' function should insert a label. -If nil, never inserts a label, if t always inserts a label. - -This variable may also be a cons cell, to whitelist or blacklist -the sections or environments for which a label should or should -not be inserted. The CAR can be either nil or t. In the former -case, `LaTeX-label' never inserts labels except for the sections -and environments listed in the CDR; in the latter case -`LaTeX-label' always inserts labels except for the sections and -environments listed in the CDR." - :group 'LaTeX-label - :type '(choice (const :tag "Insert labels" t) - (const :tag "Do not insert labels" nil) - (cons :tag "Whitelist or blacklist" - (choice - (const - :tag "Insert labels except for sections and environments..." t) - (const - :tag "Do not insert labels except for sections and environments..." - nil)) - (repeat (string :tag "Section or Environment"))))) - (defcustom LaTeX-figure-label "fig:" "*Default prefix to figure labels." :group 'LaTeX-label @@ -944,53 +921,43 @@ either the prefix or a symbol referring to one." (make-variable-buffer-local 'LaTeX-label-alist) -(defun LaTeX-label (environment) - "Insert a label for ENVIRONMENT at point. -`LaTeX-insert-label' controls whether the label should actually -be inserted. If `LaTeX-label-function' is a valid function, -LaTeX label will transfer the job to this function." - (if (cond - ;; `LaTeX-insert-label' is boolean. - ((booleanp LaTeX-insert-label) - LaTeX-insert-label) - ;; `LaTeX-insert-label' is a whitelist or a blacklist. - ((consp LaTeX-insert-label) - (if (member environment (cdr LaTeX-insert-label)) - (null (car LaTeX-insert-label)) - (car LaTeX-insert-label))) - ;; In any other cases, insert the label. - (t)) - (let (label) - (if (and (boundp 'LaTeX-label-function) - LaTeX-label-function - (fboundp LaTeX-label-function)) - - (setq label (funcall LaTeX-label-function environment)) - (let ((prefix - (or (cdr (assoc environment LaTeX-label-alist)) - (if (assoc environment LaTeX-section-list) - (if (stringp LaTeX-section-label) - LaTeX-section-label - (and (listp LaTeX-section-label) - (cdr (assoc environment LaTeX-section-label)))) - "")))) - (when prefix - (when (symbolp prefix) - (setq prefix (symbol-value prefix))) - ;; Use completing-read as we do with `C-c C-m \label RET' - (setq label (completing-read - (TeX-argument-prompt t nil "What label") - (LaTeX-label-list) nil nil prefix)) - ;; No label or empty string entered? - (if (or (string= prefix label) - (string= "" label)) - (setq label nil) - (insert TeX-esc "label" TeX-grop label TeX-grcl)))) - (if label - (progn - (LaTeX-add-labels label) - label) - nil))))) +(defun LaTeX-label (name type) + "Insert a label for NAME at point. +TYPE can be either environment or section. If +`LaTeX-label-function' is a valid function, LaTeX label will +transfer the job to this function." + (let ((prefix (cond + ((eq type 'environment) + (cdr (assoc name LaTeX-label-alist))) + ((eq type 'section) + (if (assoc name LaTeX-section-list) + (if (stringp LaTeX-section-label) + LaTeX-section-label + (and (listp LaTeX-section-label) + (cdr (assoc name LaTeX-section-label)))) + "")))) + label) + (when (symbolp prefix) + (setq prefix (symbol-value prefix))) + (when prefix + (if (and (boundp 'LaTeX-label-function) + LaTeX-label-function + (fboundp LaTeX-label-function)) + (setq label (funcall LaTeX-label-function name)) + ;; Use completing-read as we do with `C-c C-m \label RET' + (setq label (completing-read + (TeX-argument-prompt t nil "What label") + (LaTeX-label-list) nil nil prefix)) + ;; No label or empty string entered? + (if (or (string= prefix label) + (string= "" label)) + (setq label nil) + (insert TeX-esc "label" TeX-grop label TeX-grcl)) + (if label + (progn + (LaTeX-add-labels label) + label) + nil))))) (defun LaTeX-env-figure (environment) "Create ENVIRONMENT with \\caption and \\label commands." @@ -1030,7 +997,7 @@ LaTeX label will transfer the job to this function." (indent-according-to-mode) ;; ask for a label and insert a new line only if a label is ;; actually inserted - (when (LaTeX-label environment) + (when (LaTeX-label environment 'environment) (LaTeX-newline) (indent-according-to-mode))) ;; bottom caption (default) @@ -1046,7 +1013,7 @@ LaTeX label will transfer the job to this function." (if auto-fill-function (LaTeX-fill-paragraph)) ;; ask for a label and if necessary insert a new line between caption ;; and label - (when (save-excursion (LaTeX-label environment)) + (when (save-excursion (LaTeX-label environment 'environment)) (LaTeX-newline) (indent-according-to-mode))) ;; Insert an empty line between caption and marked region, if any. @@ -1077,7 +1044,7 @@ Just like array and tabular." (defun LaTeX-env-label (environment) "Insert ENVIRONMENT and prompt for label." (LaTeX-insert-environment environment) - (when (LaTeX-label environment) + (when (LaTeX-label environment 'environment) (LaTeX-newline) (indent-according-to-mode))) diff --git a/style/amsmath.el b/style/amsmath.el index 8faf308..ce732d5 100644 --- a/style/amsmath.el +++ b/style/amsmath.el @@ -1,6 +1,6 @@ ;;; amsmath.el --- Style hook for the AMS-LaTeX amsmath package. -;; Copyright (C) 2002, 2005 Free Software Foundation, Inc. +;; Copyright (C) 2002, 2005-2007, 2012-2014 Free Software Foundation, Inc. ;; FIXME: What about the copyright for <= 2001? ;; Author: Carsten Dominik <domi...@strw.leidenuniv.nl> @@ -133,13 +133,15 @@ (setq LaTeX-amsmath-label LaTeX-equation-label)) (setq LaTeX-label-alist - (append '(("align" . LaTeX-amsmath-label) + ;; Append amsmath environments to `LaTeX-label-alist', in order not to + ;; override possible custome values. + (append LaTeX-label-alist + '(("align" . LaTeX-amsmath-label) ("alignat" . LaTeX-amsmath-label) ("xalignat" . LaTeX-amsmath-label) ("multline" . LaTeX-amsmath-label) ("flalign" . LaTeX-amsmath-label) - ("gather" . LaTeX-amsmath-label)) - LaTeX-label-alist)) + ("gather" . LaTeX-amsmath-label)))) (set (make-local-variable 'TeX-braces-association) (append '(("\\lvert" . "\\rvert") @@ -188,7 +190,7 @@ If SUPPRESS is non-nil, do not insert line break macro." (indent-according-to-mode)) (let ((env (LaTeX-current-environment))) (when (and (assoc env LaTeX-label-alist) - (LaTeX-label env)) + (LaTeX-label env 'environment)) (LaTeX-newline) (indent-according-to-mode)))) diff --git a/style/longtable.el b/style/longtable.el index 28a5a97..7b5ae00 100644 --- a/style/longtable.el +++ b/style/longtable.el @@ -1,6 +1,6 @@ ;;; longtable.el --- AUCTeX style for `longtable.sty'. -;; Copyright (C) 2013 Free Software Foundation, Inc. +;; Copyright (C) 2013, 2014 Free Software Foundation, Inc. ;; Maintainer: auctex-de...@gnu.org ;; Author: Mosè Giordano <giordano.m...@libero.it> @@ -29,9 +29,6 @@ ;;; Code: -(add-to-list 'LaTeX-label-alist - '("longtable" . LaTeX-table-label)) - (TeX-add-style-hook "longtable" (lambda () @@ -57,7 +54,7 @@ (indent-according-to-mode) ;; ask for a label and insert a new line only ;; if a label is actually inserted - (when (LaTeX-label environment) + (when (LaTeX-label environment 'environment) (LaTeX-newline) (indent-according-to-mode))))))) (TeX-add-symbols @@ -80,6 +77,10 @@ (add-to-list 'LaTeX-indent-environment-list '("longtable" LaTeX-indent-tabular)) + ;; Append longtable to `LaTeX-label-alist', in order not to override possible + ;; custome values. + (add-to-list 'LaTeX-label-alist '("longtable" . LaTeX-table-label) t) + ;; Fontification (when (and (featurep 'font-latex) (eq TeX-install-font-lock 'font-latex-setup))