1 ;;; pst-plot.el --- AUCTeX style for `pst-plot.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-plot.sty'.
33 ;; -- improve symbol support (especially the pstScalePoints macros)
34 ;; -- check for multido.el necessity
38 ;; Self Parsing -- see (info "(auctex)Hacking the Parser")
39 (defvar LaTeX-auto-pstplot-regexp-list
40 '(("\\\\\\(save\\|read\\)data{?\\(\\\\[a-zA-Z]+\\)}?"
41 2 LaTeX-auto-pstplot))
42 "List of regular expressions to extract arguments of \\*data
45 (defvar LaTeX-auto-pstplot nil
46 "Temporary for parsing \\*data definitions.")
48 (defun LaTeX-pstplot-cleanup ()
49 "Move symbols from `LaTeX-auto-pstplot to `TeX-auto-symbol'."
50 (mapcar (lambda (symbol)
51 ;; (setq TeX-symbol-list (cons (list symbol 0) TeX-symbol-list))
52 ;; (setq TeX-auto-symbol (cons (list symbol 0) TeX-auto-symbol)))
53 (add-to-list 'LaTeX-pstplot-datasets symbol))
56 (defun LaTeX-pstplot-prepare ()
57 "Clear `LaTeX-auto-pstplot' before use."
58 (setq LaTeX-auto-pstplot nil))
60 (add-hook 'TeX-auto-prepare-hook 'LaTeX-pstplot-prepare)
61 (add-hook 'TeX-auto-cleanup-hook 'LaTeX-pstplot-cleanup)
64 (defvar LaTeX-pstplot-datasets nil
65 "List of parsed data sets defined with \\savedata or \\readdata.")
67 (defvar LaTeX-pstplot-parameters-name-list
68 '("axesstyle" "labels" "plotpoints" "plotstyle" "showorigin" "ticks"
69 "ticksize" "tickstyle")
70 "A list of parameters' name in pst-plot.")
72 (defvar LaTeX-pst-ticks-list '(t "none" "all" "x" "y")
73 "A list of values for ticks in pst-plot.")
75 (defvaralias 'LaTeX-pst-labels-list 'LaTeX-pst-ticks-list)
77 (defvar LaTeX-pst-plotstyle-list
78 '(t "dots" "line" "polygon" "curve" "ecurve" "ccurve")
79 "A list of values for tickstyles in pst-plot.")
81 (defvar LaTeX-pst-tickstyle-list '(t "full" "top" "bottom")
82 "A list of values for tickstyles in pst-plot.")
84 (defvar LaTeX-pst-axesstyle-list '(t "axes" "frame" "none")
85 "A list of values for axesstyles in pst-plot.")
88 (defun LaTeX-pst-macro-psaxes (optional &optional arg)
89 "Return \\psaxes arguments after querying."
90 (let* ((cpref (if current-prefix-arg (car current-prefix-arg) 0))
91 (arrows (LaTeX-pst-arrows))
92 (pnt1 (if (> cpref 4) (LaTeX-pst-point) nil))
93 (pnt2 (if (> cpref 0) (LaTeX-pst-point) nil))
94 (pnt3 (LaTeX-pst-point)))
95 ;; insert \psaxes arguments
96 (insert (if arrows (format "{%s}" arrows) "")
97 (if pnt1 (format "(%s)" pnt1) "")
98 (if pnt2 (format "(%s)" pnt2) "") "(" pnt3 ")")))
101 (defun LaTeX-pstplot-datasets-read ()
102 (TeX-arg-compl-list "Datasets" LaTeX-pstplot-datasets))
109 (mapcar 'TeX-auto-add-regexp LaTeX-auto-pstplot-regexp-list)
111 '("readdata" "Macro Name" TeX-arg-file)
112 '("savedata" "Macro Name" ["Values"])
113 '("dataplot" ["Options"]
114 (TeX-arg-eval LaTeX-pstplot-datasets-read))
115 '("fileplot" ["Options"] TeX-arg-file)
116 '("listplot" ["Options"] "Values")
117 '("pstScalePoints" "X-Mod" "Y-Mod")
118 '("psplot" [LaTeX-pst-parameter] "xmin" "xmax" t)
119 '("parametricplot" [LaTeX-pst-parameter] "xmin" "xmax" t)
120 '("psaxes" [LaTeX-pst-parameters] LaTeX-pst-macro-psaxes)
126 (unless (string-match "plotstyle"
127 LaTeX-pst-parameters-completion-regexp)
128 (setq LaTeX-pst-parameters-completion-regexp
130 (substring LaTeX-pst-parameters-completion-regexp 0 -2)
131 "\\|plotstyle\\|ticks\\|tickstyle\\|axesstyle\\|labels\\)")))
132 (make-local-variable 'LaTeX-pst-parameters-name-list)
133 (setq LaTeX-pst-parameters-name-list
134 (append LaTeX-pstplot-parameters-name-list
135 LaTeX-pst-parameters-name-list)))))
137 ;;; pst-plot.el ends here