1 ;;; listings.el --- AUCTeX style for `listings.sty'
3 ;; Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc.
5 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
6 ;; Maintainer: auctex-devel@gnu.org
10 ;; This file is part of AUCTeX.
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)
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.
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
29 ;; This file adds support for `listings.sty'.
31 ;; FIXME: Please make me more sophisticated!
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"))
46 ("boxpos" ("b" "c" "t"))
48 ("print" ("true" "false"))
52 ("showlines" ("true" "false"))
55 ;; Languages and styles
60 ("printpod" ("true" "false"))
61 ("usekeywordsintag" ("true" "false"))
64 ("makemacrouse" ("true" "false"))
65 ;; Figure out the appearance
81 ;; Getting all characters right
82 ("extendedchars" ("true" "false"))
83 ("inputencoding") ; Could make use of `latex-inputenc-coding-alist'.
84 ("upquote" ("true" "false"))
86 ("showtabs" ("true" "false"))
88 ("showspaces" ("true" "false"))
89 ("showstringspaces" ("true" "false"))
92 ("numbers" ("none" "left" "right"))
94 ("numberfirstline" ("true" "false"))
97 ("numberblanklines" ("true" "false"))
98 ("firstnumber" ("auto" "last")) ; Can also take a number.
102 ("caption") ; Insert braces?
104 ("nolol" ("true" "false"))
105 ("captionpos" ("t" "b")) ; Can be a subset of tb.
108 ;; Margins and line shape
112 ("resetmargins" ("true" "false"))
113 ("breaklines" ("true" "false"))
114 ("breakatwhitespace" ("true" "false"))
118 ("breakautoindent" ("true" "false"))
120 ("frame" ("none" "leftline" "topline" "bottomline" "lines" "single"
122 ;; Alternative to the above values. A subset of trblTRBL can be
124 "t" "r" "b" "l" "T" "R" "B" "L"))
125 ("frameround" ("t" "f")) ; The input actually has to be four times {t,f}.
130 ("framexrightmargin")
132 ("framebottommargin")
144 ("columns" ("fixed" "flexible" "fullflexible")) ; Also supports an optional
145 ; argument with {c,l,r}.
146 ("flexiblecolumns" ("true" "false"))
147 ("keepspaces" ("true" "false"))
149 ("fontadjust" ("true" "false"))
151 ("texcl" ("true" "false"))
152 ("mathescape" ("true" "false"))
157 ;; Interface to fancyvrb
158 ("fancyvrb" ("true" "false"))
161 ;; Language definitions
172 ("sensitive" ("true" "false"))
185 ("morekeywordcomment")
186 ("deletekeywordcomment")
187 ("keywordcommentsemicolon")
188 ("podcomment" ("true" "false")))
189 "Key=value options for listings macros and environments.")
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]
203 '("lstnewenvironment" "Name" ["Number or arguments"] ["Default argument"]
204 "Starting code" "Ending code")
205 '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options)))
207 (LaTeX-add-environments
208 '("lstlisting" LaTeX-env-args
209 [TeX-arg-key-val LaTeX-listings-key-val-options]))
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")
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" ""))
229 (font-latex-add-keywords '(("lstalias" "{{")
230 ("lstdefinestyle" "{{")
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))))
239 (defvar LaTeX-listings-package-options '("draft" "final" "savemem"
241 "Package options for the listings package.")
243 ;;; listings.el ends here