[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] elpa d83900b 09/51: TikZ: Make '+' and '++' prefixes apply to Tik
From: |
Tassilo Horn |
Subject: |
[elpa] elpa d83900b 09/51: TikZ: Make '+' and '++' prefixes apply to TikZ points |
Date: |
Sun, 22 May 2016 07:22:48 +0000 (UTC) |
branch: elpa
commit d83900b9fd15081049e0217dce881e2b709d0617
Author: Matthew Leach <address@hidden>
Commit: Matthew Leach <address@hidden>
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.
---
style/tikz.el | 71 +++++++++++++++++++++++++++++++++++----------------------
1 file changed, 44 insertions(+), 27 deletions(-)
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
- [elpa] elpa eb9986d 46/51: Respect both "xcolor" and "color" for query to "shadecolor", (continued)
- [elpa] elpa eb9986d 46/51: Respect both "xcolor" and "color" for query to "shadecolor", Tassilo Horn, 2016/05/22
- [elpa] elpa 40c2c26 32/51: Allow for negative offsets in region backward search, Tassilo Horn, 2016/05/22
- [elpa] elpa 9613bdd 36/51: Check TeX engine only once, Tassilo Horn, 2016/05/22
- [elpa] elpa d9910d4 21/51: Fix small errors in doc string and comment, Tassilo Horn, 2016/05/22
- [elpa] elpa 6eb95e6 14/51: Integrate viewer support between tex.el and tex-jp.el, Tassilo Horn, 2016/05/22
- [elpa] elpa e90e050 34/51: Insert braces after some macros and \relax after \ProcessOptions, Tassilo Horn, 2016/05/22
- [elpa] elpa 0a3632e 45/51: Adjust query commands for loading by xcolor.el, Tassilo Horn, 2016/05/22
- [elpa] elpa adf998c 25/51: Replace TeX-PDF-via-dvips-ps2pdf with TeX-PDF-from-DVI, Tassilo Horn, 2016/05/22
- [elpa] elpa 3e93869 43/51: Add new style/xcolor.el, Tassilo Horn, 2016/05/22
- [elpa] elpa ae6ed8b 06/51: TikZ: make `TeX-TikZ-single-macro-arg' prompt required., Tassilo Horn, 2016/05/22
- [elpa] elpa d83900b 09/51: TikZ: Make '+' and '++' prefixes apply to TikZ points,
Tassilo Horn <=
- [elpa] elpa ae6cb79 26/51: Reword documentation of TeX-PDF-from-DVI, Tassilo Horn, 2016/05/22
- [elpa] elpa 1c397d5 29/51: Fix TeX-error-overview-make-entries, Tassilo Horn, 2016/05/22
- [elpa] elpa e092f72 35/51: Use commit date to determine package date, Tassilo Horn, 2016/05/22
- [elpa] elpa 7b41d77 38/51: Adapt for upLaTeX, Tassilo Horn, 2016/05/22
- [elpa] elpa d6b107e 33/51: Improve style/doc.el, Tassilo Horn, 2016/05/22
- [elpa] elpa cf54f7d 49/51: Make ChangeLog UTF-8, Tassilo Horn, 2016/05/22
- [elpa] elpa ebf4b8a 51/51: Release GNU AUCTeX 11.89.4, Tassilo Horn, 2016/05/22
- [elpa] elpa 8c6f901 48/51: Append environment indentation rules to LaTeX-indent-environment-list, Tassilo Horn, 2016/05/22
- [elpa] elpa e78a13c 03/51: * tex-buf.el: Address some compiler warnings, Tassilo Horn, 2016/05/22
- [elpa] elpa 8ed465a 50/51: Merge branch 'master' into elpa, Tassilo Horn, 2016/05/22