* Holger Sparr (2009-04-08) writes:

> Ralf Angeli wrote:
>>
>> This is a reason I'd like to use the new key=value completion mechanism.
>> However, I'm not familiar with the features the current prompting
>> mechanism in pstricks.el provides, since I could not try it.  Ideally
>> the key=value completion should at least be on par with it.
>
> I think the provided history mechanism is important since the set of
> used parameters will not change to much. It might be annoying to be
> promptep for the same values again and again.
>
> In case you do not use the history you will go through the completing
> mechanism.

There is a history for the full key=value arguments and we'd still keep
the separate histories defined in pstricks.el as long as they are used
for separate macro arguments (points, angles, arrows, etc.)  which is
the case for most uses, as far as I can see.

The key=value completion would mostly be used for what now is covered by
`LaTeX-pst-parameters'.  I've switched that to key=value completion in
my local copy of pstricks.el.  You can check it out with the attached
patch which obviously is still kinda rough.  It also contains some
comments we should address.

The patch applies to the latest version CVS where I made a few basic
changes not influencing the handling.  Mostly bug fixes and changes of
prompts to bring them in line with coding conventions.

-- 
Ralf
--- pstricks.el.~1.5.~	2009-04-13 18:34:30.000000000 +0200
+++ pstricks.el	2009-04-13 19:33:05.000000000 +0200
@@ -69,6 +69,8 @@
                        (funcall func prompt list nil compl nil hist)))))
       (completing-read (concat prompt ": ") list nil nil nil hist))))
 
+;; XXX: Show default value in prompt.  Perhaps extend
+;; `TeX-argument-prompt' to do that.
 (defun LaTeX-pst-what (what prompt default &optional arg)
   "Ask for WHAT with PROMPT with DEFAULT.
 The corresponding lists LaTeX-pst-<what>-\\(list\\|history\\)
@@ -123,6 +125,9 @@
                (concat "(Press TAB for completions) " param)
                (intern (concat "LaTeX-" pname
                                "-parameters-value-history"))))
+    ;; FIXME: This looks broken.  `compl' is never set and unless ""
+    ;; is added to parlist (at least in the Boolean case), the prompt
+    ;; shown by `TeX-arg-compl-list' will be incorrect.
     (if (and (not compl) parlist) (add-to-list parlist val))
     (if (string= val "") "" (concat param "=" val))))
 
@@ -257,6 +262,8 @@
 (defvar LaTeX-pst-arrows-history nil
   "History of values for arrows in pstricks.")
 
+;; XXX: Better ask for arrow start and end separately?
+;; `LaTeX-pst-arrows-list' is not exhaustive.
 (defun LaTeX-pst-arrows ()
   "Ask for a arrow type and manage arrow type list"
   (or (LaTeX-pst-what "arrows" "Arrow type" nil) ""))
@@ -286,16 +293,16 @@
   (LaTeX-pst-what "refpoint" "Reference point" nil))
 
 ;;; Color
-(defvar LaTeX-pst-color-list
-  '((completing-read-multiple
-     "Color (C1 [number [C1 [...]]])" t LaTeX-pst-color-history "!")
-    "black" "darkgray" "gray" "lightgray" "white" "-black" "-darkgray"
-    "-gray" "-lightgray" "-white" "red" "green" "blue" "yellow"
-    "magenta" "cyan" "-red" "-green" "-blue" "-yellow" "-magenta"
-    "-cyan" "violet" "purple" "brown" "pink" "olive" "-violet" "-purple"
-    "-brown" "-pink" "-olive"
-    "10" "20" "30" "40" "50" "60" "70" "80" "90")
-  "A list of values for *color in pstricks.")
+;; (defvar LaTeX-pst-color-list
+;;   '((completing-read-multiple
+;;      "Color (C1 [number [C1 [...]]])" t LaTeX-pst-color-history "!")
+;;     "black" "darkgray" "gray" "lightgray" "white" "-black" "-darkgray"
+;;     "-gray" "-lightgray" "-white" "red" "green" "blue" "yellow"
+;;     "magenta" "cyan" "-red" "-green" "-blue" "-yellow" "-magenta"
+;;     "-cyan" "violet" "purple" "brown" "pink" "olive" "-violet" "-purple"
+;;     "-brown" "-pink" "-olive"
+;;     "10" "20" "30" "40" "50" "60" "70" "80" "90")
+;;   "A list of values for *color in pstricks.")
 
 (defvar LaTeX-pst-color-history nil
   "History of values for color in pstricks.")
@@ -346,6 +353,146 @@
     "trimode" "unit" "xunit" "yunit")
   "A list of parameter names in pstricks.")
 
+(defvar LaTeX-pst-color-list
+  '("black" "darkgray" "gray" "lightgray" "white"
+    "red" "green" "blue" "cyan" "magenta" "yellow")
+  "List of colors predefined in PSTricks.")
+
+(defvar LaTeX-pst-fillstyle-list
+  '("none" "solid" "vlines" "vlines*" "hlines" "hlines*" "crosshatch"
+    "crosshatch*" "boxfill")
+  "List of fill styles defined in PSTricks.")
+
+;; From PSTricks: PostScript macros for Generic TeX, User's Guide,
+;; Timothy Van Zandt, 25 July 2003, Version 97.
+;; FIXME: Provide separate variables tailored to the different macros.
+(defvar LaTeX-pst-basic-parameters-list
+  '(;; Dimensions, coordinates and angles
+    ("unit")
+    ("xunit")
+    ("yunit")
+    ("runit")
+    ;; Basic graphics parameters
+    ("linewidth")
+    ("linecolor" LaTeX-pst-color-list)
+    ("fillstyle" LaTeX-pst-fillstyle-list)
+    ("fillcolor" LaTeX-pst-color-list)
+    ("arrows" LaTeX-pst-arrows-list)
+    ("showpoints" ("true" "false"))
+    ;; Lines and polygons
+    ("linearc")
+    ("framearc")
+    ("cornersize" ("relative" "absolute"))
+    ("gangle")
+    ;; Arcs, circles and ellipses
+    ("arcsepA")
+    ("arcsepB")
+    ("arcsep")
+    ;; Curves
+    ("curvature")
+    ;; Dots
+    ("dotstyle" ("*" "o" "Bo" "x" "+" "B+" "asterisk" "Basterisk" "oplus"
+		 "otimes" "|" "B|" "square" "Bsquare" "square*" "diamond"
+		 "Bdiamond" "diamond*" "triangle" "Btriangle" "triangle*"
+		 "pentagon" "Bpentagon" "pentagon*"))
+    ("dotsize")
+    ("dotscale")
+    ("dotangle")
+    ;; Grids
+    ("gridwidth")
+    ("gridcolor" LaTeX-pst-color-list)
+    ("griddots")
+    ("gridlabels")
+    ("gridlabelcolor" LaTeX-pst-color-list)
+    ("subgriddiv")
+    ("subgridwidth")
+    ("subgridcolor" LaTeX-pst-color-list)
+    ("subgriddots")
+    ;; Plots
+    ("plotstyle" ("dots" "line" "polygon" "curve" "ecurve" "ccurve"))
+    ("plotpoints")
+    ;; Coordinate systems
+    ("origin")
+    ("swapaxes" ("true" "false"))
+    ;; Line styles
+    ("dash")
+    ("dotsep")
+    ("border")
+    ("bordercolor" LaTeX-pst-color-list)
+    ("doubleline" ("true" "false"))
+    ("doublesep")
+    ("doublecolor" LaTeX-pst-color-list)
+    ("shadow" ("true" "false"))
+    ("shadowsize")
+    ("shadowangle")
+    ("shadowcolor" LaTeX-pst-color-list)
+    ("dimen" ("outer" "inner" "middle"))
+    ;; Fill styles
+    ("hatchwidth")
+    ("hatchsep")
+    ("hatchcolor" LaTeX-pst-color-list)
+    ("hatchangle")
+    ("addfillstyle" LaTeX-pst-fillstyle-list)
+    ;; Arrowheads and such
+    ("arrowsize")
+    ("arrowlength")
+    ("arrowwinset")
+    ("tbarsize")
+    ("bracketlength")
+    ("rbracketlength")
+    ("arrowscale")
+    ;; Parameters
+    ("linetype")
+    ;; Graphics objects
+    ("liftpen")
+    ;; Placing and rotating whatever
+    ("labelsep")
+    ;; Axes
+    ("labels" ("all" "x" "y" "none"))
+    ("showorigin" ("true" "false"))
+    ("ticks" ("all" "x" "y" "none"))
+    ("tickstyle" ("full" "top" "bottom"))
+    ("ticksize")
+    ("axesstyle" ("axes" "frame" "none"))
+    ;; Framed boxes
+    ("framesep")
+    ("boxsep")
+    ("trimode" ("*" "U" "D" "R" "L"))
+    ;; Nodes
+    ("href")
+    ("vref")
+    ("radius")
+    ;; Node connections
+    ("nodesep")
+    ("arcangle")
+    ("angle")
+    ("arm")
+    ("loopsize")
+    ("ncurv")
+    ("boxsize")
+    ("offset")
+    ;; Node connections labels: I
+    ("ref")
+    ("nrot")
+    ("npos")
+    ("shortput" ("none" "nab" "tablr" "tab"))
+    ;; Node connection labels: II
+    ("tpos")
+    ;; Attaching labels to nodes
+    ("rot")
+    ;; Mathematical diagrams and graphs
+    ("mnode" ("R" "r" "C" "f" "p" "circle" "oval" "dia" "tri" "dot" "none"))
+    ("emnode" ("R" "r" "C" "f" "p" "circle" "oval" "dia" "tri" "dot" "none"))
+    ("name")
+    ("nodealign" ("true" "false"))
+    ("mcol" ("l" "r" "c"))
+    ("rowsep")
+    ("colsep")
+    ("mnodesize")
+    ;; ...
+    )
+  "List of keys and values for PSTricks macro arguments.")
+
 (defvar LaTeX-pst-parameters-name-list
   LaTeX-pst-basic-parameters-name-list
   "A list of all parameters with completion.")
@@ -369,9 +516,16 @@
   "See documentation of `LaTeX-package-parameters-pref-and-chosen'."
   (LaTeX-package-parameters-pref-and-chosen param "pst" noskip))
 
-(defun LaTeX-pst-parameters (optional &optional preparam param)
-  "See documentation of `LaTeX-package-parameters-pref-and-chosen'."
-  (LaTeX-package-parameters optional "pst" preparam param))
+;; (defun LaTeX-pst-parameters (optional &optional preparam param)
+;;   "See documentation of `LaTeX-package-parameters-pref-and-chosen'."
+;;   (LaTeX-package-parameters optional "pst" preparam param))
+
+;; FIXME: This is likely only a transitional function used until all
+;; macros got their calls to `TeX-arg-key-val' with tailored parameter
+;; lists.
+(defun LaTeX-pst-parameters (optional)
+  "Prompt for general parameters of a PSTricks argument."
+  (TeX-arg-key-val optional LaTeX-pst-basic-parameters-list))
 
 ;;; Macros
 (defun LaTeX-pst-macro-psarc (optional &optional arg)
@@ -430,8 +584,6 @@
 
 (defun LaTeX-pst-macro-psdots (optional single)
   "Return \\psdot[s]? arguments after querying."
-  ;; forced parameter dotstyle
-  (LaTeX-pst-parameters optional '("dotstyle"))
   (let* ((pnt1 (LaTeX-pst-point))
          (pnt2 (if single pnt1 (LaTeX-pst-point))))
     (insert "(" pnt1 ")")
@@ -496,17 +648,21 @@
 (defun LaTeX-pst-macro-newpsobject (&optional arg)
   "Return \\newpsobject arguments after querying."
   (insert "{" (read-string "New PSObject Name: ") "}"
+	  ;; FIXME: It would be better to use something more confined
+	  ;; than `TeX-symbol-list'.
           "{" (completing-read "Parent Object: " (TeX-symbol-list))
           "}"))
 
 ;;; Environments
 (defun LaTeX-pst-env-pspicture (env)
   "Create new pspicure environment."
-  (let ((p0 (LaTeX-pst-what "point" "Lower left (default 0,0)" "0,0"))
+  (let ((opt (multi-prompt-key-value
+	      (TeX-argument-prompt t "Options" nil)
+	      '(("showgrid") ("shift"))))
+	(p0 (LaTeX-pst-what "point" "Lower left (default 0,0)" "0,0"))
         (p1 (LaTeX-pst-what "point" "Upper right (default 1,1)" "1,1"))
-        (grid (LaTeX-pst-parameters-pref-and-chosen '("showgrid")))
         corn)
-    (setq corn (concat (if (string= "" grid) "" (format "[%s]" grid))
+    (setq corn (concat (unless (string= "" opt) (format "[%s]" opt))
                        (if (string= "0,0" p0) "" (format "(%s)" p0))
                        "(" p1 ")"))
     (LaTeX-insert-environment env corn)))
@@ -545,6 +701,7 @@
               (add-to-list 'LaTeX-pst-style-list (nth 1 list) t))
              ((string= type "color")
               (add-to-list 'LaTeX-pst-color-list (nth 1 list) t)
+	      ;; FIXME: Why is an entry with "-" in front added?
               (add-to-list 'LaTeX-pst-color-list
                            (concat "-" (nth 1 list)) t)))))
    LaTeX-auto-pstricks))
@@ -553,6 +710,8 @@
   "Clear `LaTeX-auto-pstricks' before use."
   (setq LaTeX-auto-pstricks nil))
 
+;; FIXME: This does not seem to work unless one does a manual reparse.
+;; Check e.g. with "\definecolor" and "fillcolor=".
 (add-hook 'TeX-auto-prepare-hook 'LaTeX-pst-prepare)
 (add-hook 'TeX-auto-cleanup-hook 'LaTeX-pst-cleanup)
 
@@ -617,6 +776,10 @@
                             "-list")))))
     (insert (TeX-arg-compl-list (symbol-value symb) "New Value"
                                 'LaTeX-pst-parameters-value-history))))
+;; FIXME: Does the key binding fit into the overall scheme of AUCTeX?
+;; (Changing existing content is often done with a C-u prefix to an
+;; insertion command.)  If we keep it, it should be documented in the
+;; manual.  (See also `LaTeX-pst-parameters-add'.)
 (define-key LaTeX-mode-map "\C-c\C-x\C-v" 'LaTeX-pst-parameter-change-value)
 
 (TeX-add-style-hook
@@ -669,8 +832,8 @@
       (LaTeX-pst-macro-pnt-twolen "Width" "Height"))
     '("pstriangle" [LaTeX-pst-parameters]
       (LaTeX-pst-macro-pnt-twolen "Width" "Height"))
-    '("psdot" [LaTeX-pst-macro-psdots t])
-    '("psdots" [LaTeX-pst-macro-psdots nil])
+    '("psdot" [LaTeX-pst-parameters] (LaTeX-pst-macro-psdots t))
+    '("psdots" [LaTeX-pst-parameters] (LaTeX-pst-macro-psdots nil))
     '("psecurve" [LaTeX-pst-parameters] LaTeX-pst-macro-psline)
     '("psecurve*" [LaTeX-pst-parameters] LaTeX-pst-macro-psline)
     '("psellipse" [LaTeX-pst-parameters]
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to