[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: org-capture at point
From: |
Kyle Meyer |
Subject: |
Re: org-capture at point |
Date: |
Sat, 03 Oct 2020 02:36:06 -0400 |
No Wayman writes:
>> Looks like it was introduced with:
>>
>> f5573e6a0 org-capture.el: Fix heading's level when inserting a
>> template "here"
>
> I believe the issue is due to `org-back-to-heading' moving point
> when calculating the heading level.
> The attached patch corrects the issue on my end.
Thank you!
> 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))))
This looks correct to me, and AFAICT this doesn't break the scenario
that prompted the code you're adjusting from f5573e6a0:
https://orgmode.org/list/87lfiuxqze.fsf@alphaville.usersys.redhat.com/
Applied (8d3610df0), extending the commit message with a Reported-by
trailer and link for https://orgmode.org/list/877dscaila.fsf@dwrz.net/