emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Can I ask "Which day is it?" when filtering org-agenda views?
@ 2013-09-10 15:12 Trevor Murphy
  2013-09-11  1:19 ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Trevor Murphy @ 2013-09-10 15:12 UTC (permalink / raw)
  To: emacs-orgmode

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.
 
Alternatively, if my attempted solution is brain-damaged please 
let me know a better way to manage the time grid lines.

-- 
Trevor Murphy GnuPG Key: 0xCB06EAAF

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Can I ask "Which day is it?" when filtering org-agenda views?
  2013-09-10 15:12 Can I ask "Which day is it?" when filtering org-agenda views? Trevor Murphy
@ 2013-09-11  1:19 ` Nick Dokos
  2013-09-11  2:07   ` Trevor Murphy
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nick Dokos @ 2013-09-11  1:19 UTC (permalink / raw)
  To: emacs-orgmode

Trevor Murphy <trevor.m.murphy@gmail.com> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Can I ask "Which day is it?" when filtering org-agenda views?
  2013-09-11  1:19 ` Nick Dokos
@ 2013-09-11  2:07   ` Trevor Murphy
  2013-09-11  2:26   ` Jambunathan K
  2013-09-11  2:27   ` Samuel Wales
  2 siblings, 0 replies; 5+ messages in thread
From: Trevor Murphy @ 2013-09-11  2:07 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> 
> 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. 
> 

Bah!  That's what I get for training myself to ignore dynamic 
variables.  Thank you, this is precisely the suggestion I was 
looking for.

-- 
Trevor Murphy GnuPG Key: 0xCB06EAAF

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Can I ask "Which day is it?" when filtering org-agenda views?
  2013-09-11  1:19 ` Nick Dokos
  2013-09-11  2:07   ` Trevor Murphy
@ 2013-09-11  2:26   ` Jambunathan K
  2013-09-11  2:27   ` Samuel Wales
  2 siblings, 0 replies; 5+ messages in thread
From: Jambunathan K @ 2013-09-11  2:26 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> the date of the item should be available to the function as the value
> of the dynamically bound variable "date",

To whomsoever it may concern.

    http://lists.gnu.org/archive/html/emacs-devel/2013-09/msg00085.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Can I ask "Which day is it?" when filtering org-agenda views?
  2013-09-11  1:19 ` Nick Dokos
  2013-09-11  2:07   ` Trevor Murphy
  2013-09-11  2:26   ` Jambunathan K
@ 2013-09-11  2:27   ` Samuel Wales
  2 siblings, 0 replies; 5+ messages in thread
From: Samuel Wales @ 2013-09-11  2:27 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

What a great answer to Trevor.  Thanks for your continued help to people, Nick.

On 9/10/13, Nick Dokos <ndokos@gmail.com> wrote:
> Trevor Murphy <trevor.m.murphy@gmail.com> writes:
> If I read the code correctly, the date of the item should be available

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  ANYBODY can get it.

Denmark: free Karina Hansen NOW.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-11  2:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10 15:12 Can I ask "Which day is it?" when filtering org-agenda views? Trevor Murphy
2013-09-11  1:19 ` Nick Dokos
2013-09-11  2:07   ` Trevor Murphy
2013-09-11  2:26   ` Jambunathan K
2013-09-11  2:27   ` Samuel Wales

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).