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. d83900b9fd15081049e02


From: Matthew Leach
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. d83900b9fd15081049e0217dce881e2b709d0617
Date: Fri, 08 Apr 2016 12:28:06 +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  d83900b9fd15081049e0217dce881e2b709d0617 (commit)
      from  b66c10aa0ae12d3cf85cb75e097e82bd342278dc (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 d83900b9fd15081049e0217dce881e2b709d0617
Author: Matthew Leach <address@hidden>
Date:   Fri Apr 8 12:28:04 2016 +0100

    TikZ: Make '+' and '++' prefixes apply to TikZ points
    
    * style/tikz.el (TeX-TikZ-get-prefix-string): New.
      (TeX-TikZ-arg-rect-point): Add optional argument `prefix'.
      (TeX-TikZ-arg-polar-point): Likewise.
      (TeX-TikZ-arg-named-point): Likewise.
      (TeX-TikZ-single-macro-arg): Allow a variable number of arguments to
      the argument name function map.
      (TeX-TikZ-point-function-map): Prefix all point types with '+' and
      '++'.
      (TeX-TikZ-path-connector-function-map): Remove the '+' and '++'
      suffixes.

diff --git a/style/tikz.el b/style/tikz.el
index 9754347..849d937 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -42,21 +42,25 @@ CLOSE\". If OPEN or CLOSE are nil, set them to 
`LaTeX-optop' and
       (concat open arg close)
     ""))
 
-(defun TeX-TikZ-arg-rect-point (_ignored)
+(defun TeX-TikZ-get-prefix-string (prefix)
+  "Return a string for the prefix to a command.
+")
+
+(defun TeX-TikZ-arg-rect-point (_ignored &optional prefix)
   "Prompt the user for a point on the Cartesian plane.
 Ask the user for an X and Y coordinate, and return the string
 \"(X,Y)\"."
   (let ((x (TeX-read-string (TeX-argument-prompt nil nil "X-coordinate")))
         (y (TeX-read-string (TeX-argument-prompt nil nil "Y-coordinate"))))
-   (concat " (" x ", " y") ")))
+   (concat " " prefix "(" x ", " y") ")))
 
-(defun TeX-TikZ-arg-polar-point (_ignored)
+(defun TeX-TikZ-arg-polar-point (_ignored &optional prefix)
   "Prompt the user for a point on the polar plane.
 Ask the user for r and theta values, and return the string
 \"(THETA:R)\"."
   (let ((r (TeX-read-string (TeX-argument-prompt nil nil "R")))
         (theta (TeX-read-string (TeX-argument-prompt nil nil "Theta"))))
-   (concat " (" theta ":" r ") ")))
+   (concat " " prefix "(" theta ":" r ") ")))
 
 (defun TeX-TikZ-arg-options (optional)
   "Prompt the user for options to a TikZ macro.
@@ -109,13 +113,22 @@ then called and the value returned.  PROMPT is used as 
the prompt
 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))))
-    (funcall
-     (cadr (assoc argument-type function-alist))
-     argument-type)))
+  (let* ((argument-type-names (mapcar 'car function-alist))
+         (selected-argument-type (TeX-TikZ-get-arg-type argument-type-names 
prompt))
+         (fn-alist-with-optional-elm (if optional
+                                         `(,@function-alist ("" identity))
+                                       function-alist))
+         (selected-mapping (assoc selected-argument-type
+                                  fn-alist-with-optional-elm)))
+
+    (eval
+     ;; Build the form we wish to evaluate.  This will be the function
+     ;; to be called (the second element in the assoc element),
+     ;; followed by the type name (the first element), followed by any
+     ;; other elements in the list as extra arguments.
+     `(,(cadr selected-mapping)
+       ,(car selected-mapping)
+       ,@(cddr selected-mapping)))))
 
 
 (defun TeX-TikZ-macro-arg (function-alist)
@@ -166,11 +179,11 @@ them as a list of strings, dropping the '()'."
           (add-to-list 'matches (match-string 1)))))
     matches))
 
-(defun TeX-TikZ-arg-named-point (_ignored)
+(defun TeX-TikZ-arg-named-point (_ignored &optional prefix)
   "Prompt the user for the name of a previous named-point."
   (let ((point-name (completing-read "Point name: "
                                      (TeX-TikZ-find-named-points))))
-    (concat " (" point-name ") ")))
+    (concat " " prefix "(" point-name ") ")))
 
 (defun TeX-TikZ-arg-circle (_ignored)
   "Prompt the user for the arguments to the circle command."
@@ -201,22 +214,26 @@ If OPTIONAL is non-nil and the user doesn't provide a 
point,
        (concat "parabola" options bend)))
 
 (defconst TeX-TikZ-point-function-map
-  '(("Rect Point" TeX-TikZ-arg-rect-point)
-    ("Polar Point" TeX-TikZ-arg-polar-point)
-    ("Named Point" TeX-TikZ-arg-named-point))
-  "An alist of point specification types and their functions." )
+  (let ((point-alist '(("Rect Point" TeX-TikZ-arg-rect-point)
+                       ("Polar Point" TeX-TikZ-arg-polar-point)
+                       ("Named Point" TeX-TikZ-arg-named-point))))
+    (apply 'append (mapcar
+                    (lambda (point-map)
+                      (let ((key (car point-map))
+                            (value (cadr point-map)))
+                        `((,key ,value)
+                          (,(concat "+" key) ,value "+")
+                          (,(concat "++" key) ,value "++"))))
+                    point-alist)))
+  "An alist of point specification types and their functions.
+A set of base point types along with variants that have \"+\" and
+\"++\" as a prefix."  )
 
 (defconst TeX-TikZ-path-connector-function-map
-  (let ((connectors '("--" "|-" "-|")))
-    (apply 'append (mapcar
-                     (lambda (connector)
-                       `((,connector identity)
-                         (,(concat connector " +") identity)
-                         (,(concat connector " ++") identity)))
-                     connectors)))
-  "An alist of path connectors.
-A set of base connectors along with variants that have \" +\" and
-\" ++\" appended to them, mapping to the identity function.")
+  '(("--" identity)
+    ("|-" identity)
+    ( "-|" identity))
+  "An alist of path connectors.")
 
 (defconst TeX-TikZ-draw-arg-function-map
   `(,@TeX-TikZ-point-function-map

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

Summary of changes:
 style/tikz.el |   71 +++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 44 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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