From 5f4fd0880a47baa062adc669dd71b5c3bb917081 Mon Sep 17 00:00:00 2001 Message-Id: <5f4fd0880a47baa062adc669dd71b5c3bb917081.1635075984.git.yantar92@gmail.com> From: Ihor Radchenko Date: Sun, 24 Oct 2021 19:25:24 +0800 Subject: [PATCH] org--get-expected-indentation: Consider section parent type * lisp/org.el (org--get-expected-indentation): Consider new :parent structure when `org-element-at-point' returns parent section and headline elements. * testing/lisp/test-org.el (test-org/indent-region): Add test. Fixes https://list.orgmode.org/87pmrupu0s.fsf@gmail.com/T/#t --- lisp/org.el | 4 ++++ testing/lisp/test-org.el | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lisp/org.el b/lisp/org.el index 0a83c00fc..90804d26e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19218,6 +19218,10 @@ (defun org--get-expected-indentation (element contentsp) (contentsp (cl-case type ((diary-sexp footnote-definition) 0) + (section + (org--get-expected-indentation + (org-element-property :parent element) + t)) ((headline inlinetask nil) (if (not org-adapt-indentation) 0 (let ((level (org-current-level))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 47a5f565f..5838b192d 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1168,6 +1168,13 @@ (ert-deftest test-org/indent-region () (org-adapt-indentation nil)) (org-indent-region (point) (point-max))) (buffer-string)))) + ;; Indent property drawers according to `org-adapt-indentation'. + (let ((org-adapt-indentation 'headline-data)) + (should + (equal "* H\n :PROPERTIES:\n :key:\n :END:" + (org-test-with-temp-text "* H\n:PROPERTIES:\n:key:\n:END:" + (org-indent-region (point-min) (point-max)) + (buffer-string))))) ;; Indent plain lists. (let ((org-adapt-indentation t)) (should -- 2.32.0