emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* conditionally setting org-agenda-files
@ 2008-04-26 11:34 Dan Griswold
  0 siblings, 0 replies; only message in thread
From: Dan Griswold @ 2008-04-26 11:34 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I have come up with the following snippet of elisp, which I designed
to include or exclude certain files in org-agenda-files based on the
week day and the time:

/----------------------------
;;; conditionally remove agendas based on time and day
(require 'tinylibm)
(setq nowday  (nth 4 (ti::date-time-elements)))
(setq nowtime  (nth 3 (ti::date-time-elements)))
(setq nowhour (nth 0 (split-string nowtime ":")))
(setq workfile "/home/dan/org/work.org")
(setq homefile "/home/dan/org/personal.org")

(when 
    (and (string< nowhour "17")
	 (or
	  (string= "Tue" nowday)
	  (string= "Wed" nowday)
	  (string= "Thu" nowday)
	  (string= "Fri" nowday)))
  (setq thisbuffer (buffer-name))
  (org-remove-file homefile)
  (find-file workfile)
  (org-agenda-file-to-front)
  (switch-to-buffer thisbuffer)
  )

(when 
    (and (string> nowhour "16")
	 (or
	  (string= "Tue" nowday)
	  (string= "Wed" nowday)
	  (string= "Thu" nowday)
	  (string= "Fri" nowday)))
  (setq thisbuffer (buffer-name))
  (org-remove-file workfile)
  (find-file homefile)
  (org-agenda-file-to-front )
  (switch-to-buffer thisbuffer)
  )

(when
    (or (string= "Sat" nowday)
	(string= "Sun" nowday))
  (setq thisbuffer (buffer-name))
  (find-file workfile)
  (org-agenda-file-to-front)
  (find-file homefile)
  (org-agenda-file-to-front )
  (switch-to-buffer thisbuffer)
  )

(when (string= "Mon" nowday)
  (setq thisbuffer (buffer-name))
  (org-remove-file workfile)
  (find-file homefile)
  (org-agenda-file-to-front)
  (switch-to-buffer thisbuffer)
  )

\----------------------------

Two things that are peculiar to my situation: I usually am working on
weekends, and Monday is my day off.

I welcome your comments and suggestions.

Peace,

Dan

-- 
--------------
Dan Griswold
Rochester, NY
--------------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-26 11:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-26 11:34 conditionally setting org-agenda-files Dan Griswold

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