GNU bug report logs - #69346
13.2; newcommand arguments affecting indentation

Previous Next

Package: auctex;

Reported by: Paul Nelson <ultrono <at> gmail.com>

Date: Sat, 24 Feb 2024 08:44:01 UTC

Severity: normal

Tags: notabug

Found in version 13.2

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 69346 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Paul Nelson <ultrono <at> gmail.com>
Cc: 69346 <at> debbugs.gnu.org
Subject: Re: bug#69346: 13.2; newcommand arguments affecting indentation
Date: Sat, 24 Feb 2024 23:40:24 +0100
Paul Nelson <ultrono <at> gmail.com> writes:

> It occurred to me that a better solution would be to constrain the
> "if*" commands matched by the regexp produced by
> LaTeX-indent-commands-regexp-make.  My earlier patch fixed the
> preamble definition, which was all that mattered for the specific tex
> file that I was editing, but it is more natural to simultaneously fix
> any uses of such commands.  I've attached a patch which gives my best
> attempt at doing this (no claim of optimality).

Hi Paul,

the issue with your suggestion is that it is too rigid and doesn't work
for definitions like:

--8<---------------cut here---------------start------------->8---
\newif\iffoo <at> bar
\iffoo <at> bar
  do this
\else
  do that
\fi
--8<---------------cut here---------------end--------------->8---

AUCTeX already tries to provide a solution for your problem, namely, the
variable `LaTeX-indent-begin-exceptions-list'.  You can add your defined
macro on a per file basis with the local variables like this:

--8<---------------cut here---------------start------------->8---
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% eval: (add-to-list 'LaTeX-indent-begin-exceptions-list "ifs")
%%% End:
--8<---------------cut here---------------end--------------->8---

Personally, I would define this one macro like this and avoid the
hassle:

--8<---------------cut here---------------start------------->8---
\expandafter\newcommand\csname ifs\endcsname{%
  \text{if }%
}
--8<---------------cut here---------------end--------------->8---

Or simply rename the macro to `\italicif' or something that doesn't
start if 'if'.

Best, Arash




This bug report was last modified 1 year and 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.