emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Raymond Zeitler" <r.zeitler@ieee.org>
To: 'Matt Lundin' <mdl@imapmail.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Sunrise / Sunset in Agenda View only for Current Day?
Date: Wed, 24 Nov 2010 17:12:33 -0500	[thread overview]
Message-ID: <FAF41162FEC948E9B187F134B36F7FBB@PHONON.COM> (raw)
In-Reply-To: <87wrotzzno.fsf@fastmail.fm>

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

      reply	other threads:[~2010-11-24 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FAF41162FEC948E9B187F134B36F7FBB@PHONON.COM \
    --to=r.zeitler@ieee.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=mdl@imapmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).