GNU bug report logs -
#65824
Indent after open delimiters in verb constructs
Previous Next
Reported by: Arash Esbati <arash <at> gnu.org>
Date: Fri, 8 Sep 2023 15:46: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 65824 in the body.
You can then email your comments to 65824 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-auctex <at> gnu.org
:
bug#65824
; Package
auctex
.
(Fri, 08 Sep 2023 15:46: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
.
(Fri, 08 Sep 2023 15:46:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi all,
please consider this small file:
--8<---------------cut here---------------start------------->8---
\documentclass{article}
\begin{document}
\verb|foo{bar|
foo
bar
baz
\end{document}
--8<---------------cut here---------------end--------------->8---
Now do 'M-x mark-whole-buffer RET M-x indent-region RET' and you get:
--8<---------------cut here---------------start------------->8---
\documentclass{article}
\begin{document}
\verb|foo{bar|
foo
bar
baz
\end{document}
--8<---------------cut here---------------end--------------->8---
I think the issue is within `TeX-brace-count-line' which doesn't look
for opening/closing delimiters in verbatim text. My simple minded
solution looks like this:
--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index a85b8ef9..30118384 100644
--- a/tex.el
+++ b/tex.el
@@ -5485,21 +5485,22 @@ additional characters."
'(?\{ ?\} ?\\))
(TeX-in-comment))))
(forward-char)
- (cond ((memq char (append
- TeX-indent-open-delimiters
- '(?\{)))
- (setq count (+ count TeX-brace-indent-level)))
- ((memq char (append
- TeX-indent-close-delimiters
- '(?\})))
- (setq count (- count TeX-brace-indent-level)))
- ((eq char ?\\)
- (when (< (point) limit)
- ;; ?\\ in verbatim constructs doesn't escape
- ;; the next char
- (unless (TeX-verbatim-p)
- (forward-char))
- t))))))
+ ;; If inside a verbatim construct, just return t and
+ ;; proceed, otherwise start counting:
+ (if (TeX-verbatim-p)
+ t
+ (cond ((memq char (append
+ TeX-indent-open-delimiters
+ '(?\{)))
+ (setq count (+ count TeX-brace-indent-level)))
+ ((memq char (append
+ TeX-indent-close-delimiters
+ '(?\})))
+ (setq count (- count TeX-brace-indent-level)))
+ ((eq char ?\\)
+ (when (< (point) limit)
+ (forward-char)
+ t)))))))
count)))
;;; Navigation
--8<---------------cut here---------------end--------------->8---
Any better ideas how to do this? My only concern is that
`LaTeX-verbatim-p' (which is used by `TeX-verbatim-p') uses
`save-match-data' which is known to be expensive. I don't have any
benchmarks, but there might be performance hit when indenting/filling
large portions of text.
Best, Arash
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#65824
; Package
auctex
.
(Mon, 11 Sep 2023 16:39:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 65824 <at> debbugs.gnu.org (full text, mbox):
Hi Arash,
>>>>> Arash Esbati <arash <at> gnu.org> writes:
> Any better ideas how to do this?
That seems a sensible solution to me.
> My only concern is that `LaTeX-verbatim-p' (which is used by
> `TeX-verbatim-p') uses `save-match-data' which is known to be
> expensive. I don't have any benchmarks, but there might be performance
> hit when indenting/filling large portions of text.
Hmm, it really matters, I think there are two actions that we can take:
1. Remove `save-match-data' from `LaTeX-verbatim-p' and announce the
removal in changes.texi. Grepping over the current source briefly,
the only usage of (La)TeX-verbatim-p that needs to preserve the match
data is `LaTeX-search-forward-comment-start'. So wrapping it with
`save-match-data' in that function is easy. (In addition,
`LaTeX-search-forward-comment-start' is only used as a value of
`TeX-search-forward-comment-start-function', which is only used in
`TeX-search-forward-comment-start', which isn't used at all now.)
2. Implement LaTeX mode function for `indent-region'. Now AUCTeX has
"line-by-line" indent function only, but there are apparent overheads
when AUCTeX indents a region. We could implement region-oriented
indent function which works with less overheads.
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
Reply sent
to
Arash Esbati <arash <at> gnu.org>
:
You have taken responsibility.
(Fri, 15 Sep 2023 08:19:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Arash Esbati <arash <at> gnu.org>
:
bug acknowledged by developer.
(Fri, 15 Sep 2023 08:19:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 65824-done <at> debbugs.gnu.org (full text, mbox):
Hi Keita,
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:
> Hmm, it really matters, I think there are two actions that we can take:
> 1. Remove `save-match-data' from `LaTeX-verbatim-p' and announce the
> removal in changes.texi. Grepping over the current source briefly,
> the only usage of (La)TeX-verbatim-p that needs to preserve the match
> data is `LaTeX-search-forward-comment-start'. So wrapping it with
> `save-match-data' in that function is easy. (In addition,
> `LaTeX-search-forward-comment-start' is only used as a value of
> `TeX-search-forward-comment-start-function', which is only used in
> `TeX-search-forward-comment-start', which isn't used at all now.)
> 2. Implement LaTeX mode function for `indent-region'. Now AUCTeX has
> "line-by-line" indent function only, but there are apparent overheads
> when AUCTeX indents a region. We could implement region-oriented
> indent function which works with less overheads.
Thanks for your response. I pushed that change (a228137f66). I'd say
let's wait and see if users complain about any performance regressions,
we can then implement one of your suggestions above.
For now, I'm 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, 13 Oct 2023 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 210 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.