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
This commit is contained in:
Ihor Radchenko 2021-10-24 19:25:24 +08:00
parent e2fa3c4c40
commit 5f4fd0880a
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 11 additions and 0 deletions

View File

@ -19218,6 +19218,10 @@ ELEMENT."
(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)))

View File

@ -1168,6 +1168,13 @@
(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