emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex 21e624026a 28/48: Improve support for TikZ


From: Tassilo Horn
Subject: [elpa] externals/auctex 21e624026a 28/48: Improve support for TikZ
Date: Fri, 18 Nov 2022 14:27:44 -0500 (EST)

branch: externals/auctex
commit 21e624026a250f39a508ec06274fbfa72b99b6a1
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>

    Improve support for TikZ
    
    * style/tikz.el ("tikz"): Add "tikz", "tikzset", "usetikzlibrary" and
    "foreach" macros.
    Run style hooks for graphicx, keyval and xcolor as well.
    Include preliminary support for ConTeXt and plain TeX.
    Allow optional argument for "tikzpicture" environment.
    Add "scope" environment.
    (AUCTeX-TikZ): New customize group.
    (TeX-TikZ-point-name-regexp): Use it as group.
    (TeX-TikZ-find-named-points): Add comment.
    (): Add `declare-function'.
---
 style/tikz.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 58 insertions(+), 3 deletions(-)

diff --git a/style/tikz.el b/style/tikz.el
index 565e6b0aa4..eb7d92810e 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -33,11 +33,19 @@
 (require 'tex)
 (require 'latex)
 
+;; Silence compiler
+(declare-function ConTeXt-add-environments "context"
+                  (&rest environments))
+
+(defgroup AUCTeX-TikZ nil
+  "AUCTeX TikZ support"
+  :group 'AUCTeX)
+
 (defcustom TeX-TikZ-point-name-regexp
   "(\\([A-Za-z0-9]+\\))"
   "A regexp that matches TikZ names."
   :type 'regexp
-  :group 'auctex-tikz)
+  :group 'AUCTeX-TikZ)
 
 (defconst TeX-TikZ-point-function-map
   '(("Rect Point" TeX-TikZ-arg-rect-point)
@@ -199,6 +207,10 @@ is finished."
 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 \\='()\\='."
+  ;; FIXME: This function depends on `LaTeX-find-matching-begin' and
+  ;; `LaTeX-find-matching-end', so it doesn't work for ConTeXt and
+  ;; plain TeX.  In addition, it isn't compatible with the TikZ code
+  ;; following \tikz.
   (let* ((env-end (save-excursion
                     (LaTeX-find-matching-end)
                      (point)))
@@ -278,8 +290,51 @@ return \"\"."
    (TeX-add-symbols
     '("draw" (TeX-TikZ-draw-arg))
     '("coordinate" (TeX-TikZ-coordinate-arg))
-    '("node" (TeX-TikZ-node-arg)))
+    '("node" (TeX-TikZ-node-arg))
+    '("tikz" ["TikZ option"])
+    '("tikzset" "TikZ option")
+    ;; FIXME:
+    ;; 1. usetikzlibrary isn't much useful without completion support
+    ;;    for available libraries.
+    ;; 2. ConTeXt users may prefer [...] over {...} as the argument.
+    '("usetikzlibrary" t)
+    ;; XXX: Maybe we should create pgffor.el and factor out this entry
+    ;; into it.
+    '("foreach" (TeX-arg-literal " ") (TeX-arg-free "Variable(s)")
+      (TeX-arg-literal " ") ["Foreach option"]
+      (TeX-arg-literal " in ") "Value list (Use \"...\" for range)"
+      (TeX-arg-literal " ") t))))
+
+;; LaTeX/docTeX specific stuff
+(TeX-add-style-hook
+ "tikz"
+ (lambda ()
    (LaTeX-add-environments
-    '("tikzpicture"))))
+    '("tikzpicture" ["TikZ option"])
+    '("scope" ["TikZ option"]))
+   ;; tikz.sty loads pgfcore.sty, which loads packages graphicx,
+   ;; keyval and xcolor, too.
+   (TeX-run-style-hooks "pgf" "graphicx" "keyval" "xcolor"))
+ :latex)
+
+;; ConTeXt specific stuff
+(TeX-add-style-hook
+ "tikz"
+ (lambda ()
+   (ConTeXt-add-environments
+    '("tikzpicture" ["TikZ option"])
+    '("scope" ["TikZ option"])))
+ :context)
+
+;; plain TeX specific stuff
+(TeX-add-style-hook
+ "tikz"
+ (lambda ()
+   (TeX-add-symbols
+    '("tikzpicture" ["TikZ option"])
+    "endtikzpicture"
+    '("scope" ["TikZ option"])
+    "endscope"))
+ :plain-tex)
 
 ;;; tikz.el ends here



reply via email to

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