auctex-devel
[Top][All Lists]
Advanced

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

a lisp function that replaces macros in LaTeX document


From: Uwe Brauer
Subject: a lisp function that replaces macros in LaTeX document
Date: Wed, 01 Nov 2023 14:44:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hi all


Almost all LaTeX source files I receive from colleagues have dozens or
more definitions of the sort 

\newcommand{\fluidenergy}[1]{\underline{E}_{\partial \Phi;#1}}
\newcommand{\eq}[2]{
\begin{equation}\label{E:#1}
\begin{aligned}
  #2
\end{aligned}
\end{equation}
}
\newcommand{\rrho}{\rho}

etc 

I understand that this might be a little faster for typing (if one
remembers all the definitions 😇), but it causes problems

    1. The Emacs, AuCTeX filling functions will not work properly

    2. The prettify-mode will not work as expected (and I am going to
       add these definitions to the tex--prettify-symbols-alist
       (add-to-list 'tex--prettify-symbols-alist more)) 

So usually I expand (query-replace) the most annoying definitions.

Do you think that could be done somehow in a bit more automated way.

For example
 
\newcommand{\fluidenergy}[1]{\underline{E}_{\partial \Phi;#1}}
^cursor

Run magic, auctex-replace-macro-in-buffer

That magic lisp function would scan the line, 

    1. Observe  what is the definiens (\fluidenergy)

    2. Observe what is the  definiendum, \underline{E}_{\partial
       \Phi;#1}

But then would run query-replace correctly?

Do you think that is possible

Now that I realize it, I think I will also write the auctex-dev list


Kind regards

Uwe Brauer

-- 
I strongly condemn Hamas heinous atrocities on Israel, especially the 
despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the NATO membership of Ukraine.
I support the EU membership of Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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