From 5a35577f22cdc849ebcede6bac7b7f22da7eb16b Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Fri, 2 Oct 2020 14:01:35 -0400 Subject: [PATCH] org-capture.el: Fix heading's position when inserting a template "here" * lisp/org-capture.el (org-capture-place-entry): Fix heading's position when inserting a template "here" with C-0 M-x org-capture. --- lisp/org-capture.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 67c58ffdd..020feb4d6 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1150,10 +1150,11 @@ may have been stored before." (insert-here? ;; FIXME: level should probably set directly within (let ...). (setq level (org-get-valid-level - (if (or (org-at-heading-p) - (ignore-errors (org-back-to-heading t))) - (org-outline-level) - 1)))) + (if (or (org-at-heading-p) + (ignore-errors + (save-excursion (org-back-to-heading t)))) + (org-outline-level) + 1)))) ;; Insert as a child of the current entry. ((org-capture-get :target-entry-p) (setq level (org-get-valid-level -- 2.28.0