On TeX.SE arouse some questions, on how to add the -excape-shell
option to the actual TeX processor (LaTeX, luaLaTeX, ...). One offered solution would be, to use a %%% Local Variables
section at the end of the LaTeX-file.
But Emacs would not be Emacs, if he could not set this feature by his self.
Usually, AUCTeX comes with a lot of predefined supporting Lisp files. Unfortunately, there seems to be no package for the LaTeX package minted
. At least, my AUCTeX did not have one. Meanwhile I found an minted.el
on https://github.com/giordano/auctex/blob/master/style/minted.el. (Why didn't I see that earlier??) Having not found such file, I sat down and hacked a (not so little) lisp file away. The main gimmick is the last block
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape %S%(PDFout)")))
This was copied from the brilliant TeX.SE article https://tex.stackexchange.com/questions/157242/adding-an-option-to-the-pdflatex-call-from-auctex . Other parts where copied and adapted from babel.el
or scrbase.el
. I am of plan, to send this file to the AUCTeX-team, for accepting it to be distributed with AUCTeX. But before I do so, I would ask to help me, to get an even better file.
Actually, I am having a rather dumb solution, to insert minted-options for some commands and environments (not to be mixed up, with the options for the package itself!). Right now, my function will only ask for one and only key word. I was not possible to to code it in such a way, that you can insert more than one keyword or even present some appropriate values for the given key(s).
Here is a snippet from the file minted.el
(defun LaTeX-minted-package-options ()
"Prompt for package options for the minted package."
(TeX-read-key-val
t
'(("chapter")
("section")
("cache" ("true" "false"))
("cachedir")
("finalizecache" ("true" "false"))
("frozencache" ("true" "false"))
("draft" ("true" "false"))
("final" ("true" "false"))
("kpsewhich" ("true" "false"))
("langlinenos" ("true" "false"))
("newfloat" ("true" "false"))
("outputdir"))))
(defvar LaTeX-minted-language-list
'("abap"
"abnf"
"ada" "ada95" "ada2005"
"adl"
"agda" "yaml"
"zephir")
"List of supported languages in package minted. To obtain the actual list, issue 'pygmentize -L lexers' in a shell.")
;; stolen from babel.el.gz
(defun TeX-arg-minted-lang (optional &optional prompt)
"Prompt for a language with completion and insert it as argument."
(TeX-argument-insert
(completing-read "Language: " LaTeX-minted-language-list) nil))
;; also stolen from babel.el.gz
(defun LaTeX-env-minted-lang (env)
"Prompt for a language with completion and insert it as argument of ENV."
(LaTeX-insert-environment
env (format "{%s}" (completing-read "Language: "
LaTeX-minted-language-list))))
(defvar LaTeX-minted-style-list
'("manni"
"igor"
"lovelace"
"xcode"
"vim"
"autumn"
"vs"
"rrt"
"native"
"perldoc"
"borland"
"tango"
"emacs"
"friendly"
"monokai"
"paraiso-dark"
"colorful"
"murphy"
"bw"
"pastie"
"algol_nu"
"paraiso-light"
"trac"
"default"
"algol"
"fruity")
"List of supported styles in package minted. List was obtained from command 'pygmentize -L styles'.")
(defun TeX-arg-minted-style (optional &optional prompt)
"Prompt for a style with completion and insert is as optional argument."
(TeX-argument-insert
(completing-read "Minted color style: " LaTeX-minted-style-list) nil))
(defvar LaTeX-minted-option-list
'("autogobble" ; boolean
"baselinestretch" ; dimension
"breakafter" ; string
"breakaftergroup" ; booelan
"xleftmargin" ; dimension
"xrightmargin") ; dimension
"List of options to be given in minted commands and environments.")
(defun TeX-arg-minted-opts (optional &optional prompt)
"Prompt for an option with completion and insert it as an argument."
(TeX-argument-insert
(completing-read "Minted Option: " LaTeX-minted-option-list) nil))
(TeX-add-style-hook
"minted"
(lambda ()
(TeX-run-style-hooks
"keyval" "kvoptions" "fancyvrb" "float"
"ifthen" "calc" "shellesc" "ifplatform"
"pdftexcmds" "etoolbox" "xstring" "lineno"
"framed" "xcolor" "newfloat")
(TeX-add-symbols
'("mint" [ TeX-arg-minted-opts ] TeX-arg-minted-lang)
'("mintinline" [ TeX-arg-minted-opts ] TeX-arg-minted-lang 1)
'("inputminted" [ TeX-arg-minted-opts ] TeX-arg-minted-lang TeX-arg-file-name)
'("usemintedstyle" [TeX-arg-minted-lang] TeX-arg-minted-style)
'("setminted" [TeX-arg-minted-lang] TeX-arg-minted-opts)
'("setmintedinline" [TeX-arg-minted-lang] TeX-arg-minted-opts)
"listoflistings"
"listingscaption"
"listoflistingscaption"
"listoflistings"
'("newminted" ["new environment name"] TeX-arg-minted-lang TeX-arg-minted-opts)
'("newmint" ["new macro name"] TeX-arg-minted-lang TeX-arg-minted-opts)
'("newmintinline" ["new macro name"] TeX-arg-minted-lang TeX-arg-minted-opts)
'("newmintedfile" ["new macro name"] TeX-arg-minted-lang TeX-arg-minted-opts))
(LaTeX-add-environments
"Verbatim"
'("minted" LaTeX-env-minted-lang)
"listings"
)
(LaTeX-add-counters
"FancyVerbLineBreakLast")
(LaTeX-add-saveboxes
"FV")))
;; This is from
;; https://tex.stackexchange.com/questions/157242/adding-an-option-to-the-pdflatex-call-from-auctex
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -shell-escape %S%(PDFout)")))
My file is somewhat longer, as I excluded some of the never ending list of languages and command options. Despite, this should be a MWE.
Can anybody give me some hints on how to improve the function TeX-arg-minted-opts
?
I am sure, there will be an alist
involved. On the one side of the alist, there need to be all allowed options, on the other side, there must be a function, to insert t
or nil
for a boolean, e. g. 5pt
for a dimension, ...
The left side of the alist is already present in my file. The right side is completely missing.
EDIT: meanwhile I found some minted.el
on github. I will study that. Just for the learning effect: any answers are still appreciated.
How to code this?