[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 2648a58 06/78: New function to read labels.
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 2648a58 06/78: New function to read labels. |
Date: |
Mon, 19 Oct 2015 09:10:38 +0000 |
branch: externals/auctex
commit 2648a5807bf6567b86ecd9342a39d439c7288b38
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>
New function to read labels.
* latex.el (LaTeX-label): Mention in the docstring the returned
value. Let-bind `TeX-read-label-prefix' and use `TeX-read-label'
to read the label.
(TeX-read-label-prefix): New variable.
(TeX-read-label): New function.
(TeX-arg-label): Use `TeX-read-label' and mention
`TeX-read-label-prefix' in docstring.
(TeX-arg-define-label): Mention `TeX-read-label-prefix' in
docstring.
---
ChangeLog | 12 +++++++++
latex.el | 75 +++++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2e1516b..876673f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2015-08-19 Mos� Giordano <address@hidden>
+
+ * latex.el (LaTeX-label): Mention in the docstring the returned
+ value. Let-bind `TeX-read-label-prefix' and use `TeX-read-label'
+ to read the label.
+ (TeX-read-label-prefix): New variable.
+ (TeX-read-label): New function.
+ (TeX-arg-label): Use `TeX-read-label' and mention
+ `TeX-read-label-prefix' in docstring.
+ (TeX-arg-define-label): Mention `TeX-read-label-prefix' in
+ docstring.
+
2015-08-14 Arash Esbati <address@hidden>
* latex.el (LaTeX-common-initialization): Fix the subgroup number
diff --git a/latex.el b/latex.el
index 8561535..8f613c2 100644
--- a/latex.el
+++ b/latex.el
@@ -993,35 +993,36 @@ you will be always prompted for a label, with an empty
default
prefix.
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))))
- ""))
- ((null type)
- "")
- (t
- nil)))
+transfer the job to this function.
+
+The inserted label is returned, nil if it is empty."
+ (let ((TeX-read-label-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))))
+ ""))
+ ((null type)
+ "")
+ (t
+ nil)))
label)
- (when (symbolp prefix)
- (setq prefix (symbol-value prefix)))
- (when prefix
+ (when (symbolp TeX-read-label-prefix)
+ (setq TeX-read-label-prefix (symbol-value TeX-read-label-prefix)))
+ (when TeX-read-label-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))
+ (setq label (TeX-read-label t "What label" t))
;; No label or empty string entered?
- (if (or (string= prefix label)
+ (if (or (string= TeX-read-label-prefix label)
(string= "" label))
(setq label nil)
(insert TeX-esc "label" TeX-grop label TeX-grcl))
@@ -1773,17 +1774,32 @@ If OPTIONAL is non-nil, insert the resulting value as
an optional
argument, otherwise as a mandatory one."
(TeX-argument-insert (eval args) optional))
-(defun TeX-arg-label (optional &optional prompt definition)
- "Prompt for a label completing with known labels.
+(defvar TeX-read-label-prefix nil
+ "Initial input for the label in `TeX-read-label.'")
+
+(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."
- (let ((label (completing-read (TeX-argument-prompt optional prompt "Key")
- (LaTeX-label-list))))
+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))
- (TeX-argument-insert label optional optional)))
+ label))
+
+(defun TeX-arg-label (optional &optional prompt definition)
+ "Prompt for a label completing with known labels.
+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."
+ (TeX-argument-insert
+ (TeX-read-label optional prompt definition) optional optional))
(defvar reftex-ref-macro-prompt)
@@ -1948,7 +1964,8 @@ string."
"Prompt for a label completing with known labels.
If OPTIONAL is non-nil, insert the resulting value as an optional
argument, otherwise as a mandatory one. Use PROMPT as the prompt
-string."
+string. `TeX-read-label-prefix' is used as initial input for the
+label."
(TeX-arg-label optional prompt t))
(defun TeX-arg-define-macro (optional &optional prompt)
- [elpa] externals/auctex updated (62aca31 -> 2f22938), Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 79c02c9 01/78: Make lengths available through `LaTeX-add-lengths'., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex e88f11f 04/78: Fix error when preview isn't loaded (intentionally), Tassilo Horn, 2015/10/19
- [elpa] externals/auctex c896f96 05/78: Fix the subgroup number in a regex., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 5b0b215 03/78: Setup preview menu/keymap only once., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 2648a58 06/78: New function to read labels.,
Tassilo Horn <=
- [elpa] externals/auctex be9f14a 02/78: Add the missing starred version of \AddEnumerateCounter., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 30be9cc 09/78: Add support for prettify-symbols-mode, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex eff71a7 10/78: Change | syntax to punctuation; fixes bug#21366, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a4d23f6 07/78: Add menu and new functions for error overview., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a85d7c6 15/78: Add support for undocumented macros `\captionbox[*]'., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex a3e3ab8 14/78: Add new style transparent.el., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 8d5acb0 13/78: Do not indent the content of `filecontents[*]' env., Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 57338ec 24/78: Improve my last commit, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 400609e 18/78: New TeX--if-macro-fboundp compatibility macro, Tassilo Horn, 2015/10/19
- [elpa] externals/auctex 08ab3c1 23/78: Allow hiding ^ and _ script signs, Tassilo Horn, 2015/10/19