[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 0b24e363f8 01/14: Improve indenta
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 0b24e363f8 01/14: Improve indentation after '\end{macrocode}' in docTeX mode |
Date: |
Sat, 16 Apr 2022 04:28:42 -0400 (EDT) |
branch: externals/auctex
commit 0b24e363f829f381415fe7cc34f6386baafa9921
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Improve indentation after '\end{macrocode}' in docTeX mode
* latex.el (LaTeX-indent-calculate-last): Improve indentation
after '\end{macrocode}' if still inside a description environment
like 'macro' or 'environment'.
* tests/latex/doctex-indent-in.dtx:
* tests/latex/doctex-indent-out.dtx: New test files.
* tests/latex/latex-test.el (docTeX-indentation): New test.
---
latex.el | 17 ++++++++--
tests/latex/doctex-indent-in.dtx | 68 +++++++++++++++++++++++++++++++++++++++
tests/latex/doctex-indent-out.dtx | 68 +++++++++++++++++++++++++++++++++++++++
tests/latex/latex-test.el | 21 +++++++++++-
4 files changed, 170 insertions(+), 4 deletions(-)
diff --git a/latex.el b/latex.el
index 4527fbafb7..85c290ec50 100644
--- a/latex.el
+++ b/latex.el
@@ -4156,9 +4156,20 @@ outer indentation in case of a commented line. The
symbols
"end[ \t]*{macrocode\\*?}"))
fill-prefix
(TeX-in-line-comment))
- ;; Reset indentation to zero after a macrocode
- ;; environment.
- 0)
+ ;; Reset indentation to zero after a macrocode environment
+ ;; only when we're not still inside a describing
+ ;; environment like "macro" or "environment" etc. Text
+ ;; inside these environments after '\end{macrocode}' is
+ ;; indented with `LaTeX-indent-level':
+ (let ((outer-env (LaTeX-current-environment 2)))
+ (cond ((member outer-env '("macro" "environment"))
+ LaTeX-indent-level)
+ ((and (fboundp 'LaTeX-doc-NewDocElement-list)
+ (LaTeX-doc-NewDocElement-list)
+ (member outer-env
+ (mapcar #'cadr
(LaTeX-doc-NewDocElement-list))))
+ LaTeX-indent-level)
+ (t 0))))
((looking-at (concat (regexp-quote TeX-esc)
"begin *{"
;; Don't give optional argument here
diff --git a/tests/latex/doctex-indent-in.dtx b/tests/latex/doctex-indent-in.dtx
new file mode 100644
index 0000000000..4f439588a7
--- /dev/null
+++ b/tests/latex/doctex-indent-in.dtx
@@ -0,0 +1,68 @@
+% \iffalse meta-comment
+%
+% This file may be distributed and/or modified under the conditions
+% of the LaTeX Project Public License, either version 1.3 of this
+% license or (at your option) any later version. The latest version
+% of this license is in:
+%
+% http://www.latex-project.org/lppl.txt
+%
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{package}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+\DocInput{package.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{Usage}
+%
+% \DescribeMacro{\YOURMACRO}
+% Put description of |\YOURMACRO| here.
+%
+% \DescribeEnv{YOURENV}
+% Put description of |YOURENV| here.
+%
+% \StopEventually{\PrintIndex}
+%
+% \section{Implementation}
+%
+% \begin{macro}{\YOURMACRO}
+% Put explanation of |\YOURMACRO|'s implementation here.
+% \begin{macrocode}
+ \newcommand{\YOURMACRO}{%
+ code goes here%
+}
+% \end{macrocode}
+% Some more text afterwards.
+% \end{macro}
+%
+%\begin{environment}{YOURENV}
+%Put explanation of |YOURENV|'s implementation here.
+%\begin{macrocode}
+\newenvironment{YOURENV}{%
+code before environment%
+}{%
+code after environment%
+}
+%\end{macrocode}
+%Some more text afterwards.
+%\end{environment}
+%
+% \Finale
+%
+% \endinput
+% Local Variables:
+% mode: doctex
+% TeX-master: t
+% End:
diff --git a/tests/latex/doctex-indent-out.dtx
b/tests/latex/doctex-indent-out.dtx
new file mode 100644
index 0000000000..2bdcf40cbe
--- /dev/null
+++ b/tests/latex/doctex-indent-out.dtx
@@ -0,0 +1,68 @@
+% \iffalse meta-comment
+%
+% This file may be distributed and/or modified under the conditions
+% of the LaTeX Project Public License, either version 1.3 of this
+% license or (at your option) any later version. The latest version
+% of this license is in:
+%
+% http://www.latex-project.org/lppl.txt
+%
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{package}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+\DocInput{package.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \section{Usage}
+%
+% \DescribeMacro{\YOURMACRO}
+% Put description of |\YOURMACRO| here.
+%
+% \DescribeEnv{YOURENV}
+% Put description of |YOURENV| here.
+%
+% \StopEventually{\PrintIndex}
+%
+% \section{Implementation}
+%
+% \begin{macro}{\YOURMACRO}
+% Put explanation of |\YOURMACRO|'s implementation here.
+% \begin{macrocode}
+\newcommand{\YOURMACRO}{%
+ code goes here%
+}
+% \end{macrocode}
+% Some more text afterwards.
+% \end{macro}
+%
+% \begin{environment}{YOURENV}
+% Put explanation of |YOURENV|'s implementation here.
+% \begin{macrocode}
+\newenvironment{YOURENV}{%
+ code before environment%
+}{%
+ code after environment%
+}
+% \end{macrocode}
+% Some more text afterwards.
+% \end{environment}
+%
+% \Finale
+%
+% \endinput
+% Local Variables:
+% mode: doctex
+% TeX-master: t
+% End:
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index d10b98a6e1..d5f267e418 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -54,7 +54,11 @@
'LaTeX-conditionals-indent/in
"conditionals-indent-in.tex"
'LaTeX-conditionals-indent/out
- "conditionals-indent-out.tex")
+ "conditionals-indent-out.tex"
+ 'docTeX/in
+ "doctex-indent-in.dtx"
+ 'docTeX/out
+ "doctex-indent-out.dtx")
;; Test for detecting \& in a table cell added; see
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010
@@ -672,4 +676,19 @@ check the indentation for optional argument of
\\usepackage."
(insert-file-contents LaTeX-conditionals-indent/out)
(buffer-string)))))
+(ert-deftest docTeX-indentation ()
+ "Test if content in docTeX-mode is indented correctly."
+ (should (string=
+ (with-temp-buffer
+ (insert-file-contents docTeX/in)
+ (docTeX-mode)
+ (let ((TeX-parse-self t))
+ (TeX-update-style t)
+ (indent-region (point-min) (point-max))
+ (whitespace-cleanup)
+ (buffer-string)))
+ (with-temp-buffer
+ (insert-file-contents docTeX/out)
+ (buffer-string)))))
+
;;; latex-test.el ends here
- [AUCTeX-diffs] [elpa] externals/auctex updated (2568505587 -> b91f15b3a3), Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex db75369df3 05/14: * latex.el (TeX-read-hook): Support 'include/excluded' hook., Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 86de20d0b2 02/14: Make prettification work reliably, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex aae80c4725 11/14: ; Minor Doc fix, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 12f0b610a1 06/14: * style/ltx-base.el: Update style., Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 5d951fea03 09/14: Fix bibtex dialect, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex df8d6fe772 04/14: Document how to bump the required Emacs version, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 0b24e363f8 01/14: Improve indentation after '\end{macrocode}' in docTeX mode,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex a25652ffe2 10/14: Update style/fbox.el to package version 0.06, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex f8d19d5cbb 07/14: ; * style/ltx-base.el ("ltx-base"): Fix entry for "@addtoreset"., Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 62f8341717 03/14: Lift required GNU Emacs version to 25.1, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 35b71dfe3f 08/14: Add new style/etoolbox.el, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex b91f15b3a3 14/14: Release GNU AUCTeX 13.1.3, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex c534b17704 12/14: Avoid using variadic setq-local, Tassilo Horn, 2022/04/16
- [AUCTeX-diffs] [elpa] externals/auctex 615d6f2052 13/14: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2022/04/16