From: No Wayman <iarchivedmywholelife@gmail.com>
To: emacs-orgmode@gnu.org
Cc: emacs-orgmode-request@gnu.org
Subject: Re: org-capture at point
Date: Fri, 02 Oct 2020 14:46:16 -0400 [thread overview]
Message-ID: <87ft6wwjnr.fsf@gmail.com> (raw)
In-Reply-To: <87lfgrdegt.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
> 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.
Tested by running:
#+begin_src emacs-lisp :lexical t
(dotimes (n 3)
(let ((org-capture-templates
`(( "e" "test"
entry
(file "/temp/null.org")
,(format "* %d" n)
:immediate-finish t
:no-save t))))
(goto-char (point-max))
(org-capture 0 "e")))
#+end_src
With a buffer containing:
* foo
** one
*** two
**** three
*** four
Which results in:
* foo
** one
*** two
**** three
*** four
*** 0
*** 1
*** 2
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: capture-here-position --]
[-- Type: text/x-patch, Size: 1281 bytes --]
From 5a35577f22cdc849ebcede6bac7b7f22da7eb16b Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
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
next prev parent reply other threads:[~2020-10-02 18:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.57.1601395229.29559.emacs-orgmode@gnu.org>
2020-09-30 5:24 ` org-capture at point No Wayman
2020-10-02 18:46 ` No Wayman [this message]
2020-10-03 6:36 ` Kyle Meyer
2020-09-29 12:11 david wen riccardi-zhu
2020-10-03 6:45 ` Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ft6wwjnr.fsf@gmail.com \
--to=iarchivedmywholelife@gmail.com \
--cc=emacs-orgmode-request@gnu.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).