[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX] toggle environments with and without *
From: |
Tamas Papp |
Subject: |
[AUCTeX] toggle environments with and without * |
Date: |
Mon, 01 Dec 2014 19:06:30 +0100 |
Hi,
I was trying to come up with a way to quickly switch between environment
pairs with and without an asterisk (eg equation and equation*). My
attempt is below, it works, but I was wondering if I am overcomplicating
this and maybe there is a simpler way.
Also, can someone suggest a way to comment and uncomment lines which
start with \label?
--8<---------------cut here---------------start------------->8---
(defun LaTeX-toggle-* ()
"Toggle between forms of the current environment with or without * at the
end."
(interactive)
(let* ((environment (LaTeX-current-environment)))
(when environment
(let* ((l (length environment))
(*-p (and (cl-plusp l)
(eql (aref environment (1- l)) ?*)))
(bare-environment (if *-p
(subseq environment 0 (1- l))
environment)))
(cl-assert (cl-plusp (length bare-environment)) ()
"Empty environment ~S" bare-environment)
(when (or (not LaTeX-toggle-*-environments)
(cl-find bare-environment font-latex-math-environments
:test #'equal))
(LaTeX-modify-environment (if *-p
bare-environment
(concat bare-environment "*"))))))))
--8<---------------cut here---------------end--------------->8---
Best,
Tamas
- [AUCTeX] toggle environments with and without *,
Tamas Papp <=