emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Sunrise / Sunset in Agenda View only for Current Day?
@ 2010-10-27 16:49 Raymond Zeitler
  2010-11-04  0:43 ` Matt Lundin
  0 siblings, 1 reply; 3+ messages in thread
From: Raymond Zeitler @ 2010-10-27 16:49 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: 'Raymond Zeitler'

Hi

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)


Here's an example of the "C-c a a" seven-day agenda view for October 27,
2010.  This is what I'd like to achieve if it's not too difficult.  (I
replaced the ends of long entries with "ETC." to prevent wrapping):

Week-agenda (W43-W44):
Wednesday  27 October 2010
  Sunrise:     7:09...... Sunrise (EDT), sunset 5:51pm (EDT) ETC.
               8:00...... ----------------
              10:00...... ----------------
              12:00...... ----------------
              14:00...... ----------------
              16:00...... ----------------
              18:00...... ----------------
              20:00...... ----------------
  Tasks:      Sched. 5x:  STARTED Prog1 -- document in PPT   ETC.
  Tasks:      Sched. 2x:  WAITING Revise CustomerA TUNE.CMD  ETC.
  Tasks:      Sched. 2x:  STARTED Revise CustomerB probe     ETC.
  Tasks:      Sched. 2x:  TODO Revise CustomerB traveler to  ETC.
  Day/Year:   Day 300 of 2010; 65 days remaining in the year
Thursday   28 October 2010
Friday     29 October 2010
Saturday   30 October 2010
Sunday     31 October 2010
Monday      1 November 2010 W44
Tuesday     2 November 2010



Incidentally, I've based my setup on John Wiegley's 1997 tutorial.

 http://www.newartisans.com/2007/08/using-org-mode-as-a-day-planner.html

- Ray

--
Raymond Zeitler <r.zeitler@ieee.org> 

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

* Re: Sunrise / Sunset in Agenda View only for Current Day?
  2010-10-27 16:49 Sunrise / Sunset in Agenda View only for Current Day? Raymond Zeitler
@ 2010-11-04  0:43 ` Matt Lundin
  2010-11-24 22:12   ` Raymond Zeitler
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Lundin @ 2010-11-04  0:43 UTC (permalink / raw)
  To: Raymond Zeitler; +Cc: emacs-orgmode

"Raymond Zeitler" <r.zeitler@ieee.org> 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

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

* Re: Sunrise / Sunset in Agenda View only for Current Day?
  2010-11-04  0:43 ` Matt Lundin
@ 2010-11-24 22:12   ` Raymond Zeitler
  0 siblings, 0 replies; 3+ messages in thread
From: Raymond Zeitler @ 2010-11-24 22:12 UTC (permalink / raw)
  To: 'Matt Lundin'; +Cc: emacs-orgmode

This worked wonderfully!  Thanks!

I decided to combine the &%%(diary-day-of-year) into the same category with
&%%(diary-sunrise-sunset).

My setup is shown on Emacs wiki:

http://www.emacswiki.org/emacs/RaymondZeitler

All the best!

--
Raymond Zeitler <r.zeitler@ieee.org> 


-----Original Message-----
From: Matt Lundin [mailto:mdl@imapmail.org] 
Sent: Wednesday, November 03, 2010 8:44 PM
To: Raymond Zeitler
Cc: emacs-orgmode@gnu.org
Subject: Re: Sunrise / Sunset in Agenda View only for Current Day?

"Raymond Zeitler" <r.zeitler@ieee.org> 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

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

end of thread, other threads:[~2010-11-24 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-27 16:49 Sunrise / Sunset in Agenda View only for Current Day? Raymond Zeitler
2010-11-04  0:43 ` Matt Lundin
2010-11-24 22:12   ` Raymond Zeitler

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