emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Angel de Vicente <angel.vicente.garrido@gmail.com>
To: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <87sfksq4db.fsf@gmail.com> (raw)
In-Reply-To: 87fsguxhco.fsf@localhost

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)



  parent reply	other threads:[~2022-09-15 11:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  9:28 Do not show a TODO item in the global TODO list until certain date? Angel de Vicente
2022-09-14  9:38 ` Rohit Patnaik
2022-09-14 10:44   ` Angel de Vicente
2022-09-14 12:36     ` Ihor Radchenko
2022-09-15  5:37       ` Angel de Vicente
2022-09-15 11:11       ` Angel de Vicente [this message]
2022-10-12 11:26         ` Ihor Radchenko
2022-10-21 19:35           ` Angel de Vicente
2022-10-21 23:07             ` Ihor Radchenko
2022-09-22 15:26     ` Bastien
2022-09-22 16:58       ` Angel de Vicente

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfksq4db.fsf@gmail.com \
    --to=angel.vicente.garrido@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).