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


From: Matthew Leach
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. bb67e1818e4b6fc589363658b13631af137391df
Date: Tue, 29 Mar 2016 11:29:34 +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  bb67e1818e4b6fc589363658b13631af137391df (commit)
       via  4770a356b8ce771b09c5ebd3286c15d0f20c2e17 (commit)
       via  0bb97652bbcbdc92bac7fdce1c0402eded1d9cb4 (commit)
       via  b21182798f7b4e48ffc65fa2143b76edee4a49c0 (commit)
       via  e8b5498342962c4bd09c1b78c6ca79f0c9e68d44 (commit)
       via  00740ed871771a269c765b217e4a447e8cb7579b (commit)
      from  12886090ff783cb3ba4725bdc34ea248e7648166 (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 bb67e1818e4b6fc589363658b13631af137391df
Author: Matthew Leach <address@hidden>
Date:   Mon Mar 28 12:10:56 2016 +0100

    TikZ: Add 'Named Point' point type with completion.
    
    * style/tikz.el (TeX-TikZ-point-name-regexp): New.
      (TeX-TikZ-find-named-points): New.
      (TeX-TikZ-arg-named-point): New.
      (TeX-TikZ-point-function-map): Add 'Named Point' element that maps to
      `TeX-TikZ-arg-named-point'.

diff --git a/style/tikz.el b/style/tikz.el
index d002811..abcb0bb 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -142,9 +142,41 @@ is finished."
     ;; Finish the macro.
     (insert ";")))
 
+(defcustom TeX-TikZ-point-name-regexp
+  "(\\([A-Za-z0-9]+\\))"
+  "A regexp that matches TikZ names, i.e. alpha-numeric
+  characters enclosed in a ()."
+  :type 'regexp
+  :group 'auctex-tikz)
+
+(defun TeX-TikZ-find-named-points ()
+  "Find TiKZ named points in current enviroment.
+Begin by finding the span of the current TikZ enviroment and then
+searching within that span to find all named-points and return
+them as a list of strings, dropping the '()'."
+  (let* ((env-end (save-excursion
+                    (LaTeX-find-matching-end)
+                     (point)))
+         (matches ()))
+    ;; TODO: Handle cases where we are in a nested environment, \scope
+    ;; for example.
+    (save-excursion
+      (LaTeX-find-matching-begin)
+      (save-match-data
+        (while (re-search-forward TeX-TikZ-point-name-regexp env-end t)
+          (add-to-list 'matches (match-string 1)))))
+    matches))
+
+(defun TeX-TikZ-arg-named-point (_ignored)
+  "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 ") ")))
+
 (defconst TeX-TikZ-point-function-map
   '(("Rect Point" TeX-TikZ-arg-rect-point)
-    ("Polar Point" TeX-TikZ-arg-polar-point))
+    ("Polar Point" TeX-TikZ-arg-polar-point)
+    ("Named Point" TeX-TikZ-arg-named-point))
   "An alist of point specification types to their respective
 functions.")
 

commit 4770a356b8ce771b09c5ebd3286c15d0f20c2e17
Author: Matthew Leach <address@hidden>
Date:   Sun Mar 27 19:00:37 2016 +0100

    TikZ: Add prompting for TikZ's \node macro.
    
    * style/tikz.el (TeX-TikZ-node-arg): New.

diff --git a/style/tikz.el b/style/tikz.el
index a877cb8..d002811 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -167,11 +167,21 @@ functions.")
                                           "Coordinate point type: ")))
     (insert options " " name " at" point ";")))
 
+(defun TeX-TikZ-node-arg (optional)
+  "Prompt the user for the arguments to a TikZ node macro."
+  (let ((options (TeX-TikZ-arg-options t))
+        (name (TeX-TikZ-arg-name nil))
+        (point (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map
+                                          "Node point type: "))
+        (text (TeX-TikZ-arg-text nil)))
+    (insert options " " name  " at" point text ";")))
+
 (TeX-add-style-hook
  "tikz"
  (lambda ()
    (TeX-add-symbols
     '("draw" (TeX-TikZ-draw-arg))
-    '("coordinate" (TeX-TikZ-coordinate-arg)))
+    '("coordinate" (TeX-TikZ-coordinate-arg))
+    '("node" (TeX-TikZ-node-arg)))
    (LaTeX-add-environments
     '("tikzpicture"))))

commit 0bb97652bbcbdc92bac7fdce1c0402eded1d9cb4
Author: Matthew Leach <address@hidden>
Date:   Sun Mar 27 18:48:14 2016 +0100

    TikZ: Add prompting for \coordinate macro.
    
    * style/tikz.el (TeX-TikZ-point-function-map): New.
      (TeX-TikZ-draw-arg-function-map): Use `TeX-TikZ-point-function-map'.
      (TeX-TikZ-coordinate-arg): New.

diff --git a/style/tikz.el b/style/tikz.el
index af27c63..a877cb8 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -142,9 +142,14 @@ is finished."
     ;; Finish the macro.
     (insert ";")))
 
-(defconst TeX-TikZ-draw-arg-function-map
+(defconst TeX-TikZ-point-function-map
   '(("Rect Point" TeX-TikZ-arg-rect-point)
-    ("Polar Point" TeX-TikZ-arg-polar-point)
+    ("Polar Point" TeX-TikZ-arg-polar-point))
+  "An alist of point specification types to their respective
+functions.")
+
+(defconst TeX-TikZ-draw-arg-function-map
+  `(,@TeX-TikZ-point-function-map
     ("Node" TeX-TikZ-arg-node)
     ("--" identity)
     ("-+" identity))
@@ -154,10 +159,19 @@ is finished."
 (defun TeX-TikZ-draw-arg (optional)
   (TeX-TikZ-macro-arg TeX-TikZ-draw-arg-function-map))
 
+(defun TeX-TikZ-coordinate-arg (optional)
+  "Prompt the user for the arguments to a TikZ coordinate macro."
+  (let ((options (TeX-TikZ-arg-options t))
+        (name (TeX-TikZ-arg-name nil))
+        (point (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map
+                                          "Coordinate point type: ")))
+    (insert options " " name " at" point ";")))
+
 (TeX-add-style-hook
  "tikz"
  (lambda ()
    (TeX-add-symbols
-    '("draw" (TeX-TikZ-draw-arg)))
+    '("draw" (TeX-TikZ-draw-arg))
+    '("coordinate" (TeX-TikZ-coordinate-arg)))
    (LaTeX-add-environments
     '("tikzpicture"))))

commit b21182798f7b4e48ffc65fa2143b76edee4a49c0
Author: Matthew Leach <address@hidden>
Date:   Sun Mar 27 18:05:54 2016 +0100

    TikZ: Extract the prompting of the next arg from TeX-TikZ-macro-arg.
    
    * style/tikz.el (TeX-TikZ-single-macro-arg): New.
      (TeX-TikZ-macro-arg): Use `TeX-TikZ-single-macro-arg' for prompting
      the user and calling the appropriate function.

diff --git a/style/tikz.el b/style/tikz.el
index d7857b0..af27c63 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -103,6 +103,19 @@ PROMPT is non-nil use that prompt instead."
                   "Next argument type (RET to finish): ")))
     (completing-read prompt types nil t)))
 
+(defun TeX-TikZ-single-macro-arg (function-alist &optional prompt)
+  "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."
+  (let* ((argument-types (mapcar 'car function-alist))
+         (argument-type (TeX-TikZ-get-arg-type argument-types prompt)))
+    (funcall
+     (cadr (assoc argument-type function-alist))
+     argument-type)))
+
+
 (defun TeX-TikZ-macro-arg (function-alist)
   "Prompt the user for arguments to compose a TikZ macro.
 FUNCTION-ALIST is a mapping of argument-types to functions.  The
@@ -111,19 +124,20 @@ 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))
-         (argument-types `("" ,@(mapcar 'car function-alist)))
-         (argument-type (TeX-TikZ-get-arg-type argument-types)))
+         ;; 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)))
+         (string-to-insert (TeX-TikZ-single-macro-arg 
function-alist-iterative)))
 
     ;; Insert the macro options.
     (insert options " ")
 
     ;; Iteratively prompt the user for TikZ's arguments until "" is
     ;; returned.
-    (while (not (string= argument-type ""))
-      (insert (funcall
-               (cadr (assoc argument-type TeX-TikZ-draw-arg-function-map))
-               argument-type))
-      (setq argument-type (TeX-TikZ-get-arg-type argument-types)))
+    (while (not (string= string-to-insert ""))
+      (insert string-to-insert)
+      (setq string-to-insert
+            (TeX-TikZ-single-macro-arg function-alist-iterative)))
 
     ;; Finish the macro.
     (insert ";")))

commit e8b5498342962c4bd09c1b78c6ca79f0c9e68d44
Author: Matthew Leach <address@hidden>
Date:   Sun Mar 27 17:30:50 2016 +0100

    TikZ: allow arg type prompt to be specified.
    
    * style/tikz.el (TeX-TikZ-get-arg-type): Add a new optional argument,
      prompt, and show that to the user when non-nil, instead of the
      default.

diff --git a/style/tikz.el b/style/tikz.el
index f5e11b1..d7857b0 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -94,10 +94,14 @@ string \"node[OPTIONS](NAME){TEXT}\"."
         (text (TeX-TikZ-arg-text nil)))
     (concat "node" options name text " ")))
 
-(defun TeX-TikZ-get-arg-type (types)
-  "Prompt the user for the next argument type.
-TYPES is a list of possible types that the user can specify."
-  (completing-read "Next argument type (RET to finish): " types nil t))
+(defun TeX-TikZ-get-arg-type (types &optional prompt)
+  "Prompt the user for an argument type.
+TYPES is a list of possible types that the user can specify.  If
+PROMPT is non-nil use that prompt instead."
+  (let ((prompt (if prompt
+                    prompt
+                  "Next argument type (RET to finish): ")))
+    (completing-read prompt types nil t)))
 
 (defun TeX-TikZ-macro-arg (function-alist)
   "Prompt the user for arguments to compose a TikZ macro.

commit 00740ed871771a269c765b217e4a447e8cb7579b
Author: Matthew Leach <address@hidden>
Date:   Sun Mar 27 17:20:45 2016 +0100

    TikZ: split out the prompts to TeX-TikZ-arg-node & TeX-TikZ-macro-arg.
    
    * style/tikz.el (TeX-TikZ-arg-options): New.
      (TeX-TikZ-arg-name): New.
      (TeX-TikZ-arg-text): New.
      (TeX-TikZ-arg-node): Use new TikZ arg functions for prompting the
      user.
      (TeX-TikZ-macro-arg): Use `TeX-TikZ-arg-options' when prompting for
      the options.

diff --git a/style/tikz.el b/style/tikz.el
index de8a655..f5e11b1 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -58,17 +58,41 @@ Ask the user for r and theta values, and return the string
         (theta (TeX-read-string (TeX-argument-prompt nil nil "Theta"))))
    (concat " (" theta ":" r ") ")))
 
+(defun TeX-TikZ-arg-options (optional)
+  "Prompt the user for options to a TikZ macro.
+If OPTIONAL is non-nil, always return `LaTeX-optop' and
+`LaTeX-optcl', even if the user doesn't provide any input."
+  (let ((options (TeX-read-string (TeX-argument-prompt optional nil "Options" 
))))
+    (if optional
+        (TeX-TikZ-get-opt-arg-string options)
+      (concat LaTeX-optop options LaTeX-optcl))))
+
+(defun TeX-TikZ-arg-name (optional)
+  "Prompt the user for a TikZ name.
+If OPTIONAL is non-nil, always return \"()\", even if the user
+doesn't provide any input."
+  (let ((name (TeX-read-string (TeX-argument-prompt optional nil "Name" ))))
+    (if optional
+        (TeX-TikZ-get-opt-arg-string name "(" ")")
+      (concat "(" name ")"))))
+
+(defun TeX-TikZ-arg-text (optional)
+  "Prompt the user for TikZ text.
+If OPTIONAL is non-nil always return `TeX-grop' and `TeX-grcl',
+even if the user doesn't provide any input."
+  (let ((text (TeX-read-string (TeX-argument-prompt optional nil "Text" ))))
+    (if optional
+        (TeX-TikZ-get-opt-arg-string text TeX-grop TeX-grcl)
+      (concat TeX-grop text TeX-grcl))))
+
 (defun TeX-TikZ-arg-node (_ignored)
   "Prompt the user for the deatils of a node.
 Ask the user for the name and text for a node and return the
 string \"node[OPTIONS](NAME){TEXT}\"."
-  (let ((options (TeX-read-string (TeX-argument-prompt t nil "Options" )))
-        (name (TeX-read-string (TeX-argument-prompt t nil "Name")))
-        (text (TeX-read-string (TeX-argument-prompt nil nil "Text"))))
-    (concat "node"
-            (TeX-TikZ-get-opt-arg-string options)
-            (TeX-TikZ-get-opt-arg-string name "(" ")")
-            TeX-grop text TeX-grcl " ")))
+  (let ((options (TeX-TikZ-arg-options t))
+        (name (TeX-TikZ-arg-name t))
+        (text (TeX-TikZ-arg-text nil)))
+    (concat "node" options name text " ")))
 
 (defun TeX-TikZ-get-arg-type (types)
   "Prompt the user for the next argument type.
@@ -82,13 +106,12 @@ user is repeatedly prompted for the next argument-type; 
they can
 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-read-string (TeX-argument-prompt t nil "Options")))
+  (let* ((options (TeX-TikZ-arg-options t))
          (argument-types `("" ,@(mapcar 'car function-alist)))
          (argument-type (TeX-TikZ-get-arg-type argument-types)))
 
     ;; Insert the macro options.
-    (insert (TeX-TikZ-get-opt-arg-string options)
-            " ")
+    (insert options " ")
 
     ;; Iteratively prompt the user for TikZ's arguments until "" is
     ;; returned.

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

Summary of changes:
 style/tikz.el |  145 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 121 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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