Make storing note upon headline change more robust

Let's not wait until our code turns out to be broken, but fix it now.
This commit is contained in:
Daniel - 2023-02-14 16:41:07 +01:00
parent fb60b22c5e
commit c5f1e98bf8
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 7 additions and 10 deletions

View File

@ -1058,17 +1058,14 @@ cache if that's in use."
;; Update headline
(org-edit-headline new-headline)
;; Store note manually (I tried using `org-add-log-note', but did not
;; succeed …); maybe use the logging function from
;; Code to add note interactively taken from
;; https://sachachua.com/blog/2022/11/logging-sent-messages-to-org-mode-with-message-sent-hook/
;; instead?
(goto-char (org-log-beginning 'create))
(indent-according-to-mode)
(insert "- Note taken on ")
(org-insert-time-stamp (current-time) t t)
(insert " \\\\\n")
(indent-according-to-mode)
(insert (format " Changed headline from: %s\n" old-headline)))))
(move-marker org-log-note-return-to (point))
(move-marker org-log-note-marker (point))
(with-temp-buffer
(insert (format "Changed headline from: %s\n" old-headline))
(let ((org-log-note-purpose 'note))
(org-store-log-note))))))
(when org-refile-use-cache
(org-refile-cache-clear))