From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Harkins Subject: Sharing: Agenda skip function to remove future-scheduled items Date: Tue, 14 Oct 2014 12:43:48 +0800 Message-ID: <87egubjm63.wl-jamshark70@qq.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xdty8-0001FB-K9 for emacs-orgmode@gnu.org; Tue, 14 Oct 2014 00:44:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xdty3-0002ca-4C for emacs-orgmode@gnu.org; Tue, 14 Oct 2014 00:44:20 -0400 Received: from smtpbgbr2.qq.com ([54.207.22.56]:57222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xdty1-0002cE-Qo for emacs-orgmode@gnu.org; Tue, 14 Oct 2014 00:44:15 -0400 Received: from hjh-e431.qq.com (unknown [219.136.7.35]) by esmtp4.qq.com (ESMTP) with SMTP id 0 for ; Tue, 14 Oct 2014 12:44:05 +0800 (CST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I often ask questions, or complain about things (or both at the same time), so it's nice to share something. I was making a block agenda, splitting up tasks by location (loosely inspired by GTD). But I realized that I didn't want to see items that are scheduled for the future, because this is my agenda view for "what tasks are available right now." For example, if I have a task to update my grade sheet, it doesn't make sense to do that before I've taught the lessons -- so I don't want to see the task until it's actually due. I didn't find a straightforward way to use a property search such as "scheduled is nil or scheduled > today," but I did (with some false starts) hack up a skip function that seems to do the job. So, in the relevant blocks, I have (org-agenda-skip-function 'hjh-skip-future-scheduled), and... perfect. (I'm sure it's not the most efficient, but I found elisp's time comparisons to be confusing, and I didn't want to consider time-of-day either. Performance is OK for my use.) hjh ; agenda skip function to remove items scheduled for a future date (defun hjh-skip-future-scheduled () "Skip trees that are scheduled in the future" (let* ((subtree-end (save-excursion (org-end-of-subtree t))) (schedprop (cdr (assoc "SCHEDULED" (org-entry-properties)))) (schedymd (if(stringp schedprop) (substring schedprop 0 10)))) (if schedymd (if (string< (format-time-string "%Y-%m-%d" (current-time)) schedymd) subtree-end nil) nil)))