Initial Commit
[packages] / xemacs-packages / auctex / style / emp.el
1 ;;; emp.el --- AUCTeX support for emp.sty
2
3 ;; Copyright (C) 2004, 2005  Free Software Foundation, Inc.
4
5 ;; Author: Yvon Henel aka TeXnicien de surface <Yvon.Henel@wanadoo.fr>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Keywords: tex
8
9 ;; This file is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; any later version.
13
14 ;; This file is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 ;; version 1.0 2004-03-04
25
26 ;;; Code:
27
28
29 (TeX-add-style-hook "emp"
30  (function
31   (lambda ()
32      (TeX-add-symbols "empuse" "empTeX"  "empaddtoTeX"
33                       "emprelude" "empaddtoprelude" "unitlength"
34                      )
35     (LaTeX-add-environments
36      '("empfile" LaTeX-env-empfile)
37      '("emp" LaTeX-env-emp-gen)
38      '("empdef" LaTeX-env-emp-gen)
39      '("empgraph" LaTeX-env-emp-gen)
40      '("empcmds")
41      )))
42  LaTeX-dialect)
43
44 (defun LaTeX-env-emp-gen (environment-name)
45    "Ask for file, width and length. Insert environment-name environment
46 Used for emp, empdef, and empgraph environments."
47    (let ((emp-fig-name (read-string "figure name: " ""))
48          (emp-fig-width (read-string "figure width: " "1" ))
49          (emp-fig-height (read-string "figure height: " "1" ))
50          ;;; emp.sty demands a width and a height for each of the
51          ;;; emp, empdef, and empgraph environments
52          ;;; we give them 1 by default
53          ;;; not necessarily the best thing to do?
54          )
55      (if (not (zerop (length emp-fig-name)))
56          (progn 
57            (setq LaTeX-emp-fig-name (concat LaTeX-optop emp-fig-name LaTeX-optcl))
58            (LaTeX-insert-environment environment-name LaTeX-emp-fig-name))
59          (LaTeX-insert-environment environment-name))
60      (forward-line -1)
61      (end-of-line)
62      (insert "(" emp-fig-width "," emp-fig-height ")")
63      (forward-line 1)
64      (indent-according-to-mode)
65      ))
66
67 (defun LaTeX-env-empfile (optional)
68    "Ask for file. Insert empfile environment"
69    (let ((empfile (read-string "empfile: " "")))
70      (if (not (zerop (length empfile)))
71          (progn 
72            (setq LaTeX-emp-file-name (concat LaTeX-optop empfile LaTeX-optcl))
73            (setq mpost-emp-file-name (concat empfile ".mp"))
74            (LaTeX-insert-environment "empfile" LaTeX-emp-file-name))
75        (progn
76          (setq mpost-emp-file-name "\\jobname")
77          (LaTeX-insert-environment "empfile")))
78      (if LaTeX-write18-enabled-p
79          (progn
80            (forward-line 1)
81            (end-of-line)
82            (newline-and-indent)
83            (insert "\\immediate\\write18{mpost -tex=latex " mpost-emp-file-name TeX-grcl)
84            (forward-line -2)))))
85 ;;; emp.el ends here