# How to add self defined environment to verbatim environments

Using the following code in emacs configuration file makes the listed environment as verbatim.

(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting"))


How can I add following environment to this list.

\lstnewenvironment{code}[2][]{%
\lstset{#1}%
\mdframed[style=lstlisting,title={#2}]%
}{\endmdframed}


I have tried the following but its not working

(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting" "code"))

• Did you evaluate that code or restart Emacs? – giordano Apr 28 '15 at 19:24
• @giordano Yes. I restarted emacs after modifying emacs configuration file but the effect was same as before. – Shahzad Apr 29 '15 at 1:35
• @giordano The intention is to make the code environment as verbatim so that I can use symbols like _ in my code environment. But when I specify the argument to code environment, emacs doesn't recognize this environment as verbatim any more. For e.g. \begin{code}{hi} some_code \end{code} – Shahzad Apr 29 '15 at 8:02
• @giordano Specifically when I specify a command in that argument. For exmple. \begin{code}{\texttt{S\char_h} some_code \end{code} – Shahzad Apr 29 '15 at 9:23

For emacs -Q, @giordano's suggestion of restarting emacs should have worked, though all I had to do was evaluate
(add-to-list 'LaTeX-verbatim-environments "code")

and run M-x LaTeX-mode` again.