4

With auctex I can run TeX-fold-env the environment on which point currently is located.

How can I fold all environments foo (\begin{foo}... \end{foo}) in my buffer at once? And how to unfold all occurences of foo?

1
(defun latex-fold-foo ()
  (interactive)
  (let ((env (read-from-minibuffer "Environment: ")))
    (save-excursion
      (goto-char (point-min))
      (while (search-forward (format "begin{%s}" env) nil t)
        (TeX-fold-env)))))
| improve this answer | |
  • Please some explanation in addition to just code – Andrew Swann Dec 10 '18 at 16:17

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.