auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] [elpa] externals/auctex 69b78fcc26 54/60: Don't change in


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 69b78fcc26 54/60: Don't change indentation when defining a conditional
Date: Fri, 8 Apr 2022 11:52:56 -0400 (EDT)

branch: externals/auctex
commit 69b78fcc2692e81a31ebdeb23aa82b1f5123e213
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Don't change indentation when defining a conditional
    
    * latex.el (LaTeX-indent-level-count): Add an entry for the
    "newif" macro where the following \if<foo> is the definition of
    the conditional which should not increase the indentation.
    Fix docstring.
    
    * tests/latex/conditionals-indent-in.tex:
    * tests/latex/conditionals-indent-out.tex: Adjust tests
    for the change.
---
 latex.el                                | 8 ++++++--
 tests/latex/conditionals-indent-in.tex  | 7 +++++++
 tests/latex/conditionals-indent-out.tex | 7 +++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/latex.el b/latex.el
index f30a6b5f5c..2d16483249 100644
--- a/latex.el
+++ b/latex.el
@@ -4054,8 +4054,10 @@ outer indentation in case of a commented line.  The 
symbols
             (t (LaTeX-indent-calculate-last force-type))))))
 
 (defun LaTeX-indent-level-count ()
-  "Count indentation change caused by all \\left, \\right, \\begin, and
-\\end commands in the current line."
+  "Count indentation change caused by macros in the current line.
+Macros contain \\left, \\right, \\begin, \\end and \\if-\\fi
+constructs.  A special case is \\newif where the following
+\\if<foo> should not change the indentation."
   (save-excursion
     (save-restriction
       (let ((count 0))
@@ -4077,6 +4079,8 @@ outer indentation in case of a commented line.  The 
symbols
             (setq count (+ count LaTeX-indent-level)))
            ((looking-at LaTeX-end-regexp)
             (setq count (- count LaTeX-indent-level)))
+           ((looking-at "newif\\b")
+            (search-forward TeX-esc (line-end-position) t))
            ((and (not (looking-at LaTeX-indent-begin-regexp-exceptions-local))
                  (looking-at LaTeX-indent-begin-regexp-local))
             (setq count (+ count LaTeX-indent-level)))
diff --git a/tests/latex/conditionals-indent-in.tex 
b/tests/latex/conditionals-indent-in.tex
index b832d5e2dd..2d8634e1b5 100644
--- a/tests/latex/conditionals-indent-in.tex
+++ b/tests/latex/conditionals-indent-in.tex
@@ -8,6 +8,13 @@
 
 \begin{document}
 
+\newif\ifluatex
+\ifluatex
+luatex specific code
+\else
+code for other engines
+\fi
+
 \def\IfFileExists#1#2#3{%
 \openin\@inputcheck#1 %
 \ifeof\@inputcheck
diff --git a/tests/latex/conditionals-indent-out.tex 
b/tests/latex/conditionals-indent-out.tex
index 864f718090..b99319ebd6 100644
--- a/tests/latex/conditionals-indent-out.tex
+++ b/tests/latex/conditionals-indent-out.tex
@@ -8,6 +8,13 @@
 
 \begin{document}
 
+\newif\ifluatex
+\ifluatex
+  luatex specific code
+\else
+  code for other engines
+\fi
+
 \def\IfFileExists#1#2#3{%
   \openin\@inputcheck#1 %
   \ifeof\@inputcheck




reply via email to

[Prev in Thread] Current Thread [Next in Thread]