Ikumi Keita <ik...@ikumi.que.jp> writes: > It affects only doctex mode, so I think it's OK to incorporate the > patch.
Thanks Keita. I will install the patch below in a day or two if no further comments come in. @Dirk: Thanks for the patch. I see you haven't signed the FSF copyright papers, but the change is small enough so we can install it without it. --8<---------------cut here---------------start------------->8--- diff --git a/doc/auctex.texi b/doc/auctex.texi index 1e06650f..b2deb79e 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 is 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))) --8<---------------cut here---------------end--------------->8--- Best, Arash