branch: externals/auctex commit 7d4bfacf028203616194b95d5eff7f263d2f6d51 Merge: 312c74a 4c8d64c Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into simplify-TeX-parse-error --- ChangeLog | 14 +++++++ doc/auctex.texi | 34 ++++++++++++++++++ doc/changes.texi | 13 +++++-- latex.el | 100 ++++++++++++++++++++++++++++++++++++------------------ tex-buf.el | 11 +++--- 5 files changed, 130 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2be1b61..806e013 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2014-08-11 Mos� Giordano <m...@gnu.org> + + * tex-buf.el (TeX-command): Keep the frame and the buffer + associate to the error overview if the command to be run is View. + + * latex.el (LaTeX-auto-insert-label): New customizable variable. + (LaTeX-label): Use it. + + * doc/auctex.texi (Environments): Document + `LaTeX-auto-insert-label'. + + * doc/changes.texi: Mention `LaTeX-auto-insert-label'. Fix a + couple of bad-boxes in the PDF output of the manual. + 2014-07-25 Tassilo Horn <t...@gnu.org> * latex.el (LaTeX-largest-level-set): Adapt diff --git a/doc/auctex.texi b/doc/auctex.texi index 7261705..37c7366 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -848,6 +848,40 @@ prefix argument), the current environment is modified and no new environment is inserted. @end deffn +@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-auto-insert-label} variable. +@defopt LaTeX-auto-insert-label +Control whether @code{LaTeX-environment} (@kbd{C-c C-e}) should insert a +label. If nil, never inserts a label, if t always inserts a label and +this the default. + +This variable may also be a cons cell, to whitelist or blacklist the +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-environment} never inserts labels except for the +environments listed in the cdr; in the latter case +@code{LaTeX-environment} always inserts labels except for the +environments listed in the cdr. In any cases, you can manually insert +at point a label inside an environment with @kbd{C-c C-m label +@key{RET}}, as usual. + +For example, the value +@lisp +(t . "equation") +@end lisp +makes @AUCTeX{} always prompt you for a label except for the +@samp{equation} environment. Instead with the value +@lisp +(nil . "caption" "figure") +@end lisp +you will be prompted for a label only for @samp{caption} and +@samp{figure} environments. +@end defopt + As a default selection, @AUCTeX{} will suggest the environment last inserted or, as the first choice the value of the variable @code{LaTeX-default-environment}. diff --git a/doc/changes.texi b/doc/changes.texi index b408b47..3ce9d34 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -26,7 +26,7 @@ by the TeX compiler can be opened with @kbd{M-x TeX-error-overview @item Style file authors are encouraged to distinguish common from expert -macros/environments, and mark the latter using +macros and environments, and mark the latter using @code{TeX-declare-expert-macros} and @code{LaTeX-declare-expert-environments}. @@ -53,9 +53,10 @@ non-nil. Completion for class options of the standard @LaTeX{} classes is provided as well. @item -New user options @code{LaTeX-default-author}, @code{TeX-date-format}, -@code{TeX-insert-braces-alist}, @code{LaTeX-fontspec-arg-font-search}, -and @code{LaTeX-fontspec-font-list-default}. A new possible value +New user options @code{LaTeX-default-author}, +@code{LaTeX-fontspec-arg-font-search}, +@code{LaTeX-fontspec-font-list-default}, @code{TeX-date-format}, and +@code{TeX-insert-braces-alist}. A new possible value (@code{show-all-optional-args}) for @code{TeX-insert-macro-default-style} was added. The default value of @code{TeX-source-correlate-method} has been changed. @@ -127,6 +128,10 @@ 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 environments a label should be automatically +inserted or not through the user option @code{LaTeX-auto-insert-label}. @end itemize @heading News since 11.87 diff --git a/latex.el b/latex.el index c798cda..d1ac41f 100644 --- a/latex.el +++ b/latex.el @@ -835,6 +835,28 @@ the label inserted, or nil if no label was inserted." :group 'LaTeX-label :type 'function) +(defcustom LaTeX-auto-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 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 environments +listed in the CDR; in the latter case `LaTeX-label' always +inserts labels except for the 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 environments" + (choice + (const + :tag "Insert labels except for environments..." t) + (const + :tag "Do not insert labels except for environments..." + nil)) + (repeat (string :tag "Environment"))))) + (defcustom LaTeX-figure-label "fig:" "*Default prefix to figure labels." :group 'LaTeX-label @@ -923,39 +945,51 @@ either the prefix or a symbol referring to one." (defun LaTeX-label (environment) "Insert a label for ENVIRONMENT at point. -If `LaTeX-label-function' is a valid function, LaTeX label will transfer the -job to this function." - (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)))) +`LaTeX-auto-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-auto-insert-label' is boolean. + ((booleanp LaTeX-auto-insert-label) + LaTeX-auto-insert-label) + ;; `LaTeX-auto-insert-label' is a whitelist or a blacklist. + ((consp LaTeX-auto-insert-label) + (if (member environment (cdr LaTeX-auto-insert-label)) + (null (car LaTeX-auto-insert-label)) + (car LaTeX-auto-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-env-figure (environment) "Create ENVIRONMENT with \\caption and \\label commands." diff --git a/tex-buf.el b/tex-buf.el index 0c9ff6f..a466446 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -362,11 +362,12 @@ asked if it is positive, and suppressed if it is not." nil nil))) ;; Kill the frame and buffer associated to the error overview before running - ;; the command. - (if (frame-live-p TeX-error-overview-frame) - (delete-frame TeX-error-overview-frame)) - (if (get-buffer TeX-error-overview-buffer-name) - (kill-buffer TeX-error-overview-buffer-name)) + ;; the command, but keep them if the command to be run is View. + (unless (string= name "View") + (if (frame-live-p TeX-error-overview-frame) + (delete-frame TeX-error-overview-frame)) + (if (get-buffer TeX-error-overview-buffer-name) + (kill-buffer TeX-error-overview-buffer-name))) ;; Now start the process (setq file (funcall file))