emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [feature request] A new cookie type [!] showing the last note taken


From: Ihor Radchenko
Subject: Re: [feature request] A new cookie type [!] showing the last note taken
Date: Sun, 30 Aug 2020 18:40:19 +0800

> Notes are free-form; there is no syntax describing them. Org cannot tell
> what is a "note". As a consequence, pointing to "the last note taken" is
> not reliable, syntax wise.

> Of course, under some assumptions (e.g., notes setup is fixed, you never
> write notes by hand, ...), you could guess what the last note taken is.
> But again, this is not reliable, and not portable.

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.

(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)))

Best,
Ihor






Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> Over the years of using Org I often have a need to add a short note
>> about how to proceed with some task:
>>
>> ***** REVIEW check again, subscribe | sindresorhus/awesome: 😎 Awesome lists 
>> about all kinds of interesting topics :BOOKMARK:
>> :PROPERTIES:
>> :CREATED: [2020-03-15 Sun 18:59]
>> :Source: https://github.com/sindresorhus/awesome
>> :END:
>> :LOGBOOK:
>> CLOCK: [2020-03-17 Tue 16:18]--[2020-03-17 Tue 17:46] =>  1:28
>> CLOCK: [2020-03-17 Tue 16:03]--[2020-03-17 Tue 16:18] =>  0:15
>> - Refiled on [2020-03-16 Mon 23:59]
>> :END:
>>
>> In the above example, the short note is "check again, subscribe".
>> The note is not fixed, but changes as I progress with completing the
>> task.
>>
>> This is even more useful for delegated or HOLD tasks where I often need
>> to add a short note why the task is delegated or put on hold:
>>
>> ** HOLD Finish the text prop org-mode | make babel support org file
>> links in header args (:file or :dir)
>> [[id:468e0645-68aa-4e14-86de-e5ce153538e3][[2017-09-22 Fri]
>> CuNbARBshearstrength]] :HOLD:
>> :PROPERTIES:
>> :CREATED: [2020-07-20 Mon 16:53]
>> :SHOWFROMDATE: 2020-08-15
>> :END:
>> :LOGBOOK:
>> - State "HOLD"       from "NEXT"          [2020-08-10 Mon 15:16] \\
>>   Finish the text prop org-mode
>> - Refiled on [2020-07-20 Mon 17:15]
>> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
>> :END:
>>
>> Seeing this note directly in the headline without a need to dig into the
>> task body / LOGBOOK drawer is really handy.
>>
>> In this last example, I had to duplicate the note taken using built-in
>> note mechanism into headline, which was inconvenient. It would be handy
>> if I could simply add a [!] cookie (similar to [/] or [%] cookies) to
>> the headline to show the last note taken for this task. Then, I could
>> easily see the reason why the task is blocked or what I am supposed to
>> do with the task right in agenda view or in the folded headline.
>> Something like the following
>>
>> ** HOLD [!] make babel support org... :HOLD:
>> :LOGBOOK:
>> - State "HOLD"       from "NEXT"          [2020-08-10 Mon 15:16] \\
>>   Finish the text prop org-mode
>> - Refiled on [2020-07-20 Mon 17:15]
>> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
>> :END:
>>
>> The cookie would be replaced by the last note text, according to
>> user-defined format (say, "[%s] |"):
>>
>> ** HOLD [Finish the text prop org-mode] | make babel support org... :HOLD:
>> :LOGBOOK:
>> - State "HOLD"       from "NEXT"          [2020-08-10 Mon 15:16] \\
>>   Finish the text prop org-mode
>> - Refiled on [2020-07-20 Mon 17:15]
>> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
>> :END:
>>
>> What do you think?
>
> Notes are free-form; there is no syntax describing them. Org cannot tell
> what is a "note". As a consequence, pointing to "the last note taken" is
> not reliable, syntax wise.
>
> Of course, under some assumptions (e.g., notes setup is fixed, you never
> write notes by hand, ...), you could guess what the last note taken is.
> But again, this is not reliable, and not portable.
>
> Regards,
> -- 
> Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]