"Fossies" - the Fresh Open Source Software Archive

Member "auctex-12.3/style/fvextra.el" (18 Oct 2020, 6499 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 "fvextra.el": 12.2_vs_12.3.

    1 ;;; fvextra.el --- AUCTeX style for `fvextra.sty' (v1.4)
    2 
    3 ;; Copyright (C) 2017, 2019 Free Software Foundation, Inc.
    4 
    5 ;; Author: Arash Esbati <arash@gnu.org>
    6 ;; Maintainer: auctex-devel@gnu.org
    7 ;; Created: 2017-03-05
    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 `fvextra.sty' (v1.4) from 2019/02/04.
   30 ;; `fvextra.sty' is part of TeXLive.
   31 
   32 ;;; Code:
   33 
   34 ;; Needed for compiling `cl-pushnew':
   35 (eval-when-compile
   36   (require 'cl-lib))
   37 
   38 ;; Silence the compiler:
   39 (declare-function font-latex-add-keywords
   40           "font-latex"
   41           (keywords class))
   42 
   43 (declare-function LaTeX-color-definecolor-list "color" ())
   44 (declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
   45 
   46 ;; Defined in fancyvrb.el:
   47 (defvar LaTeX-fancyvrb-key-val-options-local)
   48 
   49 (defvar LaTeX-fvextra-key-val-options
   50   '(;; 3 General options
   51     ("beameroverlays" ("true" "false"))
   52     ("curlyquotes" ("true" "false"))
   53     ("extra" ("true" "false"))
   54     ("fontencoding" (;; Reset to default document font encoding
   55              "none"
   56              ;; 128+ glyph encodings (text)
   57              "OT1" "OT2" "OT3" "OT4" "OT6"
   58              ;; 256 glyph encodings (text)
   59              "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
   60              ;; 256 glyph encodings (text extended)
   61              "X2"
   62              ;; Other encodings
   63              "LY1" "LV1" "LGR"))
   64     ("highlightcolor")
   65     ("highlightlines")
   66     ("linenos" ("true" "false"))
   67     ("mathescape" ("true" "false"))
   68     ("numberfirstline" ("true" "false"))
   69     ;; ("numbers" ("none" "left" "right" "both"))
   70     ("retokenize" ("true" "false"))
   71     ("space" ("\\textvisiblespace"))
   72     ("spacecolor" ("none"))
   73     ("stepnumberfromfirst" ("true" "false"))
   74     ("stepnumberoffsetvalues" ("true" "false"))
   75     ("tab" ("\\FancyVerbTab"))
   76     ("tabcolor" ("none"))
   77     ;; 7.1 Line breaking options
   78     ("breakafter" ("none"))
   79     ("breakaftergroup" ("true" "false"))
   80     ("breakaftersymbolpre")
   81     ("breakaftersymbolpost")
   82     ("breakanywhere" ("true" "false"))
   83     ("breakanywheresymbolpre")
   84     ("breakanywheresymbolpost")
   85     ("breakautoindent" ("true" "false"))
   86     ("breakbefore")
   87     ("breakbeforegroup" ("true" "false"))
   88     ("breakbeforesymbolpre")
   89     ("breakbeforesymbolpost")
   90     ("breakindent")
   91     ("breakindentnchars")
   92     ("breaklines" ("true" "false"))
   93     ("breaksymbol")
   94     ("breaksymbolleft")
   95     ("breaksymbolright")
   96     ("breaksymbolindent")
   97     ("breaksymbolindentnchars")
   98     ("breaksymbolindentleft")
   99     ("breaksymbolindentleftnchars")
  100     ("breaksymbolindentright")
  101     ("breaksymbolindentrightnchars")
  102     ("breaksymbolsep")
  103     ("breaksymbolsepnchars")
  104     ("breaksymbolsepleft")
  105     ("breaksymbolsepleftnchars")
  106     ("breaksymbolsepright")
  107     ("breaksymbolseprightnchars"))
  108   "Key=value options for fvextra macros and environments.")
  109 
  110 (defun LaTeX-fvextra-update-key-val ()
  111   "Update `LaTeX-fancyvrb-key-val-options-local' with key=vals from \"fvextra.sty\"."
  112   ;; Delete the key "numbers" from `LaTeX-fancyvrb-key-val-options-local':
  113   (setq LaTeX-fancyvrb-key-val-options-local
  114     (assq-delete-all (car (assoc "numbers" LaTeX-fancyvrb-key-val-options-local))
  115              LaTeX-fancyvrb-key-val-options-local))
  116   ;; Add the key with "both" value:
  117   (add-to-list 'LaTeX-fancyvrb-key-val-options-local
  118            '("numbers" ("none" "left" "right" "both")))
  119   ;; Add color values to resp. keys:
  120   (when (or (member "xcolor" (TeX-style-list))
  121         (member "color" (TeX-style-list)))
  122     (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
  123              #'LaTeX-xcolor-definecolor-list
  124                #'LaTeX-color-definecolor-list))
  125        (keys '("highlightcolor"
  126            "rulecolor"
  127            "fillcolor"
  128            "tabcolor"
  129            "spacecolor"))
  130        (tmp (copy-alist LaTeX-fancyvrb-key-val-options-local)))
  131       (dolist (x keys)
  132     (setq tmp (assq-delete-all (car (assoc x tmp)) tmp))
  133     (if (string= x "highlightcolor")
  134         (cl-pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test #'equal)
  135       (cl-pushnew (list x (append '("none") (mapcar #'car (funcall colorcmd)))) tmp :test #'equal)))
  136       (setq LaTeX-fancyvrb-key-val-options-local
  137         (copy-alist tmp)))))
  138 
  139 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-fvextra-update-key-val t)
  140 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
  141 
  142 (TeX-add-style-hook
  143  "fvextra"
  144  (lambda ()
  145 
  146    ;; Run the style hook for "fancyvrb"
  147    (TeX-run-style-hooks "fancyvrb")
  148 
  149    ;; Append `LaTeX-fvextra-key-val' to `LaTeX-fancyvrb-key-val-options-local':
  150    (setq LaTeX-fancyvrb-key-val-options-local
  151      (append LaTeX-fvextra-key-val-options
  152          LaTeX-fancyvrb-key-val-options-local))
  153 
  154    (TeX-add-symbols
  155     ;; 4.1 Inline formatting with \fvinlineset
  156     '("fvinlineset" (TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local))
  157 
  158     ;; 4.2 Line and text formatting
  159     "FancyVerbFormatText"
  160 
  161     ;; 6 New commands and environments
  162     ;; 6.1 \EscVerb
  163     '("EscVerb"
  164       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] "Text")
  165     '("EscVerb*"
  166       [ TeX-arg-key-val LaTeX-fancyvrb-key-val-options-local ] "Text")
  167 
  168     ;; 7.3.2 Breaks within macro arguments
  169     "FancyVerbBreakStart"
  170     "FancyVerbBreakStop"
  171 
  172     ;; 7.3.3 Customizing break behavior
  173     "FancyVerbBreakAnywhereBreak"
  174     "FancyVerbBreakBeforeBreak"
  175     "FancyVerbBreakAfterBreak")
  176 
  177    ;; Add \EscVerb*? to `LaTeX-verbatim-macros-with-braces-local':
  178    (add-to-list 'LaTeX-verbatim-macros-with-braces-local
  179         "EscVerb" t)
  180    (add-to-list 'LaTeX-verbatim-macros-with-braces-local
  181         "EscVerb*" t)
  182 
  183    ;; Fontification
  184    (when (and (fboundp 'font-latex-add-keywords)
  185           (eq TeX-install-font-lock 'font-latex-setup))
  186      (font-latex-add-keywords '(("fvinlineset" "{"))
  187                   'function)
  188      (font-latex-add-keywords '(("EscVerb"     "*["))
  189                   'textual)))
  190  LaTeX-dialect)
  191 
  192 (defvar LaTeX-fvextra-package-options nil
  193   "Package options for the fvextra package.")
  194 
  195 ;;; fvextra.el ends here