[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 99334fe6: Improve filling over comments in docTeX-mode
From: |
Arash Esbati |
Subject: |
master 99334fe6: Improve filling over comments in docTeX-mode |
Date: |
Sun, 2 Apr 2023 06:35:37 -0400 (EDT) |
branch: master
commit 99334fe6235f010a6430e9310eb0ed7dd19d32dc
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Improve filling over comments in docTeX-mode
* doc/auctex.texi (Indenting): Document new option.
* latex.el (docTeX-indent-across-comments): New option.
(LaTeX-indent-calculate-last): Use new option in docTeX-mode.
Code contributed by Dirk Ullrich.
Co-authored-by: Dirk Ullrich <dirk.ullrich@posteo.de>
Copyright-paperwork-exempt: yes
---
doc/auctex.texi | 34 ++++++++++++++++++++++++++++++++++
latex.el | 13 ++++++++++---
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 1e06650f..b396e397 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -1806,6 +1806,40 @@ prepared for similar side effects when you do.
Note that commented curly braces @code{@{} and @code{@}} aren't counted
when @AUCTeX{} computes indentation.
+In docTeX-mode, @TeX{} code is enclosed in @samp{macrocode} environment
+like this:
+@example
+% \begin@{macrocode@}
+\def\foo#1@{%
+ $#1$%
+@}
+% \end@{macrocode@}
+@end example
+
+@noindent
+Sometimes, the code is long and one wants to insert comments inside the
+@TeX{} code like this:
+@example
+% \begin@{macrocode@}
+\def\foo#1@{%
+% \end@{macrocode@}
+% Comment the next line of code
+% \begin@{macrocode@}
+ $#1$%
+@}
+% \end@{macrocode@}
+@end example
+
+@noindent
+Usually, the comment inside the code interrupts the indentation. This
+behavior can be controlled by setting the variable
+@code{docTeX-indent-across-comments}.
+
+@defopt docTeX-indent-across-comments
+If non-nil, indentation in docTeX is done across comments. This option is
+disabled by default.
+@end defopt
+
@node Filling
@section Filling
@cindex Filling
diff --git a/latex.el b/latex.el
index 9bf48144..c3b4f8b8 100644
--- a/latex.el
+++ b/latex.el
@@ -84,6 +84,11 @@ the lines are outcommented, like in dtx files."
:group 'LaTeX-environment
:type 'boolean)
+(defcustom docTeX-indent-across-comments nil
+ "If non-nil, indentation in docTeX is done across comments."
+ :group 'LaTeX-indentation
+ :type 'boolean)
+
(defun LaTeX-newline ()
"Start a new line potentially staying within comments.
This depends on `LaTeX-insert-into-comments'."
@@ -4391,7 +4396,9 @@ outer indentation in case of a commented line. The
symbols
(let (line-comment-current-flag
line-comment-last-flag
comment-current-flag
- comment-last-flag)
+ comment-last-flag
+ (indent-across-comments (or docTeX-indent-across-comments
+ (not (eq major-mode 'doctex-mode)))))
(beginning-of-line)
(setq line-comment-current-flag (TeX-in-line-comment)
comment-current-flag (TeX-in-commented-line))
@@ -4403,11 +4410,11 @@ outer indentation in case of a commented line. The
symbols
;; lines. The computation of indentation should in this case
;; rather take the last non-comment line into account.
;; Otherwise there might arise problems with e.g. multi-line
- ;; code comments. This behavior is not enabled in docTeX mode
+ ;; code comments. This behavior can be disabled in docTeX mode
;; where large amounts of line comments may have to be skipped
;; and indentation should not be influenced by unrelated code in
;; other macrocode environments.
- (while (and (not (eq major-mode 'doctex-mode))
+ (while (and indent-across-comments
(not comment-current-flag)
(TeX-in-commented-line)
(not (bobp)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 99334fe6: Improve filling over comments in docTeX-mode,
Arash Esbati <=