AUCTeX Sync -- New Style Files
[packages] / xemacs-packages / auctex / style / titleps.el
1 ;;; titleps.el --- AUCTeX style for `titleps.sty' (v1.1.1)
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5 ;; Author: Arash Esbati <arash@gnu.org>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Created: 2016-06-22
8 ;; Keywords: tex
9
10 ;; This file is part of AUCTeX.
11
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)
15 ;; any later version.
16
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.
21
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
25 ;; 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; This file adds support for `titleps.sty' (v1.1.1) from 2016/03/15.
30 ;; `titleps.sty' is part of TeXLive.
31
32 ;;; Code:
33
34 (defvar LaTeX-titleps-section-command-list
35   '("part"
36     "chapter"
37     "section"
38     "subsection"
39     "subsubsection"
40     "paragraph"
41     "subparagraph")
42   "List of sectioning commands available in \"titleps.sty\".")
43
44 (defun LaTeX-titleps-section-command-list ()
45   "Remove \"chapter\" from variable
46 `LaTeX-titleps-section-command-list' and return the remainder.
47 Removal is based on the return value of function
48 `LaTeX-largest-level'."
49   (if (< (LaTeX-largest-level) 2)
50       (symbol-value 'LaTeX-titleps-section-command-list)
51     (remove "chapter" LaTeX-titleps-section-command-list)))
52
53 (defvar LaTeX-titleps-newpagestyle-regexp
54   '("\\\\newpagestyle[ \t\n\r%]*{\\([^}]+\\)}" 1 LaTeX-auto-pagestyle)
55   "Match the argument of \"\\newpagestyle\" from titleps.sty.")
56
57 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
58
59 (TeX-add-style-hook
60  "titleps"
61  (lambda ()
62
63    ;; Add titleps to the parser.
64    (TeX-auto-add-regexp LaTeX-titleps-newpagestyle-regexp)
65
66    ;; Add \<section>title's
67    (dolist (sec (LaTeX-titleps-section-command-list))
68      (TeX-add-symbols `(,(concat sec "title") 0)))
69
70    (TeX-add-symbols
71    ;; 2. Defining Page Styles
72     '("newpagestyle"
73       (TeX-arg-eval
74        (lambda ()
75          (let ((ps (TeX-read-string
76                     (TeX-argument-prompt optional nil "Page style"))))
77            (LaTeX-add-pagestyles ps)
78            (format "%s" ps))))
79       (TeX-arg-conditional (y-or-n-p "With optional global style? ")
80                            ( [ t ] nil)
81                          ( t )))
82
83     '("renewpagestyle" TeX-arg-pagestyle
84       (TeX-arg-conditional (y-or-n-p "With optional global style? ")
85                            ( [ t ] nil)
86                          ( t )))
87
88     '("sethead"
89       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
90                            ( [ 3 ] nil nil nil)
91                          ( 3 )))
92
93     '("setfoot"
94       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
95                            ( [ 3 ] nil nil nil)
96                          ( 3 )))
97
98     '("sethead*" 3)
99     '("setfoot*" 3)
100
101     '("settitlemarks"
102       (TeX-arg-eval mapconcat #'identity
103                     (TeX-completing-read-multiple
104                      (TeX-argument-prompt optional nil "Level names")
105                      (LaTeX-titleps-section-command-list))
106                     ","))
107
108     '("settitlemarks"
109       (TeX-arg-eval mapconcat #'identity
110                     (TeX-completing-read-multiple
111                      (TeX-argument-prompt optional nil "Level names")
112                      (LaTeX-titleps-section-command-list))
113                     ","))
114
115     '("headrule" 0)
116     '("setheadrule" "Thickness")
117
118     '("footrule" 0)
119     '("setfootrule" "Thickness")
120
121     '("makeheadrule" 0)
122     '("makefootrule" 0)
123
124     ;; 3. On \markboth and \markleft
125     '("setmarkboth" t)
126     '("resetmarkboth" 0)
127
128     ;; 4. Headline/footline width
129     '("widenhead"
130       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
131                            ( [ 2 ] nil nil)
132                          ( 2 )))
133
134     '("widenhead*" 2)
135
136     '("TitlepsPatchSection"
137       (TeX-arg-eval completing-read
138                     (TeX-argument-prompt optional nil "Sectioning command")
139                     (LaTeX-titleps-section-command-list)))
140
141     '("TitlepsPatchSection*"
142       (TeX-arg-eval completing-read
143                     (TeX-argument-prompt optional nil "Sectioning command")
144                     (LaTeX-titleps-section-command-list)))
145
146     ;; 5. Marks
147     '("bottitlemarks"     0)
148     '("toptitlemarks"     0)
149     '("firsttitlemarks"   0)
150     '("nexttoptitlemarks" 0)
151     '("outertitlemarks"   0)
152     '("innertitlemarks"   0)
153
154     '("newtitlemark" (TeX-arg-macro "Command name"))
155     '("newtitlemark*" (TeX-arg-counter "Variable name"))
156
157     '("pretitlemark"
158       (TeX-arg-eval completing-read
159                     (TeX-argument-prompt optional nil "Sectioning command")
160                     (LaTeX-titleps-section-command-list))
161       "Text")
162
163     '("pretitlemark*"
164       (TeX-arg-eval completing-read
165                     (TeX-argument-prompt optional nil "Sectioning command")
166                     (LaTeX-titleps-section-command-list))
167       "Text")
168
169     '("ifsamemark"
170       (TeX-arg-macro "Marks group: \\")
171       (TeX-arg-macro "Command: \\")
172       2)
173
174     ;; 6. Running heads with floats
175     '("setfloathead"
176       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
177                            ( [ 3 ] nil nil nil nil [ nil ] )
178                          ( 4 [ nil ] )))
179
180     '("setfloatfoot"
181       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
182                            ( [ 3 ] nil nil nil nil [ nil ] )
183                          ( 4 [ nil ] )))
184
185     '("setfloathead*" 4 [ nil ] )
186     '("setfloatfoot*" 4 [ nil ] )
187
188     '("nextfloathead"
189       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
190                            ( [ 3 ] nil nil nil nil [ nil ] )
191                          ( 4 [ nil ] )))
192
193     '("nextfloatfoot"
194       (TeX-arg-conditional (y-or-n-p "With optional even pages? ")
195                            ( [ 3 ] nil nil nil nil [ nil ] )
196                          ( 4 [ nil ] )))
197
198     '("nextfloathead*" 4 [ nil ] )
199     '("nextfloatfoot*" 4 [ nil ] )
200
201     ;; 7. Extra marks: I'm not clear how the marks commands work;
202     ;; until then, I ignore them
203     )
204
205    (when (and (featurep 'font-latex)
206               (eq TeX-install-font-lock 'font-latex-setup))
207      (font-latex-add-keywords '(("newpagestyle"         "{[{")
208                                 ("renewpagestyle"       "{[{")
209                                 ("settitlemarks"        "*{")
210                                 ("widenhead"            "*[[{{")
211                                 ("TitlepsPatchSection"  "*{")
212                                 ("newtitlemark"         "*{")
213                                 ("pretitlemark"         "*{{")
214                                 ("nextfloathead"        "*[[[{{{{[")
215                                 ("nextfloatfoot"        "*[[[{{{{["))
216                               'function)))
217  LaTeX-dialect)
218
219 (defvar LaTeX-titleps-package-options
220   '(;; 4. Headline/footline width
221     "nopatches"
222
223     ;; 5. Marks
224     "outermarks" "innermarks" "topmarks" "botmarks"
225
226     ;; 6. Running heads with floats
227     "psfloats"
228
229     ;; 7. Extra marks
230     "extramarks")
231   "Package options for the titleps package.")
232
233 ;;; titleps.el ends here