# Folding file-specific macros in AUCTeX

What is the best way to have AUCTeX fold some math macros specifically for one file? For example in this very trivial example:

\documentclass{minimal}
\newcommand{\foo}{\lambda}
\begin{document}
$\foo$
\end{document}


I would like to tell AUCTeX that in this document and this document only, the fold commands (C-c C-o C-b and the such) should fold the macro \foo in math mode to the string "λ". I tried adding the following to the file:

% Local Variables:
% eval: (add-to-list 'LaTeX-fold-math-spec-list '("λ" ("foo")))
% End:


But it didn't work. First the change was permanent, ie. not local to this file, and second the code was evaluated after the fold-mode was activated, and therefore I needed to reload the file to see the effect.

-

% eval: (add-to-list 'LaTeX-fold-math-spec-list '("λ" ("foo")))


use

% eval: (add-to-list (make-variable-buffer-local 'LaTeX-fold-math-spec-list) '("λ" ("foo")))
% eval: (TeX-fold-mode 1)


The first line makes LaTeX-fold-math-spec-list buffer local and adds the custom element to the alist, the second one re-activates the folding mode.

-
@nik it's due to the eval, but you already use an eval in your code so I supposed that you alreade made it safe. Customize enable-local-eval. –  giordano Nov 6 '13 at 18:38
Oh yes you're completely right, I removed it in between from my .emacs. Thanks! –  Najib Idrissi Nov 6 '13 at 19:28