EasyPG 1.07 Released
[packages] / xemacs-packages / auctex / style / psfig.el
1 ;;; psfig.el - Support for the psfig style option.
2
3 ;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
4
5 ;; Contributed by Marc Gemis <makke@wins.uia.ac.be>
6 ;; Please direct comments to him.
7
8 ;;; Code:
9
10 (TeX-add-style-hook "psfig"
11  (function
12   (lambda ()
13         ;; probable some of the following symbols may be removed
14     (TeX-add-symbols "protect" "figurepath"  "fbox"
15                      "other" "letter" "other" "then" "Sine" "Cosine"
16                      "psdraft" "psfull" "psscalefirst" "psrotatefirst"
17                      "psnodraftbox" "psdraftbox" "pssilent" "psnoisy"
18                      "minmaxtest"
19      '("psfig" TeX-arg-psfig)
20      '("psfigurepath" t)
21                      )
22     (LaTeX-add-environments
23      '("psfigure" LaTeX-env-psfigure)
24      )
25     ))
26  LaTeX-dialect)
27
28 (defun TeX-arg-psfig (_optional)
29    "Ask for file, width and length. Insert psfig macro"
30    (let ((psfile (read-file-name "PS-file: " "" "" nil))
31          (figwidth (TeX-read-string "Figure width: "))
32          (figheight (TeX-read-string "Figure height: "))
33          )
34
35      (insert TeX-grop "figure=" psfile)
36      (if (not (zerop (length figwidth)))
37          (insert ",width=" figwidth))
38      (if (not (zerop (length figheight)))
39          (insert ",height=" figheight))
40      (insert TeX-grcl)
41      )
42    )
43
44
45 (defun LaTeX-env-psfigure (_environment)
46   "Create  with \\label and \\caption and \\psfig commands."
47   (let* ((float (TeX-read-string "Float to: " LaTeX-float))
48          (caption (TeX-read-string "Caption: "))
49          (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length)
50                           (TeX-read-string "(Optional) Short caption: ")))
51          (label (TeX-read-string "Label: " LaTeX-figure-label))
52          ; gf: ask if this should be centered
53          (psfile (read-file-name "PS-file: " "" "" nil))
54          (figwidth (TeX-read-string "Figure width: "))
55          (figheight (TeX-read-string "Figure height: "))
56          )
57
58     (setq LaTeX-float (if (zerop (length float))
59                           LaTeX-float
60                         float))
61
62     (LaTeX-insert-environment "figure"
63                               (concat LaTeX-optop LaTeX-float LaTeX-optcl))
64
65     (insert TeX-esc "centerline" TeX-grop TeX-esc "psfig" TeX-grop
66             "figure=" psfile)
67     (if (not (zerop (length figwidth)))
68         (insert ",width=" figwidth))
69     (if (not (zerop (length figheight)))
70         (insert ",height=" figheight))
71     (insert TeX-grcl TeX-grcl)
72     (if (zerop (length caption))
73         ()
74       (newline-and-indent)
75       (insert (LaTeX-compose-caption-macro caption short-caption)))
76     (if (or (zerop (length label))
77             (equal LaTeX-figure-label label))
78         ()
79       (newline-and-indent)
80       (insert TeX-esc "label" TeX-grop label TeX-grcl))
81
82     (forward-line 2)))
83
84 ;;; psfig.el ends here