From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Can I ask "Which day is it?" when filtering org-agenda views? Date: Tue, 10 Sep 2013 21:19:04 -0400 Message-ID: <87bo40rw8n.fsf@gmail.com> References: <87k3ion228.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJZ5c-00057i-9y for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 21:19:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJZ5U-0002Uw-PW for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 21:19:28 -0400 Received: from plane.gmane.org ([80.91.229.3]:48812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJZ5U-0002Ug-Ig for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 21:19:20 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VJZ5R-0006i0-Ve for emacs-orgmode@gnu.org; Wed, 11 Sep 2013 03:19:17 +0200 Received: from pool-108-7-96-134.bstnma.fios.verizon.net ([108.7.96.134]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Sep 2013 03:19:17 +0200 Received: from ndokos by pool-108-7-96-134.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 Sep 2013 03:19:17 +0200 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 Trevor Murphy writes: > As preface, I'm aware that I may have gone too far down the rabbit > hole. I'm inserting many time grid lines (one per half hour) into my > agenda views so I have a visual sense of my free / busy time. But I > want time grid lines that have already passed to disappear, freeing up > screen real estate for later lines. > > This was pretty easy. I customized `org-agenda-time-grid' to give me > a line at every half-hour interval. Then I set > org-agenda-before-sorting-filter-function' to return nil for time grid > lines where the "time-of-day" text property is in the past. > > In case that description isn't clear, I'm using (apologies for Gmail > formatting): > > (defun my:org-agenda-before-sorting-filter-function (org-agenda-item) > (unless (and > (string= (nth 1 org-agenda-time-grid) > (get-text-property 0 'txt org-agenda-item)) > (< (get-text-property 0 'time-of-day > org-agenda-item) > (string-to-number (format-time-string "%H%M")))) > org-agenda-item)) > > As an unanticipated side effect, my function also throws out time grid > lines when I view tomorrow (and other days) in the agenda view. > > Is there an additional check I can throw into my function to only > filter if the "day" of the time grid line is today? I tried the > obvious (get-text-property 0 'day org-agenda-item) but it seems that > the "day" text property isn't put into the item until /after/ the > filter-function gets a chance to process it. > If I read the code correctly, the date of the item should be available to the function as the value of the dynamically bound variable "date", in (month day year) form. So you should be able to compare that to today's date, obtained with (calendar-gregorian-from-absolute (org-today)) for example. Untested. > Alternatively, if my attempted solution is brain-damaged please let me > know a better way to manage the time grid lines. -- Nick