branch: externals/org
commit 38e0eaeec4b1b3482be1afbf77373457bacd93f2
Author: Morgan Smith <[email protected]>
Commit: Morgan Smith <[email protected]>
org-log-beginning: Fix indented drawer folding at creation
* lisp/org.el (org-log-beginning): Use 'point-marker' instead of
'point' so that we are still in the correct place after identation.
testing/lisp/test-org.el (test-org/org-log-into-drawer): Add tests for
when 'org-adapt-indentation' is t.
Reported-by: Tor Kringeland <[email protected]>
Link: https://list.orgmode.org/[email protected]
---
lisp/org.el | 5 +++--
testing/lisp/test-org.el | 14 ++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 282e730b401..b2bb06ae826 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10892,7 +10892,7 @@ narrowing."
(insert-and-inherit "\n"))
(let ((beg (point)) cbeg)
(insert-and-inherit ":" drawer ":")
- (setq cbeg (point))
+ (setq cbeg (point-marker))
(insert-and-inherit "\n:END:")
(cond
(at-blank-line?
@@ -10911,7 +10911,8 @@ narrowing."
(insert "\n")
(backward-char)))
(org-indent-region beg (point))
- (org-fold-region cbeg (point) t 'drawer)))))
+ (org-fold-region cbeg (point) t 'drawer)
+ (move-marker cbeg nil)))))
(end-of-line 0))))
(t
(org-end-of-meta-data org-log-state-notes-insert-after-drawers)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index af542b47df4..ae3341a2893 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -9478,6 +9478,20 @@ Behavior can be modified by setting
`org-log-into-drawer', by keywords in
(test-org-log-into-drawer "custom" "* TODO task"
(concat "* WAIT task\n"
custom-logbook-string)
"* WAIT task\n:custom:")
+ ;; Ensure indentation works correctly
+ (let ((org-adapt-indentation t))
+ (test-org-log-into-drawer nil "* TODO task"
+ (concat "* WAIT task\n "
state-change-string))
+ (test-org-log-into-drawer t "* TODO task"
+ (concat "* WAIT task\n "
+ (string-replace "\n" "\n "
+ logbook-string))
+ "* WAIT task\n :LOGBOOK:")
+ (test-org-log-into-drawer "custom" "* TODO task"
+ (concat "* WAIT task\n "
+ (string-replace "\n" "\n "
+
custom-logbook-string))
+ "* WAIT task\n :custom:"))
;; LOG_INTO_DRAWER property overrides `org-log-into-drawer'
(test-org-log-into-drawer t (concat "* TODO task\n"
(log-into-drawer-property "nil"))
(concat "* WAIT task\n"
(log-into-drawer-property "nil")