emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Sunrise / Sunset in Agenda View only for Current Day?


From: Matt Lundin
Subject: [Orgmode] Re: Sunrise / Sunset in Agenda View only for Current Day?
Date: Wed, 03 Nov 2010 20:43:39 -0400
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

"Raymond Zeitler" <address@hidden> writes:

> I added sunrise & day of the week to the org file that I base my agenda view
> on.  But this adds the information for every day that's displayed in the
> agenda.  Is it possible to get the information to show up only for the
> current day?
>
> TIA
>
> Here's the relevant content in the org file:
> #+CATEGORY: Day/Year
> &%%(diary-day-of-year)
> #+CATEGORY: Sunrise
> &%%(diary-sunrise-sunset)

One way to accomplish this is with a custom skip function and a custom
agenda command. In order for this particular setup to work, you'll need
to put the sunrise sexp in it's own subtree, as in:

--8<---------------cut here---------------start------------->8---
* Sunrise
  :PROPERTIES:
  :CATEGORY: Sunrise
  :END:
&%%(diary-sunrise-sunset)
--8<---------------cut here---------------end--------------->8---

Note: it's important that you use the CATEGORY property to ensure that
the category "Sunrise" is limited to a single subtree.

Then, you could add the following function to your emacs:

--8<---------------cut here---------------start------------->8---
(defun my-org-skip-sunrise ()
  (if (and (not (equal date (calendar-current-date)))
           (string= (org-get-category) "Sunrise"))
      (org-end-of-subtree t)
    nil))
--8<---------------cut here---------------end--------------->8---

Finally, you could define a custom command that instructs org to use the
skip function to bypass all "Sunrise" entries for days other than today:

--8<---------------cut here---------------start------------->8---
(add-to-list 'org-agenda-custom-commands 
             '("x" "My agenda" agenda ""
                ((org-agenda-ndays 7)
                 (org-agenda-skip-function 'my-org-skip-sunrise))))
--8<---------------cut here---------------end--------------->8---

If you're feeling brave, you could disregard the docstring for
org-agenda-skip-function and bind the variable globally (i.e., invoke
my-org-skip-sunrise on all agenda commands), but I wouldn't recommend
this.

Hope this helps,
Matt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]