Subject: bug#36358: Indentation of not matched braces in latex-mode

From: Stefan Monnier <[email-masked]>
Date: Tue, 25 Jun 2019 10:53:50 -0400

> Hmmm... or I don't understand how "specify commands whose args
> shouldn't be indented" will work in practice, or this may be wrong
> path.  It's not about \emph{} or \footnote{}, it's about every command
> which use '{}' (braces), so in latex... most of them(?).  Therefore if
> you let people add them to the list it'll grow really big - just look
> at font styles: \textrm{}, \textit{}, \textmd{}, \textbf{}, \textup{},
> \textsl{}, \textsf{}, \textsc{}, \texttt{}, \textnormal{} - we could
> probably use "\text*", but there are other commands, for example the
> ones we define as new in preamble.

Most of the ones I define are commands for which I do want the args to
be indented.  I typically use them like this:

    prefix: \TAlign{
      foo \\
      bar
    }

where \TAlign expands to a kind of `tabular` environment.

Similarly, I want

    \section{foo bar baz
      toto titi tata}

rather than

    \section{foo bar baz
    toto titi tata}

> Unless this patch is temporary lifebuoy for those who don't want to
> set 'tex-indent-basic' to 0, then well... carry on. :)

It's not meant as a temporary solution.  More a tentative solution.

Thinking more about it, the main distinction is whether the command is
used "within a paragraph" or not.  But I don't really know how to
precisely characterize this notion of "within a paragraph".

>> Note that the patch is for Emacs's bundled tex-mode, whereas you
>> seem to be using AUCTeX, which uses its own indentation code.
> No, I'm _not_ using AUCTeX, I'm using latex-mode.  I only pointed to
> AUCTeX, because when I was looking for answer to this problem, I found
> solution (helpful internet) in AUCTeX - 'TeX-brace-indent-level'
> variable - and wanted something similar in latex-mode.

Good.

> Also I found code in theirs (AUCTeX) TEX.EL, which may help a bit.
> It may, but since I basically know no Elisp, I may be wrong.
> (defcustom TeX-brace-indent-level 2
[...]
> (defun TeX-brace-count-line ()

It seems to indent by 2 regardless of the command, just like what you
don't want.

        Stefan