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.
Full log
View this message in rfc822 format
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
This bug report was last modified 1 year and 246 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.