GNU bug report logs - #63441
Wrong Indentation with backslash in verb macros with braces

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Thu, 11 May 2023 08:37:02 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63441 in the body.
You can then email your comments to 63441 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#63441; Package auctex. (Thu, 11 May 2023 08:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arash Esbati <arash <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Thu, 11 May 2023 08:37:02 GMT) Full text and rfc822 format available.

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

From: Arash Esbati <arash <at> gnu.org>
To: auctex-bugs <bug-auctex <at> gnu.org>
Subject: Wrong Indentation with backslash in verb macros with braces
Date: Thu, 11 May 2023 10:36:06 +0200
Hi all,

I just installed a change (commit 0cb158fd96) which improves
fontification of arguments of verb macros with braces.  One addition is
also handling of backslash(es) as last character(s) in the argument.
There is a downside, though.  Consider the following file:

--8<---------------cut here---------------start------------->8---
\documentclass{article}
\usepackage{url}
\begin{document}

This is text with \textbf{foo\}
  bar}

\path{foobar\}
next line

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

Now mark the text body and indent with 'M-x indent-region RET' or with
C-M-\ and you get:

--8<---------------cut here---------------start------------->8---
This is text with \textbf{foo\}
  bar}

\path{foobar\}
  next line
--8<---------------cut here---------------end--------------->8---

which is wrong.  This is due to the implementation of
`TeX-brace-count-line' which presumes that ?\\ always escapes the next
char, which is wrong in verb macros.  I can think of a solution like
this:

--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index b862d3c2..4663b217 100644
--- a/tex.el
+++ b/tex.el
@@ -5485,7 +5485,9 @@ additional characters."
                         (setq count (- count TeX-brace-indent-level)))
                        ((eq char ?\\)
                         (when (< (point) limit)
-                          (forward-char)
+                          (unless (and (fboundp 'LaTeX-verbatim-p)
+                                       (LaTeX-verbatim-p))
+                            (forward-char))
                           t))))))
       count)))
--8<---------------cut here---------------end--------------->8---

Any comments oder better approaches?

Best, Arash




Information forwarded to bug-auctex <at> gnu.org:
bug#63441; Package auctex. (Thu, 11 May 2023 13:48:01 GMT) Full text and rfc822 format available.

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

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Arash Esbati <arash <at> gnu.org>
Cc: 63441 <at> debbugs.gnu.org
Subject: Re: bug#63441: Wrong Indentation with backslash in verb macros with
 braces
Date: Thu, 11 May 2023 22:47:01 +0900
Hi Arash,

>>>>> Arash Esbati <arash <at> gnu.org> writes:
> which is wrong.  This is due to the implementation of
> `TeX-brace-count-line' which presumes that ?\\ always escapes the next
> char, which is wrong in verb macros.  I can think of a solution like
> this:
> diff --git a/tex.el b/tex.el
> index b862d3c2..4663b217 100644
> --- a/tex.el
> +++ b/tex.el
> @@ -5485,7 +5485,9 @@ additional characters."
>                          (setq count (- count TeX-brace-indent-level)))
>                         ((eq char ?\\)
>                          (when (< (point) limit)
> -                          (forward-char)
> +                          (unless (and (fboundp 'LaTeX-verbatim-p)
> +                                       (LaTeX-verbatim-p))
> +                            (forward-char))
>                            t))))))
>        count)))
> Any comments oder better approaches?

I don't think `fboundp' test is a right approach because it calls
`LaTeX-verbatim-p' even in non-LaTeX mode buffers after the session
loads latex.el. How about just
(TeX-verbatim-p)
instead of
(and (fboundp 'LaTeX-verbatim-p)
     (LaTeX-verbatim-p))
?

Bye,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine




Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Thu, 11 May 2023 19:43:02 GMT) Full text and rfc822 format available.

Notification sent to Arash Esbati <arash <at> gnu.org>:
bug acknowledged by developer. (Thu, 11 May 2023 19:43:02 GMT) Full text and rfc822 format available.

Message #13 received at 63441-done <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 63441-done <at> debbugs.gnu.org
Subject: Re: bug#63441: Wrong Indentation with backslash in verb macros with
 braces
Date: Thu, 11 May 2023 21:42:22 +0200
Hi Keita,

Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> I don't think `fboundp' test is a right approach because it calls
> `LaTeX-verbatim-p' even in non-LaTeX mode buffers after the session
> loads latex.el. How about just
> (TeX-verbatim-p)
> instead of
> (and (fboundp 'LaTeX-verbatim-p)
>      (LaTeX-verbatim-p))
> ?

Thanks for reminding me, you're right, that's the way to go.  I
installed the change per your suggestion (commit 715a88a5f2).  Closing
this report.

Best, Arash




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 09 Jun 2023 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 314 days ago.

Previous Next


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