auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] toggle environments with and without *


From: Tamas Papp
Subject: Re: [AUCTeX] toggle environments with and without *
Date: Tue, 02 Dec 2014 14:01:30 +0100

In the current version, it toggles between

\begin{equation*}
  a^2 + b^2 = c^2
\end{equation*}

and

\begin{equation}
  a^2 + b^2 = c^2
\end{equation}

In the "deluxe" version I am trying to write, it would toggle between

\begin{equation*}
  % my fancy equation
  % \label{eq:mylabel}
  a^2 + b^2 = c^2
\end{equation*}

and

\begin{equation}
  % my fancy equation
  \label{eq:mylabel}
  a^2 + b^2 = c^2
\end{equation}

too (note the commented out label, and that only the comments before a
\label are toggled).

I don't know enough about Emacs Lisp/AUCTeX internals to write
this. Also, help with making the current implementation more idiomatic
is welcome (currently it looks like an entry for the "you can write CL
in any language" contest).

Best,

Tamas

On Tue, Dec 02 2014, Lars Madsen <address@hidden> wrote:

> what are the requirements for this macro?
>
> (still using 11.87)
>
>
> /Lars Madsen
> Institut for Matematik / Department of Mathematics
> Aarhus Universitet / Aarhus University
> Mere info: http://au.dk/address@hidden / More information: 
> http://au.dk/en/address@hidden
>
>
> ________________________________________
> From: address@hidden address@hidden on behalf of Tamas Papp address@hidden
> Sent: 01 December 2014 19:06
> To: auctex
> Subject: [AUCTeX] toggle environments with and without *
>
> 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 mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/auctex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]