]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex-11.86/style/listings.el
cfb11e993fed5d77d6987e2650855cdd1e0e2f5d
[gnu-emacs-elpa] / packages / auctex-11.86 / style / listings.el
1 ;;; listings.el --- AUCTeX style for `listings.sty'
2
3 ;; Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc.
4
5 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Created: 2004-10-17
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 `listings.sty'.
30 ;;
31 ;; FIXME: Please make me more sophisticated!
32
33 ;;; Code:
34
35 ;; The following are options taken from chapter 4 of the listings
36 ;; manual (2006/05/08 Version 1.3c). Experimental options described
37 ;; in chapter 5 are not included.
38 (defvar LaTeX-listings-key-val-options
39 '(;; Space and placement
40 ("float" ("t" "b" "p" "h")) ; Support [*] as an optional prefix and that
41 ; tbph are not exclusive.
42 ("floatplacement" ("t" "b" "p" "h"))
43 ("aboveskip")
44 ("belowskip")
45 ("lineskip")
46 ("boxpos" ("b" "c" "t"))
47 ;; The printed range
48 ("print" ("true" "false"))
49 ("firstline")
50 ("lastline")
51 ("linerange")
52 ("showlines" ("true" "false"))
53 ("emptylines")
54 ("gobble")
55 ;; Languages and styles
56 ("style")
57 ("language")
58 ("alsolanguage")
59 ("defaultdialect")
60 ("printpod" ("true" "false"))
61 ("usekeywordsintag" ("true" "false"))
62 ("tagstyle")
63 ("markfirstintag")
64 ("makemacrouse" ("true" "false"))
65 ;; Figure out the appearance
66 ("basicstyle")
67 ("identifierstyle")
68 ("commentstyle")
69 ("stringstyle")
70 ("keywordstyle")
71 ("classoffset")
72 ("texcsstyle")
73 ("directivestyle")
74 ("emph")
75 ("moreemph")
76 ("deleteemph")
77 ("emphstyle")
78 ("delim")
79 ("moredelim")
80 ("deletedelim")
81 ;; Getting all characters right
82 ("extendedchars" ("true" "false"))
83 ("inputencoding") ; Could make use of `latex-inputenc-coding-alist'.
84 ("upquote" ("true" "false"))
85 ("tabsize")
86 ("showtabs" ("true" "false"))
87 ("tab")
88 ("showspaces" ("true" "false"))
89 ("showstringspaces" ("true" "false"))
90 ("formfeed")
91 ;; Line numbers
92 ("numbers" ("none" "left" "right"))
93 ("stepnumber")
94 ("numberfirstline" ("true" "false"))
95 ("numberstyle")
96 ("numbersep")
97 ("numberblanklines" ("true" "false"))
98 ("firstnumber" ("auto" "last")) ; Can also take a number.
99 ("name")
100 ;; Captions
101 ("title")
102 ("caption") ; Insert braces?
103 ("label")
104 ("nolol" ("true" "false"))
105 ("captionpos" ("t" "b")) ; Can be a subset of tb.
106 ("abovecaptionskip")
107 ("belowcaptionskip")
108 ;; Margins and line shape
109 ("linewidth")
110 ("xleftmargin")
111 ("xrightmargin")
112 ("resetmargins" ("true" "false"))
113 ("breaklines" ("true" "false"))
114 ("breakatwhitespace" ("true" "false"))
115 ("prebreak")
116 ("postbreak")
117 ("breakindent")
118 ("breakautoindent" ("true" "false"))
119 ;; Frames
120 ("frame" ("none" "leftline" "topline" "bottomline" "lines" "single"
121 "shadowbox"
122 ;; Alternative to the above values. A subset of trblTRBL can be
123 ;; given.
124 "t" "r" "b" "l" "T" "R" "B" "L"))
125 ("frameround" ("t" "f")) ; The input actually has to be four times {t,f}.
126 ("framesep")
127 ("rulesep")
128 ("framerule")
129 ("framexleftmargin")
130 ("framexrightmargin")
131 ("framextopmargin")
132 ("framebottommargin")
133 ("backgroundcolor")
134 ("rulecolor")
135 ("fillcolor")
136 ("fulesepcolor")
137 ("frameshape")
138 ;; Indexing
139 ("index")
140 ("moreindex")
141 ("deleteindex")
142 ("indexstyle")
143 ;; Column alignment
144 ("columns" ("fixed" "flexible" "fullflexible")) ; Also supports an optional
145 ; argument with {c,l,r}.
146 ("flexiblecolumns" ("true" "false"))
147 ("keepspaces" ("true" "false"))
148 ("basewidth")
149 ("fontadjust" ("true" "false"))
150 ;; Escaping to LaTeX
151 ("texcl" ("true" "false"))
152 ("mathescape" ("true" "false"))
153 ("escapechar")
154 ("escapeinside")
155 ("escapebegin")
156 ("escapeend")
157 ;; Interface to fancyvrb
158 ("fancyvrb" ("true" "false"))
159 ("fvcmdparams")
160 ("morefvcmdparams")
161 ;; Language definitions
162 ("keywordsprefix")
163 ("keywords")
164 ("morekeywords")
165 ("deletekeywords")
166 ("texcs")
167 ("moretexcs")
168 ("deletetexcs")
169 ("directives")
170 ("moredirectives")
171 ("deletedirectives")
172 ("sensitive" ("true" "false"))
173 ("alsoletter")
174 ("alsodigit")
175 ("alsoother")
176 ("otherkeywords")
177 ("tag")
178 ("string")
179 ("morestring")
180 ("deletestring")
181 ("comment")
182 ("morecomment")
183 ("deletecomment")
184 ("keywordcomment")
185 ("morekeywordcomment")
186 ("deletekeywordcomment")
187 ("keywordcommentsemicolon")
188 ("podcomment" ("true" "false")))
189 "Key=value options for listings macros and environments.")
190
191 (TeX-add-style-hook
192 "listings"
193 (lambda ()
194 ;; New symbols
195 (TeX-add-symbols
196 '("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
197 '("lstdefinestyle" "Style name"
198 (TeX-arg-key-val LaTeX-listings-key-val-options))
199 '("lstinline" TeX-arg-verb)
200 '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options]
201 TeX-arg-file)
202 "lstlistoflistings"
203 '("lstnewenvironment" "Name" ["Number or arguments"] ["Default argument"]
204 "Starting code" "Ending code")
205 '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options)))
206 ;; New environments
207 (LaTeX-add-environments
208 '("lstlisting" LaTeX-env-args
209 [TeX-arg-key-val LaTeX-listings-key-val-options]))
210 ;; Filling
211 (make-local-variable 'LaTeX-indent-environment-list)
212 (add-to-list 'LaTeX-indent-environment-list
213 '("lstlisting" current-indentation))
214 (make-local-variable 'LaTeX-verbatim-regexp)
215 (setq LaTeX-verbatim-regexp (concat LaTeX-verbatim-regexp "\\|lstlisting"))
216 (add-to-list 'LaTeX-verbatim-environments-local "lstlisting")
217 (add-to-list 'LaTeX-verbatim-macros-with-delims-local "lstinline")
218 (add-to-list 'LaTeX-verbatim-macros-with-braces-local "lstinline")
219 ;; Fontification
220 (when (and (fboundp 'font-latex-add-keywords)
221 (fboundp 'font-latex-set-syntactic-keywords)
222 (eq TeX-install-font-lock 'font-latex-setup))
223 (font-latex-add-keywords '(("lstnewenvironment" "{[[{{")) 'function)
224 (font-latex-add-keywords '(("lstinputlisting" "[{")) 'reference)
225 (font-latex-add-keywords '(("lstinline" "[{") ; The second argument should
226 ; actually be verbatim.
227 ("lstlistoflistings" ""))
228 'textual)
229 (font-latex-add-keywords '(("lstalias" "{{")
230 ("lstdefinestyle" "{{")
231 ("lstset" "{"))
232 'variable)
233 ;; For syntactic fontification, e.g. verbatim constructs.
234 (font-latex-set-syntactic-keywords)
235 ;; Tell font-lock about the update.
236 (setq font-lock-set-defaults nil)
237 (font-lock-set-defaults))))
238
239 (defvar LaTeX-listings-package-options '("draft" "final" "savemem"
240 "noaspects")
241 "Package options for the listings package.")
242
243 ;;; listings.el ends here