auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 2648a5807bf6567b86ecd


From: Mosè Giordano
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 2648a5807bf6567b86ecd9342a39d439c7288b38
Date: Wed, 19 Aug 2015 14:50:32 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  2648a5807bf6567b86ecd9342a39d439c7288b38 (commit)
      from  c896f96bc44577680b777bc4cd6f477181f13784 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2648a5807bf6567b86ecd9342a39d439c7288b38
Author: Mosè Giordano <address@hidden>
Date:   Wed Aug 19 16:46:46 2015 +0200

    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.

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)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog |   12 +++++++++
 latex.el  |   75 +++++++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 58 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]