I'll have to try this on my config sometime next week. Thanks a ton for this, bookmarking this post for now.
> I often change states of my todo list items to 'DONE', 'CANCELLED', etc.
>
> However, one thing I would want to know is this:
> - Is it possible to automatically delete the '#' priority value of a task after a task has been marked as 'DONE', 'CANCELLED', etc?
>
> Is this done via a hook function?
To do it globally:
--8<---------------cut here---------------start------------->8---
(defun my/org-trigger-hook (change-plist)
(let* ((type (plist-get change-plist :type))
(pos (plist-get change-plist :position))
(from (substring-no-properties (or (plist-get change-plist :from) "")))
(to (substring-no-properties (or (plist-get change-plist :to) "")))
)
(when (and
(eq type 'todo-state-change)
(member to org-done-keywords)
(member from org-not-done-keywords)
)
(org-priority (string-to-char " "))
)
)
)
(add-hook #'org-trigger-hook
#'my/org-trigger-hook)
--8<---------------cut here---------------end--------------->8---
But if, like me, you want to define this behavior per task, this is one
of the purposes of org-edna. I suggest you try it.
I your particular example, you would simply set the TRIGGER property of
the task for which you want to delete the priority to this content
--8<---------------cut here---------------start------------->8---
* NEXT [#B] some task
:PROPERTIES:
:TRIGGER: self() set-priority!(" ")
:END:
--8<---------------cut here---------------end--------------->8---
Closing it would result in
--8<---------------cut here---------------start------------->8---
* DONE some task
CLOSED: [2021-12-11 Sat 13:38]
:PROPERTIES:
:TRIGGER: self() set-priority!(" ")
:END:
--8<---------------cut here---------------end--------------->8---
Of course, it also work for repeated task or any complicated scenario
I have tried so far.
I hope that helps,
--
Konubinix
GPG Key : 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A
Attachments: