]> code.delx.au - gnu-emacs-elpa/blob - auctex-11.86/style/scrbase.el
Initial repository contents
[gnu-emacs-elpa] / auctex-11.86 / style / scrbase.el
1 ;;; scrbase.el --- AUCTeX style for the KOMA-Script bundle.
2
3 ;; Copyright (C) 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
4
5 ;; Author: Mark Trettin <Mark.Trettin@gmx.de>
6 ;; Created: 2002-09-26
7 ;; Keywords: tex
8
9 ;; This file is part of AUCTeX.
10
11 ;; AUCTeX 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 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 ;; 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; This file adds support for the KOMA-Script bundle. This file
29 ;; contains the base definitions that work with all KOMA-Script
30 ;; classes (scrarctl.cls, scrreprt.cls, scrbook.cls and scrlttr2.cls).
31 ;; You need this file since it's loaded from the class-styles.
32
33 ;;; Code:
34 (TeX-add-style-hook "scrbase"
35 (lambda ()
36 (TeX-add-symbols
37 "appendixmore"
38 "autodot"
39 '("addtokomafont" TeX-arg-KOMA-fontelements t)
40 '("areaset" [ "BCOR" ] "Width" "Height")
41 '("captionabove" [ "Lof entry" ] "Caption")
42 '("captionbelow" [ "Lof entry" ] "Caption")
43 '("cleardoubleemptypage")
44 '("cleardoubleplainpage")
45 '("cleardoublestandardpage")
46 '("dedication" t)
47 '("deffootnote" [ "Mark width" ] "Indent" "Parindent" "Definition")
48 '("deffootnotemark" "Definition")
49 '("extratitle" t)
50 '("ifpdfoutput" t nil)
51 '("ifthispageodd" t nil)
52 '("lowertitleback" t)
53 '("maketitle" [ "Pagenumber" ])
54 '("marginline" t)
55 '("publishers" "Publishers")
56 '("sectionmark" "Running head")
57 '("setbibpreamble" "Preamble")
58 '("setcaphanging")
59 '("setcapindent" "Indent")
60 '("setcapindent*" "X-Indent")
61 '("setcapmargin" [ "Margin left" ] "Margin")
62 '("setcapmargin*" [ "Margin inside" ] "Margin")
63 '("setcapwidth" [ TeX-arg-KOMA-capjust ] "Width")
64 '("setindexpreamble" "Preamble")
65 '("setkomafont" TeX-arg-KOMA-fontelements t)
66 '("subject" "Subject")
67 '("subsectionmark" "Running head")
68 '("textsubscript" "Text")
69 '("thanks" "Footnote")
70 '("thefootnotemark")
71 '("titlehead" t)
72 '("uppertitleback" t)
73 '("usekomafont" TeX-arg-KOMA-fontelements))
74 (LaTeX-add-environments
75 '("labeling" (lambda (env &rest ignore)
76 (LaTeX-insert-environment
77 env
78 (let ((delim (read-string "(Optional) Delimiter: "))
79 (width (read-string "Longest item: ")))
80 (concat
81 (if (not (zerop (length delim)))
82 (format "[%s]" delim))
83 (format "{%s}" width))))
84 (LaTeX-find-matching-begin)
85 (end-of-line 1)
86 (LaTeX-insert-item)))
87 '("addmargin" (lambda (env &rest ignore)
88 (LaTeX-insert-environment
89 env
90 (let ((leftin (read-string "(Optional) Left Indentation: "))
91 (indent (read-string "Indentation: ")))
92 (concat
93 (if (not (zerop (length leftin)))
94 (format "[%s]" leftin))
95 (format "{%s}" indent))))))
96 '("addmargin*" (lambda (env &rest ignore)
97 (LaTeX-insert-environment
98 env
99 (let ((innin (read-string "(Optional) Inner Indentation: "))
100 (indent (read-string "Indentation: ")))
101 (concat
102 (if (not (zerop (length innin)))
103 (format "[%s]" innin))
104 (format "{%s}" indent))))))
105 '("captionbeside" (lambda (env &rest ignore)
106 (LaTeX-insert-environment
107 env
108 (let ((lofent (read-string "(Optional) Lof Entry: "))
109 (title (read-string "Caption: "))
110 (place (read-string "(Optional) Placement (l,r,o,i): "))
111 (width (read-string "(Optional) Width: "))
112 (offset (read-string "(Optional) Offset: ")))
113 (concat
114 (if (not (zerop (length lofent)))
115 (format "[%s]" lofent))
116 (format "{%s}" title)
117 (if (not (zerop (length place)))
118 (format "[%s]" place))
119 (if (not (zerop (length width)))
120 (format "[%s]" width))
121 (and
122 (not (zerop (length place)))
123 (not (zerop (length offset)))
124 (format "[%s]%s" offset
125 (if (y-or-n-p "Starred? ")
126 "*" "")))))))))
127 (LaTeX-section-list-add-locally '(("addpart" 0)
128 ("addsec" 2)
129 ("minisec" 7)))
130 ;; This doesn't work. Maybe it's RefTeX's label insertion?
131 (make-local-variable 'LaTeX-section-label)
132 (setq LaTeX-section-label (append
133 LaTeX-section-label
134 '(("addpart" . nil)
135 ("addsec" . nil)
136 ("minisec" . nil))))
137 ;; Fontification
138 (when (and (featurep 'font-latex)
139 (eq TeX-install-font-lock 'font-latex-setup))
140 ;; Textual keywords
141 (font-latex-add-keywords '(("captionabove" "[{")
142 ("captionbelow" "[{")
143 ("dedication" "{")
144 ("extratitle" "{")
145 ("lowertitleback" "{")
146 ("maketitle" "[")
147 ("marginline" "{")
148 ("publishers" "{")
149 ("subject" "{")
150 ("sectionmark" "{")
151 ("setbibpreamble" "{")
152 ("setindexpreamble" "{")
153 ("subsectionmark" "{")
154 ("textsubscript" "{")
155 ("titlehead" "{")
156 ("uppertitleback" "{"))
157 'textual)
158 ;; Function keywords
159 (font-latex-add-keywords '(("deffootnote" "[{{{")
160 ("deffootnotemark" "{")
161 ("ifpdfoutput" "{{")
162 ("ifthispageodd" "{{"))
163 'function)
164 ;; Variable keywords
165 (font-latex-add-keywords '(("addtokomafont" "{{")
166 ("areaset" "[{{")
167 ("setcaphanging" "")
168 ("setcapindent" "{")
169 ("setcapmargin" "*[{")
170 ("setcapwidth" "[{")
171 ("setkomafont" "{{")
172 ("typearea" "[{")
173 ("usekomafont" "{"))
174 'variable)
175 ;; Warning keywords
176 (font-latex-add-keywords '("cleardoublestandardpage"
177 "cleardoubleplainpage"
178 "cleardoubleemptypage")
179 'warning)
180 ;; Sectioning keywords
181 (font-latex-add-keywords '(("addpart" "[{")) 'sectioning-1)
182 (font-latex-add-keywords '(("addsec" "[{")) 'sectioning-2)
183 (font-latex-add-keywords '(("minisec" "[{")) 'sectioning-4))))
184
185 (defun TeX-arg-KOMA-setpreamble (optional &optional prompt)
186 "Prompt for KOMA-Script's \\set*preamble position with completion."
187 (TeX-argument-insert
188 (completing-read
189 (TeX-argument-prompt optional prompt "Position")
190 '(("") ("l") ("r") ("c") ("o") ("u")
191 ("lo") ("lu") ("ro") ("ru") ("co") ("cu"))
192 nil t)
193 optional))
194
195 (defun TeX-arg-KOMA-capjust (optional &optional prompt)
196 "Prompt for KOMA-Script's \\setcapwidth justification with completion."
197 (TeX-argument-insert
198 (completing-read
199 (TeX-argument-prompt optional prompt "Justification")
200 '(("") ("l") ("r") ("c") ("i") ("o"))
201 nil t)
202 optional))
203
204 (defun TeX-arg-KOMA-fontelements (optional &optional prompt)
205 "Prompt for KOMA-Script's fontelements with completion."
206 (TeX-argument-insert
207 (completing-read
208 (TeX-argument-prompt optional prompt "Element")
209 '(("")
210 ("caption") ("captionlabel")
211 ("descriptionlabel") ("dictum") ("dictumauthor") ("dictumtext")
212 ("footnote") ("footnotelabel") ("footnotereference")
213 ("pagefoot") ("pagehead") ("pagenumber") ("pagination")
214 ("sectioning") ("part") ("partnumber") ("chapter") ("section")
215 ("subsection") ("subsubsection") ("paragraph") ("subparagraph")
216 ("title") ("disposition") ("minisec"))
217 nil t)
218 optional))
219
220 (add-to-list 'LaTeX-item-list '("labeling" . LaTeX-item-argument))
221
222 ;;; scrbase.el ends here