GNU bug report logs - #36358
Indentation of not matched braces in latex-mode

Previous Next

Package: emacs;

Reported by: Sebastian Urban <mrsebastianurban <at> gmail.com>

Date: Mon, 24 Jun 2019 16:09:02 UTC

Severity: minor

Full log


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

From: Sebastian Urban <mrsebastianurban <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 36358 <at> debbugs.gnu.org
Subject: Re: bug#36358: Indentation of not matched braces in latex-mode
Date: Thu, 27 Jun 2019 10:53:12 +0200
> I don't understand the question.  AFAIK this discussion and the
> patch I installed is independent from what happens to environments.

Sorry, for some reason I thought that `latex-noindent-environments'
was also added in this patch.

>> Idea: Maybe if its at the beginning of the line and there is no text
>> after `}' - indent?
>
> Hmm... I can try something like that.

Perhaps to solve the problem, you only need to write code for `indent'
condition and put something like - otherwise => noindent.  In this
case there would be no need to define `noindent' as text before/after
or surrounded by text - one of this would indicate that brackets are
inside paragraph.  This way we would made two cases: if separated =>
indent, if inside paragraph => noindent.  Or do the opposite define
`noindent' and otherwise - indent.

If this would work, we wouldn't need `latex-noindent-commands'.  But
there are probably quite a few ``styles'' of how people write latex, so
tests will be needed.

> Yes, of course, but I meant that it also does it for all commands.

So... this sounds like `tex-indent-basic'... maybe they limit the
range somehow later in the code.

> I believe this was fixed a few hours later by Basil.
> Do you still see it with the current code?

It's OK after the update.

>> ... about declarations...
>
> Hmm... that looks wrong indeed: will have to investigate, thanks.

The problem is that we have two constructs `\something{...}' and
`{\something...}' and if I understand correctly your patch after
reaching `{' moves back and compare word between `\' and `{' with the
list of `latex-noindent-commands' - if match then don't indent.  In
case of declaration, command is after `{' not before.

So, perhaps, how far it goes backward can be (already is?) limited to
SPC (& perhaps beginning of the line)?  Then if it won't find
backward, it should look forward again to SPC (& perhaps to EOL) and
compare word between `\' and SPC.

Another problem may arise from nested declarations.  As for them,
maybe add _second_ `\' as limit?  But the rest of declarations will be
ignored - or simply mention this nuisance in doc string.  Maybe look
for second `\' compare word, then to the next one `\' and compare,
until it'll find SPC instead of `\'.  Currently they indent by the
value of `tex-indent-basic' no mater how many of them is there.

Funny thing - currently (e26.2), each nested command adds value of
`tex-indent-basic' to the end value of indent, for example
(setq t-i-b 2):

\textbf{\textit{\textsc{hypertext links, including those to hypertext
      links, including those to external documents and URLs
      external}}} documents and URLs.

However, your patch works and adding any of them to commands list will
decrease indent by 2 (in this example), i.e. patch works for nested
commands.




This bug report was last modified 4 years and 344 days ago.

Previous Next


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