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


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.


Instead of

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


% 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.