[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Do not show a TODO item in the global TODO list until certain date?
From: |
Angel de Vicente |
Subject: |
Re: Do not show a TODO item in the global TODO list until certain date? |
Date: |
Thu, 15 Sep 2022 12:11:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) |
Hello,
Ihor Radchenko <yantar92@gmail.com> writes:
> Also, I am doing something similar in my personal config using
> SHOWFROMDATE property. See
> https://github.com/yantar92/emacs-config/blob/master/config.org#properties
> for inspiration.
I tried the following but without success... my Emacs Lisp lack of
knowledge is showing here...
I copied your code from
https://github.com/yantar92/emacs-config/blob/master/config.org#properties
into my .emacs and eval-ed it.
,----
| (add-to-list 'org-default-properties "SHOWFROMDATE")
| (bind-key "C-c C-f" #'org-command-set-SHOWFROMDATE-property org-mode-map)
| (bind-key "C-c C-f" #'org-command-set-SHOWFROMDATE-property
org-agenda-mode-map)
| (add-to-list 'org-agenda-bulk-custom-functions '(?F
org-command-set-SHOWFROMDATE-property))
|
| (defun org-command-set-SHOWFROMDATE-property (&optional arg)
| "Command to set :SHOWFROMDATE property for the org entry at point.
| If NOT-IN-AGENDA is not nil, do not check whether we are in agenda
now."
| (interactive "P")
| (if (equal major-mode 'org-agenda-mode)
| (progn
| (org-agenda-check-no-diary)
| (let* ((marker (or (org-get-at-bol 'org-marker)
| (org-agenda-error)))
| (buffer (marker-buffer marker))
| (pos (marker-position marker))
| (inhibit-read-only t)
| ts)
| (org-with-remote-undo buffer
| (with-current-buffer buffer
| (widen)
| (goto-char pos)
| ;; (org-fold-show-context 'agenda)
| (funcall-interactively 'org-command-set-SHOWFROMDATE-property arg)
| (setq ts (org-entry-get (point) "SHOWFROMDATE")))
| (org-agenda-show-new-time marker ts " P"))))
| (let ((property "SHOWFROMDATE"))
| (if (equal arg '(4))
| (org-entry-delete (point) property)
| (let ((value (org-read-property-value property))
| (fn (cdr (assoc-string property org-properties-postprocess-alist
t))))
| (setq org-last-set-property property)
| (setq org-last-set-property-value (concat property ": " value))
| ;; Possibly postprocess the inserted value:
| (when fn (setq value (funcall fn value)))
| (unless (equal (org-entry-get nil property) value)
| (org-entry-put nil property value)))))))
|
| (defun org-set-SHOWFROMDATE-property (PROMPT &rest args)
| "Read :SHOWFROMDATE: property."
| (org-read-date nil nil nil PROMPT))
|
| (add-to-list 'org-property-set-functions-alist '("SHOWFROMDATE" .
org-set-SHOWFROMDATE-property))
|
| (defun org-agenda-skip-before-SHOWFROMDATE-property ()
| "Skip agenda item if :SHOWFROMDATE: property is set and the day is before
it"
| (when-let* ((showfromdate (if (bound-and-true-p org-ql--current-element)
| (org-element-property :SHOWFROMDATE
(org-element-lineage org-ql--current-element '(headline) t))
| (org-entry-get (point) "SHOWFROMDATE")))
| (showfromdate (unless (seq-empty-p showfromdate) (ts-parse-org
showfromdate)))
| (currenttime (ts-now)))
| (ts< currenttime showfromdate)))
`----
Then, I defined a test custom command:
,----
| (setq org-agenda-custom-commands
| '(("h" "Agenda and tasks"
| ((agenda "" ((org-agenda-skip-function
'org-agenda-skip-before-SHOWFROMDATE-property)))
| (alltodo "" ((org-agenda-skip-function
'org-agenda-skip-before-SHOWFROMDATE-property)))))))
`----
together with a test TODO item:
,----
| ** TODO test :personal:
|
| :PROPERTIES:
| :SHOWFROMDATE: 2022-10-16
| :END:
`----
But the "test" still shows in the TODO list. Am I missing something
basic here?
Thanks for your help. Cheers,
--
Ángel de Vicente
Research Software Engineer (Supercomputing and BigData)
Instituto de Astrofísica de Canarias (https://www.iac.es/en)