Use this .dir-locals.el
file
((latex-mode . ((TeX-command-extra-options . "-shell-escape")
(tex-start-options . "-shell-escape")
(eval
. (setq-local tex-verbatim-environments
(cons "minted" tex-verbatim-environments))))))
Discussion
Put the above .dir-locals.el file in the same directory as the latex files which use minted.
This causes Ctrlc Ctrlc to use the -shell-escape
option. The first line sets it up for AUCTeX and the second sets it for emacs's builtin latex-mode, when AUCTeX is not installed.
The remainder of the file hints to emacs that the "minted" environment should be styled like a verbatim environment. Normally emacs's latex-mode displays the character after an underscore as a subscript, like_this_for_example.
Why not the .emacs
file?
Using .emacs is convenient, but risky. Enabling -shell-escape
globally is considered dangerous — there's a reason it is not on by default — and it should be used sparingly. Using a .dir-locals.el file instead allows one to choose to enable -shell-escape
only for the documents that actually need it.