[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex c886a1b 10/95: Check if label is defined before
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex c886a1b 10/95: Check if label is defined before adding it to known labels |
Date: |
Sun, 16 Apr 2017 01:26:45 -0400 (EDT) |
branch: externals/auctex
commit c886a1b4c58fd293a793d72e0e6c1e959cb698e5
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Check if label is defined before adding it to known labels
* latex.el (TeX-read-label): Check if label is already defined and
ask for user confirmation before adding it list of known labels.
Do not add label if empty string or the value of
`TeX-read-label-prefix'.
---
latex.el | 45 +++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/latex.el b/latex.el
index 3ceda44..c2aab36 100644
--- a/latex.el
+++ b/latex.el
@@ -1823,16 +1823,41 @@ argument, otherwise as a mandatory one."
(defun TeX-read-label (optional &optional prompt definition)
"Prompt for a label completing with known labels and return it.
-If OPTIONAL is non-nil, insert the resulting value as an optional
-argument, otherwise as a mandatory one. Use PROMPT as the prompt
-string. If DEFINITION is non-nil, add the chosen label to the
-list of defined labels. `TeX-read-label-prefix' is used as
-initial input for the label."
- (let ((label (completing-read
- (TeX-argument-prompt optional prompt "Key")
- (LaTeX-label-list) nil nil TeX-read-label-prefix)))
- (if (and definition (not (string-equal "" label)))
- (LaTeX-add-labels label))
+This function always returns a string depending on user input:
+the returned value can be an empty string \"\", the value of
+`TeX-read-label-prefix' if present (e.g. \"fig:\") or a complete
+label input (e.g. \"fig:foo\"). If OPTIONAL is non-nil, indicate
+optional as part of prompt in minibuffer. Use PROMPT as the
+prompt string. If DEFINITION is non-nil, add the chosen label to
+the list of defined labels. `TeX-read-label-prefix' is used as
+initial input for the label. Also check if label is already
+defined and ask user for confirmation before proceeding."
+ (let (label valid)
+ (while (not valid)
+ (setq label
+ (completing-read
+ (TeX-argument-prompt optional prompt "Key")
+ (LaTeX-label-list) nil nil TeX-read-label-prefix))
+ ;; If we're defining a label, check if it's already defined and
+ ;; ask user for confirmation, otherwise ask again
+ (cond ((and definition
+ (assoc label (LaTeX-label-list)))
+ (ding)
+ (when (y-or-n-p
+ (format-message "Label `%s' exists. Use anyway? " label))
+ (setq valid t)))
+ (t
+ (setq valid t))))
+ ;; Only add a newly defined label to list of known one if it is
+ ;; not empty and not equal to `TeX-read-label-prefix', if given
+ (when (and definition
+ (not (string-equal "" label))
+ (if TeX-read-label-prefix
+ (not (string-equal TeX-read-label-prefix label))
+ t))
+ (LaTeX-add-labels label))
+ ;; Return label, can be empty string "", TeX-read-label-prefix
+ ;; only "fig:" or the real thing like "fig:foo"
label))
(defun TeX-arg-label (optional &optional prompt definition)
- [elpa] externals/auctex updated (f0cb472 -> 334da3d), Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 46059c3 02/95: Remove file from distributed tar ball, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 3ca0106 08/95: Guard setcar with appropriate test, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a159114 01/95: Add AUCTeX Logo, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 183959a 04/95: Fix ConTeXt-outline-regexp, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 474981f 05/95: Show summary of tests at the end of make check, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 15960e4 06/95: Add makeglossaries to the list of commands, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex b714739 09/95: Add \citetitle to `reftex-cite-format' in style/biblatex, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex ccd67c2 17/95: ; * style/breqn.el ("breqn"): Add missing starred version of array., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c886a1b 10/95: Check if label is defined before adding it to known labels,
Tassilo Horn <=
- [elpa] externals/auctex 74766b4 03/95: Remove also a gitignore, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 7230fec 07/95: * latex.el (LaTeX-newline): Make interactive. See bug#24412., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a77e75a 15/95: ; * doc/changes.texi: Improve wording., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 76a2b5f 18/95: * tex-ispell.el: Add support for enviroments from breqn.sty., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 558da5f 24/95: * latex/preview.dtx: Fix example for \PreviewMacro* macro., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 73ccc38 22/95: Simplify addition of entirely skipped environments, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 4f2a322 16/95: Fix plain-TeX-auto-regexp-list docstring, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex fbe0782 11/95: Add `NO-INSERT' argument to `LaTeX-label', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex d54e747 19/95: Fix font-latex-after-hacking-local-variables on XEmacs, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 1b3f6e8 13/95: Update style/listings.el to use `LaTeX-env-label-as-keyval', Tassilo Horn, 2017/04/16