[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4a3d7a2d: Suppress indentation of verbatim env's in docTeX-mode
From: |
Arash Esbati |
Subject: |
master 4a3d7a2d: Suppress indentation of verbatim env's in docTeX-mode |
Date: |
Sun, 10 Jul 2022 13:37:57 -0400 (EDT) |
branch: master
commit 4a3d7a2dc24df3c0013498baf5ae2df3c23210fb
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Suppress indentation of verbatim env's in docTeX-mode
* latex.el (docTeX-indent-inner-fixed): Add entry for verbatim*?
environments.
(LaTeX-indent-line): Add a check in order to suppress
the calculation of indentation inside verbatim environments in
docTeX-mode.
* tests/latex/doctex-indent-in.dtx:
* tests/latex/doctex-indent-out.dtx: Update test.
---
latex.el | 28 ++++++++++++++++++----------
tests/latex/doctex-indent-in.dtx | 6 ++++++
tests/latex/doctex-indent-out.dtx | 6 ++++++
3 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/latex.el b/latex.el
index e8b81409..eb91e697 100644
--- a/latex.el
+++ b/latex.el
@@ -3910,7 +3910,10 @@ value."
4 t)
(,(concat (regexp-quote TeX-esc)
"\\(begin\\|end\\)[ \t]*{\\(macro\\|environment\\)\\*?}")
- 0 nil))
+ 0 nil)
+ (,(concat (regexp-quote TeX-esc)
+ "\\(begin\\|end\\)[ \t]*{verbatim\\*?}")
+ 0 t))
"List of items which should have a fixed inner indentation.
The items consist of three parts. The first is a regular
expression which should match the respective string. The second
@@ -4042,13 +4045,18 @@ Lines starting with an item is given an extra
indentation of
(concat (match-string 0) (TeX-comment-padding-string))))))
(save-excursion
(cond ((and fill-prefix
- (TeX-in-line-comment)
- (eq major-mode 'doctex-mode))
+ (eq major-mode 'doctex-mode)
+ (TeX-in-line-comment))
;; If point is in a line comment in `doctex-mode' we only
- ;; consider the inner indentation.
- (let ((inner-indent (LaTeX-indent-calculate 'inner)))
- (when (/= (LaTeX-current-indentation 'inner) inner-indent)
- (LaTeX-indent-inner-do inner-indent))))
+ ;; consider the inner indentation. An exception is when
+ ;; we're inside a verbatim environment where we don't
+ ;; want to touch the indentation, notably with a
+ ;; fill-prefix "% ":
+ (unless (member (LaTeX-current-environment)
+ (LaTeX-verbatim-environments))
+ (let ((inner-indent (LaTeX-indent-calculate 'inner)))
+ (when (/= (LaTeX-current-indentation 'inner) inner-indent)
+ (LaTeX-indent-inner-do inner-indent)))))
((and fill-prefix
LaTeX-syntactic-comments)
;; In any other case of a comment we have to consider
@@ -4057,16 +4065,16 @@ Lines starting with an item is given an extra
indentation of
(let ((inner-indent (LaTeX-indent-calculate 'inner))
(outer-indent (LaTeX-indent-calculate 'outer)))
(when (/= (LaTeX-current-indentation 'inner) inner-indent)
- (LaTeX-indent-inner-do inner-indent))
+ (LaTeX-indent-inner-do inner-indent))
(when (/= (LaTeX-current-indentation 'outer) outer-indent)
- (LaTeX-indent-outer-do outer-indent))))
+ (LaTeX-indent-outer-do outer-indent))))
(t
;; The default is to adapt whitespace before any
;; non-whitespace character, i.e. to do outer
;; indentation.
(let ((outer-indent (LaTeX-indent-calculate 'outer)))
(when (/= (LaTeX-current-indentation 'outer) outer-indent)
- (LaTeX-indent-outer-do outer-indent))))))
+ (LaTeX-indent-outer-do outer-indent))))))
(when (< (current-column) (save-excursion
(LaTeX-back-to-indentation) (current-column)))
(LaTeX-back-to-indentation))))
diff --git a/tests/latex/doctex-indent-in.dtx b/tests/latex/doctex-indent-in.dtx
index 4f439588..8d6081ca 100644
--- a/tests/latex/doctex-indent-in.dtx
+++ b/tests/latex/doctex-indent-in.dtx
@@ -33,6 +33,12 @@
% \DescribeEnv{YOURENV}
% Put description of |YOURENV| here.
%
+%\begin{verbatim}
+% Some
+%verbatim
+% content
+%\end{verbatim}
+%
% \StopEventually{\PrintIndex}
%
% \section{Implementation}
diff --git a/tests/latex/doctex-indent-out.dtx
b/tests/latex/doctex-indent-out.dtx
index 2bdcf40c..432d969b 100644
--- a/tests/latex/doctex-indent-out.dtx
+++ b/tests/latex/doctex-indent-out.dtx
@@ -33,6 +33,12 @@
% \DescribeEnv{YOURENV}
% Put description of |YOURENV| here.
%
+%\begin{verbatim}
+% Some
+%verbatim
+% content
+%\end{verbatim}
+%
% \StopEventually{\PrintIndex}
%
% \section{Implementation}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 4a3d7a2d: Suppress indentation of verbatim env's in docTeX-mode,
Arash Esbati <=