"Fossies" - the Fresh Open Source Software Archive

Member "auctex-12.3/style/fancyvrb.el" (18 Oct 2020, 21974 Bytes) of package /linux/misc/auctex-12.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lisp source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "fancyvrb.el": 12.2_vs_12.3.

    1 ;;; fancyvrb.el --- AUCTeX style for `fancyvrb.sty' version 3.0.
    2 
    3 ;; Copyright (C) 2013, 2014, 2016-2018, 2020 Free Software Foundation, Inc.
    4 
    5 ;; Maintainer: auctex-devel@gnu.org
    6 ;; Author: Mosè Giordano <mose@gnu.org>
    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 `fancyvrb.sty' version 3.0.
   29 
   30 ;; This style has some capabilities to parse user defined macros,
   31 ;; environments and saved blocks with `SaveVerbatim' environments and
   32 ;; offer them for completion.  After defining a new macro or
   33 ;; environment, hit `C-c C-n' to parse the document.  In case of
   34 ;; `SaveVerbatim', a second `C-c C-n' might be necessary.
   35 
   36 ;; The command `\CustomVerbatimEnvironment' is not mentioned in the
   37 ;; documenation; hence this command is removed from this style.  Use
   38 ;; `\DefineVerbatimEnvironment' for new environments and customize the
   39 ;; standard ones with `\RecustomVerbatimEnvironment'.
   40 
   41 ;; The entries in `LaTeX-fancyvrb-key-val-options' cover also some
   42 ;; keys which are not mentioned in the manual of the package.
   43 
   44 ;;; Code:
   45 
   46 ;; Needed for auto-parsing:
   47 (require 'tex)
   48 (require 'latex)
   49 
   50 ;; Silence the compiler:
   51 (declare-function font-latex-add-keywords
   52           "font-latex"
   53           (keywords class))
   54 
   55 (declare-function font-latex-set-syntactic-keywords
   56           "font-latex")
   57 
   58 (defvar LaTeX-fancyvrb-key-val-options
   59   `(("commentchar" ("none"))
   60     ("gobble")
   61     ("formatcom")
   62     ;; Undocumented key
   63     ("formatcom*")
   64     ("fontfamily" ("tt" "courier" "helvetica"))
   65     ("fontsize"   ("auto" "\\tiny" "\\scriptsize"
   66            "\\footnotesize" "\\small" "\\normalsize"
   67            "\\large" "\\Large" "\\LARGE" "\\huge" "\\Huge"))
   68     ("fontshape"  ("auto" "n" "it" "sl" "sc" "scit"))
   69     ("fontseries" ("auto" "m" "b" "bx" "sb" "c" "l" "lc"))
   70     ("frame" ("none" "leftline" "topline" "bottomline" "lines" "single"))
   71     ("framerule")
   72     ("framesep")
   73     ("rulecolor" ("none"))
   74     ("fillcolor" ("none"))
   75     ("label" ("none"))
   76     ("labelposition" ("none" "topline" "bottomline" "all"))
   77     ("numbers" ("none" "left" "right"))
   78     ("numbersep")
   79     ("firstnumber" ("auto" "last" "integer"))
   80     ("stepnumber")
   81     ("numberblanklines" ("true" "false"))
   82     ("firstline")
   83     ("lastline")
   84     ("showspaces" ("true" "false"))
   85     ("showtabs" ("true" "false"))
   86     ("obeytabs" ("true" "false"))
   87     ("tabsize")
   88     ("baselinestretch" ("auto" "dimension"))
   89     ("commandchars" ("none"))
   90     ("xleftmargin")
   91     ("xrightmargin")
   92     ("resetmargins" ("true" "false"))
   93     ("hfuzz")
   94     ("samepage" ("true" "false"))
   95     ("codes")
   96     ;; Undocumented key
   97     ("codes*")
   98     ("defineactive")
   99     ;; Undocumented key
  100     ("defineactive*")
  101     ;; Undocumented key and introduced in version 2.81 2011/04/06
  102     ("vspace" ,(mapcar (lambda (x)
  103              (concat TeX-esc (car x)))
  104                (LaTeX-length-list)))
  105     ;; Actually, the following options are used only by the `BVerbatim'
  106     ;; environment.
  107     ("boxwidth" ("auto" "dimension"))
  108     ("baseline" ("b" "c" "t"))
  109     ;; The next key applies only to `\SaveVerb' macro.
  110     ("aftersave"))
  111   "Key=value options for fancyvrb macros and environments.")
  112 
  113 (defvar LaTeX-fancyvrb-key-val-options-local nil
  114   "Buffer-local key=value options for fancyvrb macros and environments.
  115 This variable is intended for packages like \"fvextra\" which
  116 provide new key=values for fancyvrb environments.  New key=values
  117 should be appended to this variable.")
  118 (make-variable-buffer-local 'LaTeX-fancyvrb-key-val-options-local)
  119 
  120 (defvar LaTeX-fancyvrb-base-macros
  121   '("VerbatimInput" "BVerbatimInput" "LVerbatimInput"
  122     "SaveVerb" "UseVerb" "Verb")
  123   "List of base macros available with fancyvrb package.
  124 Starred versions are not included in this list.")
  125 
  126 (defvar LaTeX-fancyvrb-base-environments
  127   '("Verbatim" "BVerbatim" "LVerbatim" "SaveVerbatim" "VerbatimOut")
  128   "List of base environments available with fancyvrb package.
  129 Starred versions are not included in this list.")
  130 
  131 (defvar LaTeX-fancyvrb-key-val-skip-regexp
  132   (concat "\\(?:" (LaTeX-extract-key-value-label 'none) "\\)?")
  133   "Helper regexp to skip over an optional argument.")
  134 
  135 ;; Setup for defining new Verbatim commands:
  136 
  137 (TeX-auto-add-type "fancyvrb-macro" "LaTeX")
  138 
  139 (defvar LaTeX-fancyvrb-macro-regexp
  140   `(,(concat "\\\\\\(Rec\\|C\\)ustomVerbatimCommand"
  141          "[ \t\n\r]*{?[ \t\n\r]*\\\\\\([A-Za-z]+\\)[ \t\n\r]*}?"
  142          "[ \t\n\r]*{[ \t\n\r]*\\([A-Za-z]+\\)[ \t\n\r]*}")
  143     (2 3 1) LaTeX-auto-fancyvrb-macro)
  144   "Matches macros by fancyvrb package.")
  145 
  146 ;; Setup for defining new Verbatim environments:
  147 
  148 (TeX-auto-add-type "fancyvrb-environment" "LaTeX")
  149 
  150 (defvar LaTeX-fancyvrb-environment-regexp
  151   `(,(concat "\\\\DefineVerbatimEnvironment"
  152          "[ \t\n\r]*{[ \t\n\r]*\\([A-Za-z0-9]+\\)[ \t\n\r]*}"
  153          "[ \t\n\r]*{[ \t\n\r]*\\([A-Za-z]+\\)[ \t\n\r]*}")
  154     (1 2) LaTeX-auto-fancyvrb-environment)
  155   "Matches new environments defined by fancyvrb package.")
  156 
  157 ;; Setup for names in SaveVerb macros:
  158 
  159 (TeX-auto-add-type "fancyvrb-saveverb" "LaTeX")
  160 
  161 (defvar LaTeX-fancyvrb-saveverb-regexp
  162   `(,(concat "\\\\SaveVerb"
  163          LaTeX-fancyvrb-key-val-skip-regexp
  164          "{\\([^}]+\\)}")
  165     1 LaTeX-auto-fancyvrb-saveverb)
  166   "Match the name under which verbatim text is saved by SaveVerb macro.")
  167 
  168 ;; Setup for names in SaveVerbatim environments:
  169 
  170 (TeX-auto-add-type "fancyvrb-saveverbatim" "LaTeX")
  171 
  172 (defvar LaTeX-fancyvrb-saveverbatim-regexp
  173   `(,(concat "\\\\begin{SaveVerbatim}"
  174          LaTeX-fancyvrb-key-val-skip-regexp
  175          "{\\([^}]+\\)}")
  176     1 LaTeX-auto-fancyvrb-saveverbatim)
  177   "Match the name under which verbatim text is saved by SaveVerbatim environment.")
  178 
  179 (defun LaTeX-fancyvrb-auto-prepare ()
  180   "Clear various LaTeX-auto-fancyvrb-* variables before parsing."
  181   (setq LaTeX-auto-fancyvrb-macro        nil
  182     LaTeX-auto-fancyvrb-environment  nil
  183     LaTeX-auto-fancyvrb-saveverb     nil
  184     LaTeX-auto-fancyvrb-saveverbatim nil))
  185 
  186 (defun LaTeX-fancyvrb-auto-cleanup ()
  187   "Process parsed elements for fancyvrb package."
  188   (LaTeX-fancyvrb-arg-define-macro nil t)
  189   (LaTeX-fancyvrb-arg-define-environment nil t))
  190 
  191 (add-hook 'TeX-auto-prepare-hook #'LaTeX-fancyvrb-auto-prepare t)
  192 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-fancyvrb-auto-cleanup t)
  193 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
  194 
  195 (defun LaTeX-fancyvrb-arg-define-macro (optional &optional cleanup recustom)
  196   "Query and insert a new verbatim macro with fancyvrb package.
  197 If OPTIONAL is non-nil, insert the arguments in brackets.  If
  198 CLEANUP is non-nil, do not insert any arguments in the buffer and
  199 update only various AUCTeX variables for verbatim macros.  If
  200 RECUSTOM is non-nil, delete macros from the variable
  201 `TeX-symbol-list' before adding the new ones."
  202   ;; This part is only relevant when called by user:
  203   (unless cleanup
  204     (let ((new-mac (if recustom
  205                (completing-read
  206             (TeX-argument-prompt optional nil "Verbatim macro: \\" t)
  207             (mapcar #'car (apply #'append LaTeX-fancyvrb-macro-list)))
  208              (TeX-read-string
  209               (TeX-argument-prompt optional nil "New verbatim macro: \\" t))))
  210       (base-mac (completing-read (TeX-argument-prompt optional nil "Based on macro")
  211                      LaTeX-fancyvrb-base-macros))
  212       (rec-flag (if recustom "Rec" "C")))
  213       ;; We are (re-)defining a macro: Insert user queried input and
  214       ;; use `LaTeX-add-fancyvrb-macros' on the input.  Do not enclose
  215       ;; the first argument in braces as this will improve
  216       ;; fontification.  Otherwise, the part between 2 closing braces
  217       ;; get fontified, i.e.:
  218       ;; \CustomVerbatimCommand{\foo}{Verb}{}
  219       ;;                            ^     ^
  220       (let ((TeX-arg-opening-brace "")
  221         (TeX-arg-closing-brace ""))
  222     (TeX-argument-insert new-mac optional TeX-esc))
  223       (TeX-argument-insert base-mac optional)
  224       (TeX-argument-insert
  225        (TeX-read-key-val optional LaTeX-fancyvrb-key-val-options-local) optional)
  226       (LaTeX-add-fancyvrb-macros `(,new-mac ,base-mac ,rec-flag))))
  227   ;;
  228   ;; Now run the procdure: Do not use the function
  229   ;; `LaTeX-fancyvrb-macro-list' here which will remove dupes from the
  230   ;; variable `LaTeX-fancyvrb-macro-list' depending on car; we need
  231   ;; the variable as is, hence (apply #'append ...);
  232   (dolist (elt (apply #'append LaTeX-fancyvrb-macro-list))
  233     (let ((mac-name (nth 0 elt))
  234       (base-mac (nth 1 elt))
  235       (flag     (nth 2 elt)))
  236       ;; If we're Rec-ustomizing, delete the entry first from
  237       ;; `TeX-symbol-list':
  238       (when (string= flag "Rec")
  239     (setq TeX-symbol-list
  240           (assq-delete-all (car (assoc mac-name (TeX-symbol-list))) TeX-symbol-list)))
  241       ;; Now add the new item: Start with new macros for loading
  242       ;; files:
  243       (cond ((member base-mac '("VerbatimInput" "BVerbatimInput" "LVerbatimInput"))
  244          (TeX-add-symbols
  245           `(,mac-name
  246         [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
  247         LaTeX-fancyvrb-arg-file-relative))
  248          (when (and (fboundp 'font-latex-add-keywords)
  249             (eq TeX-install-font-lock 'font-latex-setup))
  250            (font-latex-add-keywords `((,mac-name "[{"))
  251                     'reference)))
  252         ;; New macros for saving verbatim text:
  253         ((string= base-mac "SaveVerb")
  254          (TeX-add-symbols
  255           `(,mac-name
  256         [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
  257         (TeX-arg-eval
  258          (lambda ()
  259            (let ((name (TeX-read-string
  260                 (TeX-argument-prompt optional nil "Save name"))))
  261              (LaTeX-add-fancyvrb-saveverbs name)
  262              (format "%s" name))))
  263         TeX-arg-verb))
  264          (when (and (fboundp 'font-latex-add-keywords)
  265             (eq TeX-install-font-lock 'font-latex-setup))
  266            (font-latex-add-keywords `((,mac-name "[{"))
  267                     'textual)))
  268         ;; New macros for using previously saved text:
  269         ((string= base-mac "UseVerb")
  270          (TeX-add-symbols
  271           `(,mac-name
  272         (TeX-arg-eval
  273          completing-read
  274          (TeX-argument-prompt optional nil "Saved name")
  275          (LaTeX-fancyvrb-saveverb-list))))
  276          (when (and (fboundp 'font-latex-add-keywords)
  277             (eq TeX-install-font-lock 'font-latex-setup))
  278            (font-latex-add-keywords `((,mac-name "{"))
  279                     'textual)))
  280         ;; Anything else is considered as verbatim typesetting macro:
  281         (t
  282          (TeX-add-symbols
  283           `(,mac-name
  284         [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
  285         TeX-arg-verb)
  286           ;; Defined macros have a starred version where the
  287           ;; `showspaces' key is set to true
  288           `(,(concat mac-name "*")
  289         [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]
  290         TeX-arg-verb))
  291          (add-to-list 'LaTeX-verbatim-macros-with-delims-local
  292               mac-name t)
  293          (add-to-list 'LaTeX-verbatim-macros-with-delims-local
  294               (concat mac-name "*") t)
  295          (when (and (fboundp 'font-latex-add-keywords)
  296             (eq TeX-install-font-lock 'font-latex-setup))
  297            (font-latex-add-keywords `((,mac-name "*["))
  298                     'textual))))))
  299   ;; Update font-lock:
  300   (when (and (fboundp 'font-latex-set-syntactic-keywords)
  301          (eq TeX-install-font-lock 'font-latex-setup))
  302     (font-latex-set-syntactic-keywords)))
  303 
  304 (defun LaTeX-fancyvrb-arg-define-environment (optional &optional cleanup)
  305   "Query and insert a new verbatim environment with fancyvrb package.
  306 If OPTIONAL is non-nil, insert the arguments in brackets.  If
  307 CLEANUP is non-nil, do not insert any arguments in the buffer and
  308 update only various AUCTeX variables for verbatim environments."
  309   (unless cleanup
  310     (let ((new-env (TeX-read-string
  311             (TeX-argument-prompt optional nil "New verbatim environment")))
  312       (base-env (completing-read
  313              (TeX-argument-prompt optional nil "Based on environment")
  314              LaTeX-fancyvrb-base-environments)))
  315       ;; We are defining a new env: First insert the arguments and then
  316       ;; run `LaTeX-add-fancyvrb-environments' on '(new-env base-env).
  317       ;; If base-env is SaveVerbatim, run
  318       ;; `LaTeX-add-fancyvrb-saveverbatims' on new-env as well.
  319       (TeX-argument-insert new-env optional)
  320       (TeX-argument-insert base-env optional)
  321       (TeX-argument-insert
  322        (TeX-read-key-val optional LaTeX-fancyvrb-key-val-options-local) optional)
  323       (LaTeX-add-fancyvrb-environments `(,new-env ,base-env))
  324       (when (string= base-env "SaveVerbatim")
  325     (LaTeX-add-fancyvrb-saveverbatims new-env))))
  326   ;;
  327   ;; Now run the procdure:
  328   (dolist (elt (LaTeX-fancyvrb-environment-list))
  329     (let ((env (car elt))
  330       (type (cadr elt)))
  331       (cond ((string= type "VerbatimOut")
  332          (LaTeX-add-environments
  333           `(,env (lambda (env)
  334                (let ((options (TeX-read-key-val
  335                        t LaTeX-fancyvrb-key-val-options-local))
  336                  (file (TeX-read-string "Output file: ")))
  337              (LaTeX-insert-environment
  338               env
  339               (concat
  340                (unless (zerop (length options))
  341                  (concat LaTeX-optop options LaTeX-optcl))
  342                (concat TeX-grop file TeX-grcl))))))))
  343         ((string= type "SaveVerbatim")
  344          (TeX-auto-add-regexp `(,(concat "\\\\begin{"
  345                          env
  346                          "}"
  347                          LaTeX-fancyvrb-key-val-skip-regexp
  348                          "{\\([^}]+\\)}")
  349                     1 LaTeX-auto-fancyvrb-saveverbatim)))
  350         (t
  351          ;; Regular verbatim environments have a starred
  352          ;; version; so add them here; the non-starred additions
  353          ;; to `LaTeX-verbatim-environments-local' and
  354          ;; `LaTeX-indent-environment-list' are done outside
  355          ;; (cond ...):
  356          (LaTeX-add-environments
  357           `(,env LaTeX-env-args
  358              [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]))
  359          (LaTeX-add-environments
  360           `(,(concat env "*") LaTeX-env-args
  361         [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ]))
  362          (add-to-list 'LaTeX-verbatim-environments-local (concat env "*"))
  363          (add-to-list 'LaTeX-indent-environment-list
  364               `(,(concat env "*") current-indentation) t)))
  365       ;; These apply for all environments defined:
  366       (add-to-list 'LaTeX-verbatim-environments-local env)
  367       (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation) t)))
  368   ;; Update font-lock:
  369   (when (and (fboundp 'font-latex-set-syntactic-keywords)
  370          (eq TeX-install-font-lock 'font-latex-setup))
  371     (font-latex-set-syntactic-keywords)))
  372 
  373 (defun LaTeX-fancyvrb-arg-file-relative (optional)
  374   "Query and insert a file name relative to current master file.
  375 If OPTIONAL is non-nil, insert the file name in brackets."
  376   (TeX-argument-insert
  377    (file-relative-name
  378     (read-file-name (TeX-argument-prompt optional nil "File"))
  379     (TeX-master-directory))
  380    optional))
  381 
  382 (TeX-add-style-hook
  383  "fancyvrb"
  384  (lambda ()
  385    (TeX-auto-add-regexp LaTeX-fancyvrb-macro-regexp)
  386    (TeX-auto-add-regexp LaTeX-fancyvrb-environment-regexp)
  387    (TeX-auto-add-regexp LaTeX-fancyvrb-saveverb-regexp)
  388    (TeX-auto-add-regexp LaTeX-fancyvrb-saveverbatim-regexp)
  389    (TeX-run-style-hooks
  390     "keyval")
  391 
  392    ;; Activate the buffer-local version of key-vals.
  393    (setq LaTeX-fancyvrb-key-val-options-local
  394      (copy-alist LaTeX-fancyvrb-key-val-options))
  395 
  396    (TeX-add-symbols
  397     ;; Verbatim material in footnotes
  398     "VerbatimFootnotes"
  399     ;; Improved verbatim commands
  400     '("Verb" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local] TeX-arg-verb)
  401     ;; \Verb also has a starred version:
  402     '("Verb*" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local] TeX-arg-verb)
  403     '("DefineShortVerb" (TeX-arg-eval
  404              TeX-read-string
  405              (TeX-argument-prompt optional nil "Character")
  406              TeX-esc))
  407     '("UndefineShortVerb" (TeX-arg-eval
  408                TeX-read-string
  409                (TeX-argument-prompt optional nil "Character")
  410                TeX-esc))
  411     ;; Verbatim environments
  412     '("fvset" (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
  413     ;; Changing individual line formatting
  414     "FancyVerbFormatLine"
  415     ;; Line numbering
  416     "theFancyVerbLine"
  417     ;; Selection of lines to print
  418     "FancyVerbStartString"
  419     "FancyVerbStopString"
  420 
  421     ;; Personalized environments
  422     '("DefineVerbatimEnvironment"
  423       LaTeX-fancyvrb-arg-define-environment)
  424     '("RecustomVerbatimEnvironment"
  425       (TeX-arg-eval completing-read
  426             (TeX-argument-prompt optional nil "Verbatim environment")
  427             LaTeX-fancyvrb-base-environments)
  428       (TeX-arg-eval completing-read
  429             (TeX-argument-prompt optional nil "Based on environment")
  430             LaTeX-fancyvrb-base-environments)
  431       (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
  432 
  433     '("CustomVerbatimCommand"
  434       LaTeX-fancyvrb-arg-define-macro)
  435     '("RecustomVerbatimCommand"
  436       (LaTeX-fancyvrb-arg-define-macro nil t))
  437 
  438     ;; Saving and restoring verbatim text and environments
  439     '("SaveVerb"
  440       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
  441       (TeX-arg-eval
  442        (lambda ()
  443      (let ((name (TeX-read-string
  444               (TeX-argument-prompt optional nil "Save name"))))
  445        (LaTeX-add-fancyvrb-saveverbs name)
  446        (format "%s" name))))
  447       TeX-arg-verb)
  448     '("UseVerb" (TeX-arg-eval
  449          completing-read
  450          (TeX-argument-prompt optional nil "Saved name")
  451          (LaTeX-fancyvrb-saveverb-list)))
  452     '("UseVerbatim" (TeX-arg-eval completing-read
  453                   (TeX-argument-prompt optional nil "Saved name")
  454                   (LaTeX-fancyvrb-saveverbatim-list)))
  455     '("LUseVerbatim" (TeX-arg-eval completing-read
  456                    (TeX-argument-prompt optional nil "Saved name")
  457                    (LaTeX-fancyvrb-saveverbatim-list)))
  458     '("BUseVerbatim" (TeX-arg-eval completing-read
  459                    (TeX-argument-prompt optional nil "Saved name")
  460                    (LaTeX-fancyvrb-saveverbatim-list)))
  461 
  462     ;; Writing and reading verbatim files
  463     '("VerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
  464       LaTeX-fancyvrb-arg-file-relative)
  465     '("BVerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
  466       LaTeX-fancyvrb-arg-file-relative)
  467     '("LVerbatimInput" [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local]
  468       LaTeX-fancyvrb-arg-file-relative))
  469 
  470    (LaTeX-add-environments
  471     '("Verbatim" LaTeX-env-args
  472       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local])
  473     '("Verbatim*" LaTeX-env-args
  474       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local])
  475     '("BVerbatim" LaTeX-env-args
  476       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local])
  477     '("BVerbatim*" LaTeX-env-args
  478       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local])
  479     '("LVerbatim" LaTeX-env-args
  480       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local])
  481     '("LVerbatim*" LaTeX-env-args
  482       [TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local])
  483     '("SaveVerbatim"
  484       (lambda (env)
  485     (let ((options (TeX-read-key-val t LaTeX-fancyvrb-key-val-options-local))
  486           (name (TeX-read-string "Save name: ")))
  487       (LaTeX-insert-environment
  488        env
  489        (concat
  490         (unless (zerop (length options))
  491           (concat LaTeX-optop options LaTeX-optcl))
  492         (concat TeX-grop name TeX-grcl)))
  493       (LaTeX-add-fancyvrb-saveverbatims name))))
  494     '("VerbatimOut"
  495       (lambda (env)
  496     (let ((options (TeX-read-key-val t LaTeX-fancyvrb-key-val-options-local))
  497           (file (TeX-read-string "Output file: ")))
  498       (LaTeX-insert-environment
  499        env
  500        (concat (unless (zerop (length options))
  501              (concat LaTeX-optop options LaTeX-optcl))
  502            (concat TeX-grop file TeX-grcl)))))))
  503 
  504    (LaTeX-add-counters
  505     "FancyVerbLine")
  506 
  507    ;; Filling
  508    (add-to-list 'LaTeX-verbatim-environments-local "Verbatim")
  509    (add-to-list 'LaTeX-verbatim-environments-local "Verbatim*")
  510    (add-to-list 'LaTeX-verbatim-environments-local "BVerbatim")
  511    (add-to-list 'LaTeX-verbatim-environments-local "BVerbatim*")
  512    (add-to-list 'LaTeX-verbatim-environments-local "LVerbatim")
  513    (add-to-list 'LaTeX-verbatim-environments-local "LVerbatim*")
  514    (add-to-list 'LaTeX-verbatim-environments-local "SaveVerbatim")
  515    (add-to-list 'LaTeX-verbatim-environments-local "VerbatimOut")
  516    (make-local-variable 'LaTeX-indent-environment-list)
  517    (add-to-list 'LaTeX-indent-environment-list '("Verbatim" current-indentation) t)
  518    (add-to-list 'LaTeX-indent-environment-list '("Verbatim*" current-indentation) t)
  519    (add-to-list 'LaTeX-indent-environment-list '("BVerbatim" current-indentation) t)
  520    (add-to-list 'LaTeX-indent-environment-list '("BVerbatim*" current-indentation) t)
  521    (add-to-list 'LaTeX-indent-environment-list '("LVerbatim" current-indentation) t)
  522    (add-to-list 'LaTeX-indent-environment-list '("LVerbatim*" current-indentation) t)
  523    (add-to-list 'LaTeX-indent-environment-list '("SaveVerbatim" current-indentation) t)
  524    (add-to-list 'LaTeX-indent-environment-list '("VerbatimOut" current-indentation) t)
  525    (add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb")
  526    (add-to-list 'LaTeX-verbatim-macros-with-delims-local "Verb*")
  527 
  528    ;; Fontification
  529    (when (and (fboundp 'font-latex-add-keywords)
  530           (eq TeX-install-font-lock 'font-latex-setup))
  531      (font-latex-add-keywords '(("CustomVerbatimCommand"       "|{\\{{")
  532                 ("RecustomVerbatimCommand"     "|{\\{{")
  533                 ("DefineVerbatimEnvironment"   "{{{")
  534                 ("RecustomVerbatimEnvironment" "{{{")
  535                 ("DefineShortVerb"   "{")
  536                 ("UndefineShortVerb" "{")
  537                 ("fvset"             "{"))
  538                   'function)
  539      (font-latex-add-keywords '(("VerbatimInput"  "[{")
  540                 ("BVerbatimInput" "[{")
  541                 ("LVerbatimInput" "[{"))
  542                   'reference)
  543      (font-latex-add-keywords '(("Verb" "*[") ; The second argument is verbatim.
  544                 ("SaveVerb"     "[{")
  545                 ("UseVerb"      "{")
  546                 ("UseVerbatim"  "{")
  547                 ("LUseVerbatim" "{")
  548                 ("BUseVerbatim" "{"))
  549                   'textual)))
  550  LaTeX-dialect)
  551 
  552 (defvar LaTeX-fancyvrb-package-options nil
  553   "Package options for the fancyvrb package.")
  554 
  555 ;;; fancyvrb.el ends here