Bastien <b...@gnu.org> writes:

>> It is now, as of commit 0a651b746.
>
> ... and I broke some tests.  Sorry for that.  I will fix this next
> week, unless someone does it before me.

Here are two patches that set org-adapt-indentation to t for the tests
which were implicitly relying on that behavior; that lets 'make test'
succeed again for me.

I'm pretty sure the first one is TRT (since I'm the author of the
tests), although Eventually™ we should make a more exhaustive suite
based on the table you referenced earlier.

The second one makes the remaining tests pass again, but I couldn't tell
at a glance whether their expectations still make sense.

>From e136f0d3123173d947bf4c1ce06aaf5f12117ef8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legoug...@gmail.com>
Date: Sun, 9 May 2021 18:05:35 +0200
Subject: [PATCH 1/2] Set org-adapt-indentation explicitly in some tests

* testing/lisp/test-org.el (test-org/with-electric-indent,
test-org/without-electric-indent): Make sure org-adapt-indentation is
consistent with expected results.
---
 testing/lisp/test-org.el | 42 +++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 9f0ede1b9..5ac9173ac 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1404,12 +1404,14 @@
 	    (electric-indent-local-mode 1)
 	    (call-interactively 'org-return)
 	    (buffer-string))))
-  (should
-   (equal "* heading\n  body"
-	  (org-test-with-temp-text "* heading<point>body"
-	    (electric-indent-local-mode 1)
-	    (call-interactively 'org-return)
-	    (buffer-string))))
+  ;; TODO: test more values of `org-adapt-indentation'.
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "* heading\n  body"
+	    (org-test-with-temp-text "* heading<point>body"
+	      (electric-indent-local-mode 1)
+	      (call-interactively 'org-return)
+	      (buffer-string)))))
   ;; C-j, like `electric-newline-and-maybe-indent', should not indent.
   (should
    (equal "  Para\ngraph"
@@ -1423,12 +1425,14 @@
 	    (electric-indent-local-mode 1)
 	    (call-interactively 'org-return-and-maybe-indent)
 	    (buffer-string))))
-  (should
-   (equal "* heading\nbody"
-	  (org-test-with-temp-text "* heading<point>body"
-	    (electric-indent-local-mode 1)
-	    (call-interactively 'org-return-and-maybe-indent)
-	    (buffer-string)))))
+  ;; TODO: test more values of `org-adapt-indentation'.
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "* heading\nbody"
+	    (org-test-with-temp-text "* heading<point>body"
+	      (electric-indent-local-mode 1)
+	      (call-interactively 'org-return-and-maybe-indent)
+	      (buffer-string))))))
 
 (ert-deftest test-org/without-electric-indent ()
   "Test RET and C-j specifications with `electric-indent-mode' off."
@@ -1467,12 +1471,14 @@
 	    (electric-indent-local-mode 0)
 	    (call-interactively 'org-return-and-maybe-indent)
 	    (buffer-string))))
-  (should
-   (equal "* heading\n  body"
-	  (org-test-with-temp-text "* heading<point>body"
-	    (electric-indent-local-mode 0)
-	    (call-interactively 'org-return-and-maybe-indent)
-	    (buffer-string)))))
+  ;; TODO: test more values of `org-adapt-indentation'.
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "* heading\n  body"
+	    (org-test-with-temp-text "* heading<point>body"
+	      (electric-indent-local-mode 0)
+	      (call-interactively 'org-return-and-maybe-indent)
+	      (buffer-string))))))
 
 (ert-deftest test-org/meta-return ()
   "Test M-RET (`org-meta-return') specifications."
-- 
2.31.1

>From 2a485754a7f04d00ef5e5ebed82924d44f768424 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legoug...@gmail.com>
Date: Sun, 9 May 2021 18:20:11 +0200
Subject: [PATCH 2/2] Set org-adapt-indentation explicitly in some tests

* testing/lisp/test-org.el (test-org/indent-line,
test-org/indent-region): Make sure org-adapt-indentation is consistent
with expected results.
---
 testing/lisp/test-org.el | 126 ++++++++++++++++++++-------------------
 1 file changed, 66 insertions(+), 60 deletions(-)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 5ac9173ac..95ffb0a80 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1007,22 +1007,23 @@
   ;; At the first line of an element, indent like previous element's
   ;; first line, ignoring footnotes definitions and inline tasks, or
   ;; according to parent.
-  (should
-   (= 2
-      (org-test-with-temp-text "A\n\n  B\n\nC<point>"
-	(org-indent-line)
-	(org-get-indentation))))
-  (should
-   (= 1
-      (org-test-with-temp-text " A\n\n[fn:1] B\n\n\nC<point>"
-	(org-indent-line)
-	(org-get-indentation))))
-  (should
-   (= 1
-      (org-test-with-temp-text
-	  " #+BEGIN_CENTER\n<point>  Contents\n#+END_CENTER"
-	(org-indent-line)
-	(org-get-indentation))))
+  (let ((org-adapt-indentation t))
+    (should
+     (= 2
+        (org-test-with-temp-text "A\n\n  B\n\nC<point>"
+	                         (org-indent-line)
+	                         (org-get-indentation))))
+    (should
+     (= 1
+        (org-test-with-temp-text " A\n\n[fn:1] B\n\n\nC<point>"
+	                         (org-indent-line)
+	                         (org-get-indentation))))
+    (should
+     (= 1
+        (org-test-with-temp-text
+	 " #+BEGIN_CENTER\n<point>  Contents\n#+END_CENTER"
+	 (org-indent-line)
+	 (org-get-indentation)))))
   ;; Within code part of a source block, use language major mode if
   ;; `org-src-tab-acts-natively' is non-nil.  Otherwise, indent
   ;; according to line above.
@@ -1066,11 +1067,12 @@
 (ert-deftest test-org/indent-region ()
   "Test `org-indent-region' specifications."
   ;; Indent paragraph.
-  (should
-   (equal "A\nB\nC"
-	  (org-test-with-temp-text " A\nB\n  C"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "A\nB\nC"
+	    (org-test-with-temp-text " A\nB\n  C"
+	                             (org-indent-region (point-min) (point-max))
+	                             (buffer-string)))))
   ;; Indent greater elements along with their contents.
   (should
    (equal "#+BEGIN_CENTER\nA\nB\n#+END_CENTER"
@@ -1083,11 +1085,12 @@
 	  (org-test-with-temp-text "#+BEGIN_VERSE\n A\n  B\n#+END_VERSE"
 	    (org-indent-region (point-min) (point-max))
 	    (buffer-string))))
-  (should
-   (equal "#+BEGIN_VERSE\n  A\n   B\n#+END_VERSE"
-	  (org-test-with-temp-text " #+BEGIN_VERSE\n  A\n   B\n #+END_VERSE"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "#+BEGIN_VERSE\n  A\n   B\n#+END_VERSE"
+	    (org-test-with-temp-text " #+BEGIN_VERSE\n  A\n   B\n #+END_VERSE"
+	                             (org-indent-region (point-min) (point-max))
+	                             (buffer-string)))))
   ;; Indent example blocks as a single block, unless indentation
   ;; should be preserved.  In this case only indent the block markers.
   (should
@@ -1095,36 +1098,38 @@
 	  (org-test-with-temp-text "#+BEGIN_EXAMPLE\n A\n  B\n#+END_EXAMPLE"
 	    (org-indent-region (point-min) (point-max))
 	    (buffer-string))))
-  (should
-   (equal "#+BEGIN_EXAMPLE\n A\n  B\n#+END_EXAMPLE"
-	  (org-test-with-temp-text " #+BEGIN_EXAMPLE\n  A\n   B\n #+END_EXAMPLE"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
-  (should
-   (equal "#+BEGIN_EXAMPLE -i\n  A\n   B\n#+END_EXAMPLE"
-	  (org-test-with-temp-text
-	      " #+BEGIN_EXAMPLE -i\n  A\n   B\n #+END_EXAMPLE"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
-  (should
-   (equal "#+BEGIN_EXAMPLE\n  A\n   B\n#+END_EXAMPLE"
-	  (org-test-with-temp-text
-	      " #+BEGIN_EXAMPLE\n  A\n   B\n #+END_EXAMPLE"
-	    (let ((org-src-preserve-indentation t))
-	      (org-indent-region (point-min) (point-max)))
-	    (buffer-string))))
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "#+BEGIN_EXAMPLE\n A\n  B\n#+END_EXAMPLE"
+	    (org-test-with-temp-text " #+BEGIN_EXAMPLE\n  A\n   B\n #+END_EXAMPLE"
+	                             (org-indent-region (point-min) (point-max))
+	                             (buffer-string))))
+    (should
+     (equal "#+BEGIN_EXAMPLE -i\n  A\n   B\n#+END_EXAMPLE"
+	    (org-test-with-temp-text
+	     " #+BEGIN_EXAMPLE -i\n  A\n   B\n #+END_EXAMPLE"
+	     (org-indent-region (point-min) (point-max))
+	     (buffer-string))))
+    (should
+     (equal "#+BEGIN_EXAMPLE\n  A\n   B\n#+END_EXAMPLE"
+	    (org-test-with-temp-text
+	     " #+BEGIN_EXAMPLE\n  A\n   B\n #+END_EXAMPLE"
+	     (let ((org-src-preserve-indentation t))
+	       (org-indent-region (point-min) (point-max)))
+	     (buffer-string)))))
   ;; Treat export blocks as a whole.
   (should
    (equal "#+BEGIN_EXPORT latex\n A\n  B\n#+END_EXPORT"
 	  (org-test-with-temp-text "#+BEGIN_EXPORT latex\n A\n  B\n#+END_EXPORT"
 	    (org-indent-region (point-min) (point-max))
 	    (buffer-string))))
-  (should
-   (equal "#+BEGIN_EXPORT latex\n A\n  B\n#+END_EXPORT"
-	  (org-test-with-temp-text
-	      " #+BEGIN_EXPORT latex\n  A\n   B\n #+END_EXPORT"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "#+BEGIN_EXPORT latex\n A\n  B\n#+END_EXPORT"
+	    (org-test-with-temp-text
+	        " #+BEGIN_EXPORT latex\n  A\n   B\n #+END_EXPORT"
+	      (org-indent-region (point-min) (point-max))
+	      (buffer-string)))))
   ;; Indent according to mode if `org-src-tab-acts-natively' is
   ;; non-nil.  Otherwise, do not indent code at all.
   (should
@@ -1160,16 +1165,17 @@
 	      (org-indent-region (point) (point-max)))
 	    (buffer-string))))
   ;; Indent plain lists.
-  (should
-   (equal "- A\n  B\n  - C\n\n    D"
-	  (org-test-with-temp-text "- A\n   B\n  - C\n\n     D"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
-  (should
-   (equal "- A\n\n- B"
-	  (org-test-with-temp-text " - A\n\n - B"
-	    (org-indent-region (point-min) (point-max))
-	    (buffer-string))))
+  (let ((org-adapt-indentation t))
+    (should
+     (equal "- A\n  B\n  - C\n\n    D"
+	    (org-test-with-temp-text "- A\n   B\n  - C\n\n     D"
+	      (org-indent-region (point-min) (point-max))
+	      (buffer-string))))
+    (should
+     (equal "- A\n\n- B"
+	    (org-test-with-temp-text " - A\n\n - B"
+	      (org-indent-region (point-min) (point-max))
+	      (buffer-string)))))
   ;; Indent footnote definitions.
   (should
    (equal "[fn:1] Definition\n\nDefinition"
-- 
2.31.1

Reply via email to