Initial Commit
[packages] / xemacs-packages / auctex / style / listings.el
1 ;;; listings.el --- AUCTeX style for `listings.sty'
2
3 ;; Copyright (C) 2004, 2005, 2009, 2013 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 (2007/02/22 Version 1.4).
37 (defvar LaTeX-listings-key-val-options
38   '(;; Space and placement
39     ("float" ("t" "b" "p" "h")) ; Support [*] as an optional prefix and that
40                                 ; tbph are not exclusive.
41     ("floatplacement" ("t" "b" "p" "h"))
42     ("aboveskip")
43     ("belowskip")
44     ("lineskip")
45     ("boxpos" ("b" "c" "t"))
46     ;; The printed range
47     ("print" ("true" "false"))
48     ("firstline")
49     ("lastline")
50     ("linerange")
51     ("showlines" ("true" "false"))
52     ("emptylines")
53     ("gobble")
54     ;; Languages and styles
55     ("style")
56     ("language")
57     ("alsolanguage")
58     ("defaultdialect")
59     ("printpod" ("true" "false"))
60     ("usekeywordsintag" ("true" "false"))
61     ("tagstyle")
62     ("markfirstintag")
63     ("makemacrouse" ("true" "false"))
64     ;; Figure out the appearance
65     ("basicstyle")
66     ("identifierstyle")
67     ("commentstyle")
68     ("stringstyle")
69     ("keywordstyle")
70     ("classoffset")
71     ("texcsstyle")
72     ("directivestyle")
73     ("emph")
74     ("moreemph")
75     ("deleteemph")
76     ("emphstyle")
77     ("delim")
78     ("moredelim")
79     ("deletedelim")
80     ;; Getting all characters right
81     ("extendedchars" ("true" "false"))
82     ("inputencoding") ; Could make use of `latex-inputenc-coding-alist'.
83     ("upquote" ("true" "false"))
84     ("tabsize")
85     ("showtabs" ("true" "false"))
86     ("tab")
87     ("showspaces" ("true" "false"))
88     ("showstringspaces" ("true" "false"))
89     ("formfeed")
90     ;; Line numbers
91     ("numbers" ("none" "left" "right"))
92     ("stepnumber")
93     ("numberfirstline" ("true" "false"))
94     ("numberstyle")
95     ("numbersep")
96     ("numberblanklines" ("true" "false"))
97     ("firstnumber" ("auto" "last")) ; Can also take a number.
98     ("name")
99     ;; Captions
100     ("title")
101     ("caption") ; Insert braces?
102     ("label")
103     ("nolol" ("true" "false"))
104     ("numberbychapter" ("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" "spaceflexible")) ;
145                                         ; Also supports an optional
146                                         ; argument with {c,l,r}.
147     ("flexiblecolumns" ("true" "false"))
148     ("keepspaces" ("true" "false"))
149     ("basewidth")
150     ("fontadjust" ("true" "false"))
151     ;; Escaping to LaTeX
152     ("texcl" ("true" "false"))
153     ("mathescape" ("true" "false"))
154     ("escapechar")
155     ("escapeinside")
156     ("escapebegin")
157     ("escapeend")
158     ;; Interface to fancyvrb
159     ("fancyvrb" ("true" "false"))
160     ("fvcmdparams")
161     ("morefvcmdparams")
162     ;; Language definitions
163     ("keywordsprefix")
164     ("keywords")
165     ("morekeywords")
166     ("deletekeywords")
167     ("texcs")
168     ("moretexcs")
169     ("deletetexcs")
170     ("directives")
171     ("moredirectives")
172     ("deletedirectives")
173     ("sensitive" ("true" "false"))
174     ("alsoletter")
175     ("alsodigit")
176     ("alsoother")
177     ("otherkeywords")
178     ("tag")
179     ("string")
180     ("morestring")
181     ("deletestring")
182     ("comment")
183     ("morecomment")
184     ("deletecomment")
185     ("keywordcomment")
186     ("morekeywordcomment")
187     ("deletekeywordcomment")
188     ("keywordcommentsemicolon")
189     ("podcomment" ("true" "false"))
190     ;; The following are all options from chapter 5, which are
191     ;; experimental
192     ;; Export of identifiers
193     ("procnamekeys")
194     ("moreprocnamekeys")
195     ("deleteprocnamekeys")
196     ("procnamestyle")
197     ("indexprocnames" ("true" "false"))
198     ;; Hyperlink references
199     ("hyperref")
200     ("morehyperref")
201     ("deletehyperref")
202     ("hyperanchor")
203     ("hyperlink")
204     ;; Literate programming
205     ("literate") ;; three arguments: replace,replacement text,length
206     ;; LGrind definitions
207     ("lgrindef")
208     ;; Arbitrary linerange markers
209     ("rangebeginprefix")
210     ("rangebeginsuffix")
211     ("rangeendprefix")
212     ("rangeendsuffix")
213     ("rangeprefix")
214     ("rangesuffix")
215     ("includerangemarker" ("true" "false"))
216     ;; Multicolumn Listing
217     ("multicolumn"))
218   "Key=value options for listings macros and environments.")
219
220 (TeX-add-style-hook
221  "listings"
222  (lambda ()
223    ;; New symbols
224    (TeX-add-symbols
225     '("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
226     '("lstdefinestyle" "Style name"
227       (TeX-arg-key-val LaTeX-listings-key-val-options))
228     '("lstinline" TeX-arg-verb)
229     '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options]
230       TeX-arg-file)
231     "lstlistoflistings"
232     '("lstnewenvironment" "Name" ["Number or arguments"] ["Default argument"]
233       "Starting code" "Ending code")
234     '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options))
235     '("lstloadlanguages" t)
236     ;; 4.17 Short Inline Listing Commands
237     '("lstMakeShortInline" [ "Options" ] "Character")
238     '("lstDeleteShortInline" "Character")
239     
240     "lstgrinddeffile" "lstaspectfiles" "lstlanguagefiles"
241     "lstlistingname" "lstlistlistingname")
242    
243    ;; New environments
244    (LaTeX-add-environments
245     '("lstlisting" LaTeX-env-args
246       [TeX-arg-key-val LaTeX-listings-key-val-options]))
247    ;; Filling
248    (make-local-variable 'LaTeX-indent-environment-list)
249    (add-to-list 'LaTeX-indent-environment-list
250                 '("lstlisting" current-indentation))
251    (make-local-variable 'LaTeX-verbatim-regexp)
252    (setq LaTeX-verbatim-regexp (concat LaTeX-verbatim-regexp "\\|lstlisting"))
253    (add-to-list 'LaTeX-verbatim-environments-local "lstlisting")
254    (add-to-list 'LaTeX-verbatim-macros-with-delims-local "lstinline")
255    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "lstinline")
256    ;; Fontification
257    (when (and (fboundp 'font-latex-add-keywords)
258               (fboundp 'font-latex-set-syntactic-keywords)
259               (eq TeX-install-font-lock 'font-latex-setup))
260      (font-latex-add-keywords '(("lstnewenvironment" "{[[{{")) 'function)
261      (font-latex-add-keywords '(("lstinputlisting" "[{")) 'reference)
262      (font-latex-add-keywords '(("lstinline" "[{") ; The second argument should
263                                                    ; actually be verbatim.
264                                 ("lstlistoflistings" ""))
265                               'textual)
266      (font-latex-add-keywords '(("lstalias" "{{")
267                                 ("lstdefinestyle" "{{")
268                                 ("lstset" "{"))
269                               'variable)
270      ;; For syntactic fontification, e.g. verbatim constructs.
271      (font-latex-set-syntactic-keywords)
272      ;; Tell font-lock about the update.
273      (setq font-lock-set-defaults nil)
274      (font-lock-set-defaults)))
275  LaTeX-dialect)
276
277 (defvar LaTeX-listings-package-options '("draft" "final" "savemem" 
278                                          "noaspects"
279                                          ;; procnames is mentioned in
280                                          ;; Section 5.2 
281                                          "procnames")
282   "Package options for the listings package.")
283
284 ;;; listings.el ends here