1 ;;; pst-node.el --- AUCTeX style for `pst-node.sty'
3 ;; Copyright (C) 2007 Free Software Foundation, Inc.
5 ;; Author: Holger Sparr <holger.sparr@gmx.net>
6 ;; Created: 21 Jun 2007
7 ;; Based on: Jean-Philippe Georget's pst-plot.el
8 ;; Keywords: latex, pstricks, auctex, emacs
10 ;; This file is part of AUCTeX.
12 ;; AUCTeX is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; AUCTeX is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
24 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 ;; This file adds support for `pst-node.sty'.
33 ;; -- self parsing of possible node names
34 ;; -- adding more macro support
38 (defalias 'LaTeX-pst-node 'LaTeX-pst-point)
40 (defvar LaTeX-pstnode-parameters-completion-regexp
42 "Regexp for `string-match'ing a parameter.")
44 (defvar LaTeX-pstnode-parameters-boolean-regexp "show\\([a-zA-Z]+\\)"
45 "Regexp for `string-match'ing a parameter.")
47 (defvar LaTeX-pstnode-npos-list '(".25" ".5" ".75" "1" "1.5" "2")
48 "A list of values for npos in nput.")
50 (defvar LaTeX-pstnode-nrot-list '(":U" ":D" ":R" ":L")
51 "A list of values for nrot in nput.")
53 (defvar LaTeX-pstnode-psmatrix-list
54 '("mnode" "emnode" "name" "nodealign" "mocl" "rowsep" "colsep"
56 "A list of values for trimode in pstribox.")
59 (defvar LaTeX-pstnode-parameters-history nil
60 "History of values for parameters in pst-node.")
62 (defvar LaTeX-pstnode-parameters-value-history nil
63 "History of parameter values in pst-node.")
65 (defvar LaTeX-pstnode-parameters-name-list
66 '("angle" "angleA" "angleB" "arcangle" "arcangleA" "arcangleB" "arm"
67 "armA" "armB" "boxsize" "colsep" "framesize" "href" "loopsize"
68 "ncurv" "ncurvA" "ncurvB" "nodesepA" "nodesepB" "npos" "nrot"
69 "offset" "offsetA" "offsetB" "radius" "vref" "Xnodesep" "XnodesepA"
70 "XnodesepB" "Ynodesep" "YnodesepA" "YnodesepB")
71 "A list of parameters' name in pst-node.")
73 (defvar LaTeX-pstnode-parameters-name-history nil
74 "History of parameter names in pst-node.")
76 ;;; Derived Functions from pstricks.el defuns
77 (defun LaTeX-pstnode-parameter-value (param)
78 "See documentation of `LaTeX-package-parameter-value'."
79 (LaTeX-package-parameter-value param "pstnode"))
81 (defun LaTeX-pstnode-parameters-pref-and-chosen (param &optional noskip)
82 "See documentation of `LaTeX-package-parameters-pref-and-chosen'."
83 (LaTeX-package-parameters-pref-and-chosen param "pstnode" noskip))
85 (defun LaTeX-pstnode-parameters (optional &optional preparam param)
86 "See documentation of `LaTeX-package-parameters-pref-and-chosen'."
87 (LaTeX-package-parameters optional "pstnode" preparam param))
90 (defun LaTeX-pstnode-macro-nput (optional &optional arg)
91 "Return \\nput arguments after querying."
92 (insert "[rot=" (LaTeX-pst-angle) "]{" (LaTeX-pst-angle) "}{"
93 (LaTeX-pst-node) "}"))
95 (defun LaTeX-pstnode-macro-cnodeput (optional &optional arg)
96 "Return \\cnodeput arguments after querying."
97 (let ((rotation (if current-prefix-arg (LaTeX-pst-angle) nil))
98 (pnt (if current-prefix-arg (LaTeX-pst-point) nil)))
99 (insert (if rotation (format "{%s}" rotation) "")
100 (if pnt (format "(%s)" pnt) "") "{" (LaTeX-pst-node) "}")))
102 (defun LaTeX-pstnode-macro-nc (optional &optional arg)
103 "Return \\nc* arguments after querying."
104 (let ((arrows (LaTeX-pst-arrows)))
105 (insert (if arrows (format "{%s}" arrows) "") "{" (LaTeX-pst-node)
106 "}{" (LaTeX-pst-node) "}")))
108 (defun LaTeX-pstnode-macro-pc (optional &optional arg)
109 "Return \\pc* arguments after querying."
110 (let ((arrows (LaTeX-pst-arrows)))
111 (insert (if arrows (format "{%s}" arrows) "") "(" (LaTeX-pst-point)
112 ")(" (LaTeX-pst-point) ")")))
114 (defun LaTeX-pstnode-macro-tnabcput (optional &optional arg)
115 "Return \\t?put or \\n?put arguments after querying."
116 (TeX-argument-insert (LaTeX-pstnode-parameters-pref-and-chosen
117 '("nrot" "npos")) optional))
120 (defun LaTeX-pstnode-env-psmatrix (env)
121 "Return psmatrix environment with arguments."
122 (let ((opt (completing-read-multiple "Options: "
123 LaTeX-pstnode-psmatrix-list)))
124 (LaTeX-insert-environment env opt)))
130 (LaTeX-add-environments
131 '("psmatrix" LaTeX-pstnode-env-psmatrix))
133 '("MakeShortNab" 2) '("MakeShortTablr" 4) '("PSTnodesLoaded" 0)
134 '("nput" LaTeX-pstnode-macro-nput TeX-arg-macro)
135 '("cnodeput" [LaTeX-pst-parameters] LaTeX-pstnode-macro-cnodeput t)
136 '("Cnode" [LaTeX-pstnode-parameters] LaTeX-pst-point-in-parens t)
137 '("cnode" [LaTeX-pstnode-parameters] "Radius" t)
138 '("fnode" [LaTeX-pstnode-parameters] LaTeX-pst-point-in-parens t)
139 '("fnode*" [LaTeX-pstnode-parameters] LaTeX-pst-point-in-parens t)
140 '("dotnode" [LaTeX-pstnode-parameters] LaTeX-pst-point-in-parens t)
141 '("pnode" LaTeX-pst-point-in-parens t)
142 '("Rnode" [LaTeX-pstnode-parameters ("href" "vref")]
143 (TeX-arg-eval LaTeX-pst-point) t)
144 '("rnode" [LaTeX-pstnode-parameters ("ref")]
145 (TeX-arg-eval LaTeX-pst-point) t)
146 '("circlenode" [LaTeX-pst-parameters]
147 (TeX-arg-eval LaTeX-pst-point) t)
148 '("dianode" [LaTeX-pst-parameters] "Node Name" t)
149 '("ovalnode" [LaTeX-pst-parameters] "Node Name" t)
150 '("trinode" [LaTeX-pst-parameters] "Node Name" t)
151 '("dotnode" [LaTeX-pst-parameters] LaTeX-pst-point-in-parens
153 '("naput" [LaTeX-pstnode-macro-tnabcput] t)
154 '("nbput" [LaTeX-pstnode-macro-tnabcput] t)
155 '("ncput" [LaTeX-pstnode-macro-tnabcput] t)
156 '("taput" [LaTeX-pstnode-macro-tnabcput] t)
157 '("tbput" [LaTeX-pstnode-macro-tnabcput] t)
158 '("thput" [LaTeX-pstnode-macro-tnabcput] t)
159 '("tlput" [LaTeX-pstnode-macro-tnabcput] t)
160 '("trput" [LaTeX-pstnode-macro-tnabcput] t)
161 '("tvput" [LaTeX-pstnode-macro-tnabcput] t)
162 '("ncline" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
163 '("ncarc" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
164 '("ncdiag" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
165 '("ncdiagg" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
166 '("ncbar" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
167 '("ncangle" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
168 '("ncangles" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
169 '("ncloop" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
170 '("nccurve" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
171 '("nccircle" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
172 '("ncbox" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
173 '("ncarcbox" [LaTeX-pst-parameters] LaTeX-pstnode-macro-nc)
174 '("pcline" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
175 '("pccurve" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
176 '("pcarc" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
177 '("pcbar" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
178 '("pcdiag" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
179 '("pcdiagg" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
180 '("pcangle" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
181 '("pcangles" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
182 '("pcloop" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
183 '("pcbox" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
184 '("pcarcbox" [LaTeX-pst-parameters] LaTeX-pstnode-macro-pc)
185 '("psspan" (TeX-arg-eval LaTeX-pst-input-int))
191 ;;; pst-node.el ends here