1 ;;; fancyvrb.el --- AUCTeX style for `fancyvrb.sty' version 2.8.
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Author: Mosè Giordano <giordano.mose@libero.it>
9 ;; This file is part of AUCTeX.
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)
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.
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
28 ;; This file adds support for `fancyvrb.sty' version 2.8.
32 (defvar LaTeX-fancyvrb-macro-regexp
33 (concat "\\\\\\(?:Re\\|\\)CustomVerbatimCommand"
34 "[ \t\n\r]*{?[ \t\n\r]*\\\\\\([A-Za-z]+\\)[ \t\n\r]*}?")
35 "Matches macros by fancyvrb package.")
37 (defvar LaTeX-fancyvrb-environment-regexp
38 (concat "\\\\\\(?:Define\\|Custom\\|Recustom\\)VerbatimEnvironment"
39 "[ \t\n\r]*{[ \t\n\r]*\\([A-Za-z]+\\)[ \t\n\r]*}")
40 "Matches environments by fancyvrb package.")
42 (defvar LaTeX-fancyvrb-key-val-options
46 ("fontfamily" ("tt" "courier" "helvetica"))
50 ("frame" ("none" "leftline" "topline" "bottomline" "lines" "single"))
56 ("labelposition" ("none" "topline" "bottomline" "all"))
57 ("numbers" ("none" "left" "right"))
59 ("firstnumber" ("auto" "last" "integer"))
61 ("numberblanklines" ("true" "false"))
64 ("showspaces" ("true" "false"))
65 ("showtabs" ("true" "false"))
66 ("obeytabs" ("true" "false"))
68 ("baselinestretch" ("auto" "dimension"))
72 ("resetmargins" ("true" "false"))
74 ("samepage" ("true" "false"))
77 ;; Actually, the following options are used only by the `BVerbatim'
79 ("boxwidth" ("auto" "dimension"))
80 ("baseline" ("b" "c" "t")))
81 "Key=value options for fancyvrb macros and environments.")
86 (TeX-auto-add-regexp `(,LaTeX-fancyvrb-macro-regexp 1 TeX-auto-symbol))
88 `(,LaTeX-fancyvrb-environment-regexp 1 LaTeX-auto-environment))
92 ;;; Verbatim material in footnotes
94 ;;; Improved verbatim commands
95 '("Verb" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options] TeX-arg-verb)
98 ;;; Verbatim environments
99 '("fvset" (TeX-arg-key-val LaTeX-fancyvrb-key-val-options))
100 ;; Changing individual line formatting
101 "FancyVerbFormatLine"
104 ;; Selection of lines to print
105 "FancyVerbStartString"
106 "FancyVerbStopString"
107 ;; Personalized environments
108 '("CustomVerbatimEnvironment"
109 (TeX-arg-define-environment "New verbatim environment")
110 (TeX-arg-environment "Basend on environment")
111 (TeX-arg-key-val LaTeX-fancyvrb-key-val-options))
112 '("RecustomVerbatimEnvironment"
113 (TeX-arg-environment "New verbatim environment")
114 (TeX-arg-environment "Basend on environment")
115 (TeX-arg-key-val LaTeX-fancyvrb-key-val-options))
116 '("DefineVerbatimEnvironment"
117 (TeX-arg-define-environment "New verbatim environment")
118 (TeX-arg-environment "Basend on environment")
119 (TeX-arg-key-val LaTeX-fancyvrb-key-val-options))
120 '("CustomVerbatimCommand" (TeX-arg-define-macro "New verbatim macro: ")
121 (TeX-arg-eval completing-read "Based on macro: " (TeX-symbol-list))
122 (TeX-arg-key-val LaTeX-fancyvrb-key-val-options))
123 '("RecustomVerbatimCommand" (TeX-arg-macro "New verbatim macro: ")
124 (TeX-arg-eval completing-read "Based on macro: " (TeX-symbol-list))
125 (TeX-arg-key-val LaTeX-fancyvrb-key-val-options))
126 ;;; Saving and restoring verbatim text and environments
133 ;;; Writing and reading verbatim files
134 '("VerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options]
136 '("BVerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options]
138 '("LVerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options]
140 (LaTeX-add-environments
141 '("Verbatim" LaTeX-env-args
142 [TeX-arg-key-val LaTeX-fancyvrb-key-val-options])
143 '("BVerbatim" LaTeX-env-args
144 [TeX-arg-key-val LaTeX-fancyvrb-key-val-options])
145 '("LVerbatim" LaTeX-env-args
146 [TeX-arg-key-val LaTeX-fancyvrb-key-val-options])
147 '("SaveVerbatim" LaTeX-env-args
148 [TeX-arg-key-val LaTeX-fancyvrb-key-val-options])
151 (let ((options (TeX-read-key-val t LaTeX-fancyvrb-key-val-options))
152 (file (TeX-read-string "Output file: ")))
153 (LaTeX-insert-environment
155 (concat (unless (zerop (length options))
156 (concat LaTeX-optop options LaTeX-optcl))
157 (concat TeX-grop file TeX-grcl)))))))
162 (set (make-local-variable 'LaTeX-verbatim-regexp)
164 LaTeX-verbatim-regexp
165 "\\|Verbatim\\|BVerbatim\\|LVerbatim\\|SaveVerbatim\\|VerbatimOut"))
166 (add-to-list 'LaTeX-verbatim-environments-local "Verbatim")
167 (add-to-list 'LaTeX-verbatim-environments-local "BVerbatim")
168 (add-to-list 'LaTeX-verbatim-environments-local "LVerbatim")
169 (add-to-list 'LaTeX-verbatim-environments-local "SaveVerbatim")
170 (add-to-list 'LaTeX-verbatim-environments-local "VerbatimOut")
171 (make-local-variable 'LaTeX-indent-environment-list)
172 (add-to-list 'LaTeX-indent-environment-list '("Verbatim" current-indentation))
173 (add-to-list 'LaTeX-indent-environment-list '("BVerbatim" current-indentation))
174 (add-to-list 'LaTeX-indent-environment-list '("LVerbatim" current-indentation))
175 (add-to-list 'LaTeX-indent-environment-list '("SaveVerbatim" current-indentation))
176 (add-to-list 'LaTeX-indent-environment-list '("VerbatimOut" current-indentation))
177 (add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb")
178 (add-to-list 'LaTeX-verbatim-macros-with-braces-local "Verb")
181 (when (and (fboundp 'font-latex-add-keywords)
182 (fboundp 'font-latex-set-syntactic-keywords)
183 (eq TeX-install-font-lock 'font-latex-setup))
184 (font-latex-add-keywords '(("DefineVerbatimEnvironment" "{{{")
185 ("CustomVerbatimEnvironment" "{{{")
186 ("RecustomVerbatimEnvironment" "{{{"))
188 (font-latex-add-keywords '(("VerbatimInput" "[{")
189 ("BVerbatimInput" "[{")
190 ("LVerbatimInput" "[{"))
192 (font-latex-add-keywords '(("Verb" "[")) ; The second argument should
193 ; actually be verbatim.
195 (font-latex-add-keywords '(("fvset" "{")) 'variable)
196 ;; For syntactic fontification, e.g. verbatim constructs.
197 (font-latex-set-syntactic-keywords)
198 ;; Tell font-lock about the update.
199 (setq font-lock-set-defaults nil)
200 (font-lock-set-defaults)))
203 (defvar LaTeX-fancyvrb-package-options nil
204 "Package options for the fancyvrb package.")
206 ;;; fancyvrb.el ends here