branch: externals/org
commit f66b130c95f3a975b504bf60e0e300634f4a8591
Author: Lukas Rudd Andersen <l...@phdk.org>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org--get-expected-indentation: Indent end tag of blocks of all types
    
    * lisp/org.el (org--get-expected-indentation): Add all block types to
      the check for indenting end tags.
    
    * testing/lisp/test-org.el (test-org/indent-line): Add tests.
    
    Link: https://list.orgmode.org/877c48jg29.fsf@localhost/
    TINYCHANGE
---
 lisp/org.el              | 14 ++++++++++----
 testing/lisp/test-org.el | 18 ++++++++++--------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 14df7ed66d..b533c70983 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19363,10 +19363,16 @@ ELEMENT."
          ;; and contents.
          ((and post-affiliated (= (line-beginning-position) post-affiliated))
           (org--get-expected-indentation element t))
-         ;; POS is after contents in a greater element.  Indent like
-         ;; the beginning of the element.
-         ((and (memq type org-element-greater-elements)
-               (let ((cend (org-element-contents-end element)))
+         ;; POS is after contents in a greater element or other block.
+         ;; Indent like the beginning of the element.
+         ((and (or (memq type org-element-greater-elements)
+                    (memq type '(comment-block example-block export-block
+                                               src-block verse-block)))
+               (let ((cend (or (org-element-contents-end element)
+                                (org-with-wide-buffer
+                                (goto-char (org-element-end element))
+                                (skip-chars-backward " \r\t\n")
+                                (line-beginning-position)))))
                  (and cend (<= cend pos))))
           ;; As a special case, if point is at the end of a footnote
           ;; definition or an item, indent like the very last element
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index a55c4162ea..eefc9b6922 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1184,14 +1184,16 @@ Otherwise, evaluate RESULT as an sexp and return its 
result."
     (org-test-with-temp-text "* H\n[fn:1] Definition\n\n\n\n<point>"
       (let ((org-adapt-indentation t)) (org-indent-line))
       (org-get-indentation))))
-  ;; After the end of the contents of a greater element, indent like
-  ;; the beginning of the element.
-  (should
-   (= 1
-      (org-test-with-temp-text
-         " #+BEGIN_CENTER\n  Contents\n<point>#+END_CENTER"
-       (org-indent-line)
-       (org-get-indentation))))
+  ;; After the end of the contents of a greater element or other
+  ;; block, indent like the beginning of the element.
+  (mapcar (lambda (type)
+           (should
+            (= 1
+               (org-test-with-temp-text
+                   (format " #+BEGIN_%1$s\n  Contents\n<point>#+END_%1$s" type)
+                 (org-indent-line)
+                 (current-indentation)))))
+         '("CENTER" "COMMENT" "EXAMPLE" "EXPORT" "SRC" "VERSE"))
   ;; On blank lines after a paragraph, indent like its last non-empty
   ;; line.
   (should

Reply via email to