[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 906ac31 55/67: Add new style/pyth
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 906ac31 55/67: Add new style/pythontex.el |
Date: |
Fri, 8 Feb 2019 11:40:39 -0500 (EST) |
branch: externals/auctex
commit 906ac31426a84d79d1cfb6ad12fd06bd755935aa
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Add new style/pythontex.el
* Makefile.in (STYLESRC): Add new style.
* style/pythontex.el: New file.
---
Makefile.in | 2 +-
style/pythontex.el | 570 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 571 insertions(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index a5bf496..3c07c16 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -165,7 +165,7 @@ STYLESRC = style/prosper.el \
style/arabxetex.el style/australian.el style/newzealand.el \
style/xltabular.el style/marginnote.el style/thmtools.el \
style/ocg-p.el style/ocgx.el style/thm-restate.el \
- style/dashundergaps.el
+ style/pythontex.el style/dashundergaps.el
STYLEELC = $(STYLESRC:.el=.elc)
diff --git a/style/pythontex.el b/style/pythontex.el
new file mode 100644
index 0000000..6aecb93
--- /dev/null
+++ b/style/pythontex.el
@@ -0,0 +1,570 @@
+;;; pythontex.el --- AUCTeX style for `pythontex.sty' (v0.16)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-12-01
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING. If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `pythontex.sty' v0.16 from
+;; 2017/07/20. `pythontex.sty' is part of TeXLive.
+
+;;; Code:
+
+;; Silence the compiler:
+;; `LaTeX-fancyvrb-key-val-options-local' will be defined after
+;; loading `fvextra.el' which loads `fancyvrb.el' in return:
+(defvar LaTeX-fancyvrb-key-val-options-local)
+
+;; These are provided by `font-latex.el':
+(defvar font-latex-syntactic-keywords-extra)
+(declare-function font-latex-add-keywords
+ "font-latex"
+ (keywords class))
+(declare-function font-latex-update-font-lock
+ "font-latex"
+ (&optional syntactic-kws))
+
+;; The next two are provided by `newfloat.el':
+(declare-function LaTeX-add-newfloat-DeclareFloatingEnvironments
+ "newfloat"
+ (&rest newfloat-declarefloatingenvironments))
+(declare-function LaTeX-newfloat-auto-cleanup
+ "newfloat" ())
+
+;; Needed for auto-parsing:
+(require 'tex)
+
+(defvar LaTeX-pythontex-pygmentize-program (executable-find "pygmentize")
+ "Path to pygmentize executable.")
+
+(defvar LaTeX-pythontex-language-list nil
+ "List containing languages provided by pymentize program.")
+
+(defun LaTeX-pythontex-language-list (&rest _ignored)
+ "Return a list of languages provided by pymentize program.
+Update the variable `LaTeX-pythontex-language-list' if still nil."
+ (or LaTeX-pythontex-language-list
+ (when LaTeX-pythontex-pygmentize-program
+ (with-temp-buffer
+ (shell-command (concat LaTeX-pythontex-pygmentize-program " -L
lexers")
+ (current-buffer))
+ (goto-char (point-min))
+ (let (languages)
+ (while (re-search-forward "^\*[[:space:]]\([^:]+\):" nil t)
+ (dolist (lang (split-string (match-string 1) "[[:space:],]" t))
+ (push lang languages)))
+ (setq LaTeX-pythontex-language-list languages))))))
+
+(defvar LaTeX-pythontex-package-options-list
+ `(("usefamily" ("py" "sympy" "pylab" "rb" "ruby" "jl" "julia"
"octave"))
+ ("gobble" ("none" "auto"))
+ ("beta" ("true" "false"))
+ ("runall" ("true" "false"))
+ ("rerun" ("never" "modified" "errors" "warnings" "always"))
+ ("hashdependencies" ("true" "false"))
+ ("autoprint" ("true" "false"))
+ ("autostdout" ("true" "false"))
+ ("debug")
+ ("makestderr" ("true" "false"))
+ ("stderrfilename" ("full" "session" "genericfile" "genericscript"))
+ ("pyfuture" ("none" "all" "default"))
+ ("pyconfuture" ("none" "all" "default"))
+ ("upquote" ("true" "false"))
+ ("fixlr" ("true" "false"))
+ ("keeptemps" ("all" "code" "none"))
+ ("prettyprinter" ("pygments" "fancyvrb"))
+ ("prettyprintinline" ("true" "false"))
+ ("pygments" ("true" "false"))
+ ("pyginline" ("true" "false"))
+ ("pyglexer" ,(LaTeX-pythontex-language-list))
+ ("pygopt" ("style" "texcomments" "mathescape"))
+ ("fvextfile")
+ ("pyconbanner" ("none" "standard" "default" "pyversion"))
+ ("pyconfilename" ("stdin" "console"))
+ ("depythontex" ("true" "false")))
+ "Package options for the pythontex package.")
+
+(defun LaTeX-pythontex-package-options ()
+ "Prompt for package options for the pythontex package."
+ (TeX-read-key-val t LaTeX-pythontex-package-options-list))
+
+(defvar LaTeX-pythontex-family-list
+ '("py" "sympy" "pylab" "rb" "ruby" "jl" "julia" "octave")
+ "List of language families provided by pythontex package.")
+
+(defun LaTeX-env-pythontex (environment)
+ "Insert ENVIRONMENT provided by pythontex package."
+ (let ((session (TeX-read-string
+ (TeX-argument-prompt t nil "Session")))
+ (fvkeyval (TeX-read-key-val t LaTeX-fancyvrb-key-val-options-local)))
+ (LaTeX-insert-environment environment
+ (concat
+ (when (and session (not (string= session "")))
+ (concat LaTeX-optop session LaTeX-optcl))
+ ;; We need an extra pair of brackets
+ ;; when no session is given but
+ ;; key=vals are available
+ (when (and session (string= session "")
+ fvkeyval (not (string= fvkeyval "")))
+ (concat LaTeX-optop LaTeX-optcl))
+ (when (and fvkeyval (not (string= fvkeyval "")))
+ (concat LaTeX-optop fvkeyval LaTeX-optcl))))))
+
+;; Setup for \saveprintpythontex & \savestdoutpythontex &
+;; \savestderrpythontex
+(TeX-auto-add-type "pythontex-savecontent" "LaTeX")
+
+(defvar LaTeX-pythontex-savecontent-regexp
+ `(,(concat "\\"
+ (regexp-opt '("saveprintpythontex"
+ "savestdoutpythontex"
+ "savestderrpythontex")
+ "\(?:")
+ "{\([^}]+\)}")
+ 1 LaTeX-auto-pythontex-savecontent)
+ "Matches the argument of \save(print|stdout|stderr)pythontex macros.")
+
+;; Setup for \setpythontexlistingenv:
+(TeX-auto-add-type "pythontex-setpythontexlistingenv" "LaTeX")
+
+(defvar LaTeX-pythontex-setpythontexlistingenv-regexp
+ '("\\setpythontexlistingenv{\([^}]+\)}"
+ 1 LaTeX-auto-pythontex-setpythontexlistingenv)
+ "Matches the argument of \setpythontexlistingenv macro.")
+
+(defun LaTeX-pythontex-auto-prepare ()
+ "Clear various `LaTeX-auto-pythontex-*' before parsing."
+ (setq LaTeX-auto-pythontex-savecontent nil
+ LaTeX-auto-pythontex-setpythontexlistingenv nil))
+
+(defun LaTeX-pythontex-auto-cleanup ()
+ "Process the parsing results for \setpythontexlistingenv macro."
+ ;; Use `LaTeX-add-newfloat-DeclareFloatingEnvironments' on parsed
+ ;; elements and then run `LaTeX-newfloat-auto-cleanup'.
+ (dolist (env (mapcar #'car (LaTeX-pythontex-setpythontexlistingenv-list)))
+ (LaTeX-add-newfloat-DeclareFloatingEnvironments `(,env "verbatim")))
+ (LaTeX-newfloat-auto-cleanup))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-pythontex-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-pythontex-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun LaTeX-pythontex-add-syntactic-keywords-extra (type macro)
+ "Add MACRO from pythontex.sty to `font-latex-syntactic-keywords-extra'
- [AUCTeX-diffs] [elpa] externals/auctex f319b9f 60/67: Override some bindings in `TeX-mode-map' in Texinfo mode, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex f319b9f 60/67: Override some bindings in `TeX-mode-map' in Texinfo mode, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex ca16d88 59/67: Update style/enumitem.el to package version 3.6, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 9d8369a 39/67: ; Silence the compiler in styles for `font-latex-update-font-lock', Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 5147a27 48/67: Revise description about CJK support, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 40ba5b6 37/67: Improve handling of `TeX-insert-macro-default-style' in styles, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 761ffc3 27/67: Remove compatibility code for older emacsen, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex b13bebb 28/67: Remove compatibility code for older emacsen, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 235f93c 46/67: ; Silence the compiler in styles for pstricks, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 3aef308 58/67: Skip macros and environments from pythontex, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 3b5cea2 56/67: Improve completion for \url between url.el and hyperref.el, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 906ac31 55/67: Add new style/pythontex.el,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex 33329c3 57/67: ; * doc/auctex.texi (Completion): Fix typo., Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 6e8aa67 41/67: ; Silence the compiler in styles for `font-latex-add-quotes', Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 4fed4a7 64/67: Remove combatibility code for older emasen, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex a4576a1 49/67: ; * tex.el (TeX-math-toggle-off-input-method): Fix doc string., Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex c893152 50/67: Redefine support for \url in hyperref, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 5827aeb 34/67: Remove TeX-mark-active, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 2c73857 51/67: ; * style/pst-plot.el (LaTeX-pstplot-cleanup): Fix typo., Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 45ad237 35/67: Remove TeX-maybe-remove-help,, Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex 3d0c445 38/67: ; Silence the compiler in styles for `font-latex-add-keywords'., Tassilo Horn, 2019/02/08
- [AUCTeX-diffs] [elpa] externals/auctex f34ce5a 67/67: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2019/02/08