Ihor Radchenko <[email protected]> writes: > I was mainly referring to org-add-note. The last note taken with > org-add-note can be found quite reliably. > > I am using the following code saving the last note into :SUMMARY: > property upon exiting the note buffer. Though it may be an overkill, not > sure how easy would it be to parse the note syntax for notes created by > org-add-note.
You cannot reliably. > (defvar yant/last-note-taken "" > "Text of the last note taken.") > > (define-advice org-store-log-note (:before (&rest args) > yant/org-store-last-note) > "Store the last saved note into `yant/last-note-taken'." > (let ((txt (buffer-string))) > (while (string-match "\\`# .*\n[ \t\n]*" txt) > (setq txt (replace-match "" t t txt))) > (when (string-match "\\s-+\\'" txt) > (setq txt (replace-match " " t t txt))) > (when (string-match "\n" txt) > (setq txt (replace-match " " t t txt))) > (if (not (seq-empty-p txt)) > (setq yant/last-note-taken txt)))) > > (define-advice org-store-log-note (:after (&rest args) > yant/org-save-last-note-into-summary-prop) > "Save the last saved note into SUMMARY property." > (when (and (not org-note-abort) (not (seq-empty-p yant/last-note-taken))) > (if (eq major-mode 'org-agenda-mode) > (org-with-point-at-org-buffer > (org-set-property "SUMMARY" (or yant/last-note-taken ""))) > (org-set-property "SUMMARY" (or yant/last-note-taken ""))) > (setq yant/last-note-taken nil))) This implementation is only tangentially related to a "last note". You want to introduce some syntax to display the value a given property, here SUMMARY. But `org-add-note' is not the only way to add a note. Again, on a given document, you can only guess what is the "last note". This is not reliable enough to extend the syntax. Regards,
