[Top][All Lists]

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

[elpa] elpa de0d445 07/51: TikZ: Add optional parameter to `TeX-TikZ-sin

From: Tassilo Horn
Subject: [elpa] elpa de0d445 07/51: TikZ: Add optional parameter to `TeX-TikZ-single-macro-arg'.
Date: Sun, 22 May 2016 07:22:47 +0000 (UTC)

branch: elpa
commit de0d445ea13a772d9cd842863c4d49217be7553b
Author: Matthew Leach <address@hidden>
Commit: Matthew Leach <address@hidden>

    TikZ: Add optional parameter to `TeX-TikZ-single-macro-arg'.
    * style/tikz.el (TeX-TikZ-single-macro-arg): New argument OPTIONAL.
      (TeX-TikZ-macro-arg): Use OPTIONAL argument when calling
 style/tikz.el |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/style/tikz.el b/style/tikz.el
index d335cbc..222be06 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -101,14 +101,18 @@ PROMPT as the prompt for input."
   (let ((completion-ignore-case t))
     (completing-read prompt types nil t)))
-(defun TeX-TikZ-single-macro-arg (function-alist prompt)
+(defun TeX-TikZ-single-macro-arg (function-alist prompt &optional optional)
   "Prompt the user for a single argument to compose a TikZ macro.
 FUNCTION-ALIST is a mapping of argument-types to functions.  The
 user is prompted for the argument type, the chosen function is
 then called and the value returned.  PROMPT is used as the prompt
-for the argument type."
+for the argument type.  When OPTIONAL is non-nil, add \"\" to
+FUNCTION-ALIST with a mapping to `identity', permitting an
+optional input."
   (let* ((argument-types (mapcar 'car function-alist))
          (argument-type (TeX-TikZ-get-arg-type argument-types prompt)))
+    (when optional
+      (setq function-alist `(,@function-alist ("" identity))))
      (cadr (assoc argument-type function-alist))
@@ -122,11 +126,8 @@ choose form the cars in FUNCTION-ALIST and the appropriate
 function is then called.  If the user enters \"\", then the macro
 is finished."
   (let* ((options (TeX-TikZ-arg-options t))
-         ;; For the iterative version, we need to add "" to the
-         ;; function-alist, allowing the user to end the macro.
-         (function-alist-iterative `(,@function-alist ("" identity)))
          (prompt "Next argument type (RET to finish): ")
-         (string-to-insert (TeX-TikZ-single-macro-arg function-alist-iterative 
+         (string-to-insert (TeX-TikZ-single-macro-arg function-alist prompt 
     ;; Insert the macro options.
     (insert options " ")
@@ -136,7 +137,7 @@ is finished."
     (while (not (string= string-to-insert ""))
       (insert string-to-insert)
       (setq string-to-insert
-            (TeX-TikZ-single-macro-arg function-alist-iterative prompt)))
+            (TeX-TikZ-single-macro-arg function-alist prompt t)))
     ;; Finish the macro.
     (insert ";")))

reply via email to

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