Fix adding notes when updating headlines

I think I just did it wrong, so let's try adding a note by calling
`org-add-note` directly.  So far it's working better, but I am not quite sure
whether I really did it right this time.  In any way, `org-add-note` keeps track
of all the bookkeeping for taking notes, so my code is simpler now :)
This commit is contained in:
Daniel - 2022-01-08 09:11:02 +01:00
parent 4a5b363ead
commit d23a8dc817
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 6 additions and 9 deletions

View File

@ -710,15 +710,12 @@ Interactively query for HEADLINE when not provided."
(let ((old-headline (org-entry-get (point) "ITEM"))) (let ((old-headline (org-entry-get (point) "ITEM")))
(org-edit-headline new-headline) (org-edit-headline new-headline)
;; This simulates manually adding a note. It may also work by directly ;; This simulates adding a note manually. I am not quite sure how
;; using `org-add-note', but this function makes use of `post-command-hook' ;; robust this is, but let's try it out.
;; in a way I do not understand. So let's try it that way. (org-add-note)
(move-marker org-log-note-marker (point)) (insert ; This goes into the *Org Note* buffer.
(let ((org-log-note-purpose 'note)) (format "Changed headline from: %s" old-headline))
(org-add-log-note nil) (org-store-log-note))))
(insert ; This goes into the *Org Note* buffer.
(format "Changed headline from: %s" old-headline))
(org-store-log-note)))))
(when (derived-mode-p 'org-agenda-mode) (when (derived-mode-p 'org-agenda-mode)
(org-agenda-redo))) (org-agenda-redo)))