auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 464fd346b9834ed1481c3


From: Ikumi Keita
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 464fd346b9834ed1481c3c2ffa81963714fc530f
Date: Sun, 26 Sep 2021 05:04:24 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  464fd346b9834ed1481c3c2ffa81963714fc530f (commit)
       via  4e156561ba1fbb5275661fd1fd6c7e48d0fb2ec4 (commit)
       via  b379da77ad5caee4e45d4ed6b43398c11437baa8 (commit)
      from  3684fdeb688347e1656cd922d2a658bff704016f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 464fd346b9834ed1481c3c2ffa81963714fc530f
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Fri Sep 24 02:56:15 2021 +0900

    * tests/latex/latex-test.el (LaTeX-flush-left-indent): New test.

diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index af6e34f..b6135b2 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -75,6 +75,58 @@
              (insert-file-contents LaTeX-math-indent/out)
              (buffer-string)))))
 
+;; Test for flush-left type indentation.  The begin/end line of
+;; verbatim-like environments and comment-like environments (provided
+;; by comment.sty) must be flush left.
+;; We also test the indent inside these environments and after them.
+(ert-deftest LaTeX-flush-left-indent ()
+  (with-temp-buffer
+    (LaTeX-mode)
+    (let ((LaTeX-verbatim-environments
+           '("verbatim" "verbatim*" "filecontents" "filecontents*"))
+          (LaTeX-comment-env-list '("comment")))
+
+      ;; Test 1: verbatim environment
+      (insert "\
+\\begin{itemize}
+\\item abc")
+      (LaTeX-insert-environment "verbatim")
+      ;; Check indent inside verbatim env.
+      (should (= (current-column) 0))
+      ;; Check indent of verbatim env itself.
+      (should (string= "\
+\\begin{itemize}
+\\item abc
+\\begin{verbatim}
+
+\\end{verbatim}"
+                       (buffer-string)))
+      ;; Check indent after verbatim env.
+      (goto-char (point-max))
+      (newline-and-indent)
+      (should (= (current-column) 2))
+
+      ;; Test 2: comment environment
+      (erase-buffer)
+      (insert "\
+\\begin{itemize}
+\\item abc")
+      (LaTeX-insert-environment "comment")
+      ;; Check indent inside comment env.
+      (should (= (current-column) 2))
+      ;; Check indent of comment env itself.
+      (should (string= "\
+\\begin{itemize}
+\\item abc
+\\begin{comment}
+\s\s
+\\end{comment}"
+                       (buffer-string)))
+      ;; Check indent after comment env.
+      (goto-char (point-max))
+      (newline-and-indent)
+      (should (= (current-column) 2)))))
+
 ;; Test LaTeX code with math modes is indented as expected.  This has mostly to
 ;; do with the value of `LaTeX-fill-break-at-separators' and how
 ;; `LaTeX-fill-move-to-break-point' handles it.  If the test fails, try to look

commit 4e156561ba1fbb5275661fd1fd6c7e48d0fb2ec4
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Thu Sep 23 05:22:39 2021 +0900

    Cleanup indentation of verbatim environments
    
    * latex.el (LaTeX-begin-regexp): Delete because this variable isn't
    used anywhere.
    (LaTeX-indent-calculate-last): Remove redundant regexp grouping.

diff --git a/latex.el b/latex.el
index d833b0f..9630556 100644
--- a/latex.el
+++ b/latex.el
@@ -3564,13 +3564,6 @@ functions, see `LaTeX-fill-region-as-paragraph'."
   :group 'LaTeX-indentation
   :type 'regexp)
 
-(defcustom LaTeX-verbatim-regexp "verbatim\\*?"
-  "Regexp matching environments with indentation at col 0 for begin/end."
-  :group 'LaTeX-indentation
-  :type 'regexp)
-(make-obsolete-variable 'LaTeX-verbatim-regexp 
'LaTeX-verbatim-environments-local
-                        "2014-12-19")
-
 (defcustom LaTeX-begin-regexp "begin\\b\\|\\["
   "Regexp matching macros considered begins."
   :group 'LaTeX-indentation
@@ -3850,12 +3843,12 @@ outer indentation in case of a commented line.  The 
symbols
            ;; environment.
            0)
           ((looking-at (concat (regexp-quote TeX-esc)
-                               "begin *{\\("
+                               "begin *{"
                                ;; Don't give optional argument here
                                ;; because indent would be disabled
                                ;; inside comment env otherwise.
                                (LaTeX-verbatim-regexp)
-                               "\\)}"))
+                               "}"))
            0)
           ((looking-at (concat (regexp-quote TeX-esc)
                                "end *{"

commit b379da77ad5caee4e45d4ed6b43398c11437baa8
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Date:   Thu Sep 23 05:14:44 2021 +0900

    Don't indent begin/end of comment env
    
    Begin/end line of comment environment must be flush left, just like
    verbatim environments.  However, comment environment shouldn't be
    included in `LaTeX-verbatim-environments' because
    1. filling shouldn't be disabled inside comment environment
    2. contents inside comment environment should be fontified as comment
    
    * latex.el (LaTeX-verbatim-regexp): Attach a new optional argument
    COMMENT to allow inclusion of comment environments.
    (LaTeX-indent-calculate): Indent begin/end line of comment environment
    at column 0.
    Remove redundant regexp grouping.
    (LaTeX-indent-calculate-last): Calculate indent after comment
    environment correctly.
    Remove redundant regexp grouping.

diff --git a/latex.el b/latex.el
index 9954cc5..d833b0f 100644
--- a/latex.el
+++ b/latex.el
@@ -3681,9 +3681,12 @@ Lines starting with an item is given an extra 
indentation of
   (delete-region (line-beginning-position) (point))
   (indent-to outer-indent))
 
-(defun LaTeX-verbatim-regexp ()
-  "Calculate the verbatim env regex from `LaTeX-verbatim-environments'."
-  (regexp-opt (LaTeX-verbatim-environments)))
+(defun LaTeX-verbatim-regexp (&optional comment)
+  "Calculate the verbatim env regex from `LaTeX-verbatim-environments'.
+If optional argument COMMENT is non-nil, include comment env from
+`LaTeX-comment-env-list'."
+  (regexp-opt (append (LaTeX-verbatim-environments)
+                      (if comment LaTeX-comment-env-list))))
 
 (defun LaTeX-indent-calculate (&optional force-type)
   "Return the indentation of a line of LaTeX source.
@@ -3715,9 +3718,9 @@ outer indentation in case of a commented line.  The 
symbols
                                     (length comment-padding)))
                (nth 1 entry)))
             ((looking-at (concat (regexp-quote TeX-esc)
-                                 "\\(begin\\|end\\){\\("
-                                 (LaTeX-verbatim-regexp)
-                                 "\\)}"))
+                                 "\\(begin\\|end\\){"
+                                 (LaTeX-verbatim-regexp t)
+                                 "}"))
              ;; \end{verbatim} must be flush left, otherwise an unwanted
              ;; empty line appears in LaTeX's output.
              0)
@@ -3848,20 +3851,23 @@ outer indentation in case of a commented line.  The 
symbols
            0)
           ((looking-at (concat (regexp-quote TeX-esc)
                                "begin *{\\("
+                               ;; Don't give optional argument here
+                               ;; because indent would be disabled
+                               ;; inside comment env otherwise.
                                (LaTeX-verbatim-regexp)
                                "\\)}"))
            0)
           ((looking-at (concat (regexp-quote TeX-esc)
-                               "end *{\\("
-                               (LaTeX-verbatim-regexp)
-                               "\\)}"))
+                               "end *{"
+                               (LaTeX-verbatim-regexp t)
+                               "}"))
            ;; If I see an \end{verbatim} in the previous line I skip
            ;; back to the preceding \begin{verbatim}.
            (save-excursion
              (if (re-search-backward (concat (regexp-quote TeX-esc)
-                                             "begin *{\\("
-                                             (LaTeX-verbatim-regexp)
-                                             "\\)}") 0 t)
+                                             "begin *{"
+                                             (LaTeX-verbatim-regexp t)
+                                             "}") 0 t)
                  (LaTeX-indent-calculate-last force-type)
                0)))
           (t (+ (LaTeX-current-indentation force-type)

-----------------------------------------------------------------------

Summary of changes:
 latex.el                  | 41 ++++++++++++++++++-------------------
 tests/latex/latex-test.el | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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