Initial Commit
[packages] / xemacs-packages / auctex / style / prosper.el
1 ;;; prosper.el --- Prosper style file for AUCTeX
2
3 ;; Copyright (C) 2001, 2002 by Philip Lord, Nevin Kapur
4
5 ;; Authors:  Phillip Lord<p.lord@russet.org.uk>
6 ;;           Nevin Kapur <nevin@jhu.edu>
7 ;; Keywords: tex, wp, prosper
8 ;; Version: 0.6
9 ;; URL: http://www.mts.jhu.edu/~kapur/emacs/prosper.el
10
11 ;; This is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15
16 ;;; Commentary:
17
18 ;; This is a propser (http://prosper.sourceforge.net/) style file for
19 ;; AUCTeX.
20
21 ;;; Installation:
22 ;;
23 ;; For this file to work you need to have a working installation of
24 ;; AucTeX. After that installtion is simple. Put this file into one of
25 ;; the directories specified in `TeX-style-path', with the name
26 ;; "style" rather than "auto" as it might get over written in the
27 ;; latter.
28 ;;
29 ;; Then stick the current for into your .emacs
30 ;; (eval-after-load "latex"
31 ;;   '(add-to-list 'LaTeX-style-list '("prosper")))
32 ;;
33 ;;
34 ;; And that should be it. You check whether it's worked or not by
35 ;; opening a prosper document, and trying `LaTeX-environment'. "slide"
36 ;; should be available by tab completion and it should ask you about
37 ;; overlays.
38 ;;
39 ;; The environment "prosper" should be inserted immediately after the
40 ;; document environment.  It will prompt you for options available
41 ;; under prosper and create a skeleton document.
42
43 ;;; Bugs:
44 ;;
45 ;; Currently the documentclass expansion doesn't work, unless you
46 ;; enter a documentclass line to let auctex know which style files to
47 ;; load. Then delete this and do it again. Not good. I know no way
48 ;; around this.
49
50 ;;; Code:
51
52 ;; Constants:
53
54
55 ;;;; This is partly working now, and it a little neater than it
56 ;;;; was. The main problem is that the redefinition of "documentclass"
57 ;;;; does not happen until its all too late, so that stuff never
58 ;;;; happens correctly. This is easy enough to fix by fiddling with
59 ;;;; auctex. I shall have to download the latest version, and see if
60 ;;;; its already been fixed.
61
62
63
64 (defconst LaTeX-prosper-version "2008-05-25"
65   "prosper.el version.")
66
67 (defconst LaTeX-prosper-transition-styles '("Split"
68                                           "Blinds"
69                                           "Box"
70                                           "Wipe"
71                                           "Dissolve"
72                                           "Glitter"
73                                           "Replace")
74   "List of transition styles provided by prosper.")
75
76 (defconst LaTeX-prosper-slide-styles
77   '("alienglow" "autumn" "azure"
78     "contemporain" "darkblue" "default" "frames"
79     "lignesbleues" "nuancegris" "troispoints"
80     "alcatel" "gyom" "pascal" "rico"
81     ))
82
83 (defun LaTeX-prosper-insert-title (optional)
84   (newline)
85   (mapc (lambda(f)
86           (TeX-insert-macro f)
87           (newline))
88         '("title" "subtitle" "author" "email" "institution" "slideCaption"
89           "Logo" "DefaultTransition"))
90   (LaTeX-insert-environment "document")
91   (TeX-insert-macro "maketitle"))
92
93
94 ;; Utility functions
95 (defun LaTeX-prosper-arg-pdftransition (environment)
96   (let ((default
97           (if (boundp 'LaTeX-prosper-transition-history)
98               (car LaTeX-prosper-transition-history)
99             "Replace")))
100     (TeX-argument-insert
101      (completing-read
102       (TeX-argument-prompt nil
103                            (format "Transition (Default %s) " default)
104                            t)
105       (mapcar 'list LaTeX-prosper-transition-styles)
106       nil
107       t
108       nil
109       'LaTeX-prosper-transition-history
110       default)
111      nil)))
112
113 (defun LaTeX-prosper-slide-style-prompt()
114   (completing-read
115    "Slide Style?"
116    (mapcar 'list LaTeX-prosper-slide-styles)
117    nil nil nil nil "default" ))
118
119
120 (defun LaTeX-prosper-insert-options(environment)
121   (insert "[" )
122   (insert (LaTeX-prosper-slide-style-prompt) " ")
123   (mapc (lambda(f)
124           (if (y-or-n-p (car f))
125               (insert (car (cdr f)) " ")))
126         '(("Draft?" "draft")
127           ("Color Slides?" "slideColor")
128           ("Disable running total on each slide?" "nototal")
129           ("Is the final version going to be PDF?" "pdf")
130           ("Are you going to use Adobe Distiller" "distiller")))
131   (delete-char -1)
132   (insert "]"))
133
134 (defun LaTeX-prosper-insert-slide (environment)
135   (if (y-or-n-p "Surround with overlay ?")
136       (progn (TeX-insert-macro "overlays")
137              (if (search-backward "{" 0 t)
138                  (progn
139                    (goto-char (+ 1 (point)))
140                    (insert "%\n")))))
141   (let ((title (read-string "Title: ")))
142     (LaTeX-insert-environment "slide" (concat TeX-grop title TeX-grcl))))
143
144
145
146 ;; AUCTeX configuration
147 (TeX-add-style-hook "prosper"
148                     (function
149                      (lambda ()
150                        (LaTeX-add-environments
151                         '("slide" LaTeX-prosper-insert-slide)
152                         '("itemstep" LaTeX-env-item)
153                         '("Itemize" LaTeX-env-item))
154                        (TeX-add-symbols
155                         '("documentclass"
156                           LaTeX-prosper-insert-options
157                           LaTeX-prosper-insert-title)
158                         '("title" "Title of the presentation")
159                         '("subtitle" "Subtitle of the presentation")
160                         '("author" "Author name")
161                         '("email" "Author email")
162                         '("institution" "Author institution")
163                         '("slideCaption" "Caption for slide")
164                         '("Logo" "Logo")
165                         '("displayVersion" TeX-arg-free)
166                         '("DefaultTransition"
167                           LaTeX-prosper-arg-pdftransition)
168                         '("NoFrenchBabelItemize" TeX-arg-free)
169                         '("part" LaTeX-prosper-arg-part)
170                         '("overlays" "Number of overlays" t)
171                         '("FontTitle" "Color slides" "Black & White Slides")
172                         '("FontText" "Color slides" "Black & White Slides")
173                         '("fontTitle" "Text")
174                         '("fontText" "Text")
175                         '("ColorFoot" "Color")
176                         '("PDFtransition" LaTeX-prosper-arg-pdftransition)
177                         '("myitem" "Level" "Definition")
178                         '("fromSlide" "Number" t)
179                         '("fromSlide*" "Number" t)
180                         '("onlySlide" "Number" t)
181                         '("onlySlide*" "Number" t)
182                         '("OnlySlide" "Number")
183                         '("UntilSlide" "Number")
184                         '("untilSlide*" "Number")
185                         '("PDForPS" TeX-arg-conditional)
186                         '("onlyInPS" t)
187                         '("onlyInPDF" t)
188                         '("FromSlide" "Number"))))
189                     LaTeX-dialect)
190
191
192 ;;; prosper.el ends here