[Top][All Lists]

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

Re: [AUCTeX] Indentation of \if statements

From: Oleh
Subject: Re: [AUCTeX] Indentation of \if statements
Date: Fri, 19 Dec 2014 09:32:14 +0100

Hi Tassilo,

>> I've added the generalization to anything that starts with "\if".
>> Should be fine unless people use something like:
>>     \newcommand\iffy{...}
>> See the attached patch.
> No, that's too lax.  In one of my documents I actually do have an \iface
> macro which has nothing to with "if".
> What I basically had in mind was having two variables
> `TeX-begin-macro-list' and `TeX-end-macro-list'.  From those begin/end
> regexes could be created using `regexp-opt' and used analogously to
> `LaTeX-begin-regexp'/`LaTeX-end-regexp'.
> This has the benefit that a hypothetical ifplatform.el style simply can
> add \ifwindows and friends to the `TeX-begin-macro-list' and indentation
> should just work.
> By default, `TeX-begin-macro-list' should contain all the standard TeX
> if variations: if, ifx, ifnum, ifodd, ifdim, iftrue, iffalse, ....  Then
> the begin regex would be computed by (concat "\\\\" (regexp-opt
> TeX-begin-macro-list) "\\b").  Note that "\\\\if\\b" also matches
> "address@hidden" solving your original issue.
> Likewise, `TeX-end-macro-list' would contain "else" and "fi".
> Does that make sense?

Sounds good, although a case can be made for "convention over
configuration" (the only thing that stuck with me after that Rails
course). In my second patch (somewhere above in the discussion
branch), the convention is that this adds to indentation:


, while this doesn't:


The convention is that if a command starts with "\if" and has no
arguments, e.g no "{" on the same line, it's an "if" switch and the
indentation should be added. This way we can sidestep any need for
configuration: with your approach, the user has to add a custom
command "\iffoo" she just wrote to `TeX-begin-macro-list' before the
indentation starts working again.

The convention could be tweaked a little, e.g. maybe consider the
closing brace as well or something.
So then, if there are no braces we're all good, but if there are we
could use this:

> That's usually written as
>   \ifBooleanTF{#1}{%
>     true}{%
>     false}
> and then the indentation is correct out of the box because auctex
> indents the contents in braces.


reply via email to

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