From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: reingold@emr.cs.iit.edu (Edward M. Reingold) Newsgroups: gmane.emacs.help Subject: Re: Exception dates in diary? Date: 19 Jan 2008 18:17:31 -0600 Organization: Usenet @ UIUC - http://www.killfile.org/usenet/ Message-ID: <85ir1pnyec.fsf@emr.cs.iit.edu> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1200789644 7651 80.91.229.12 (20 Jan 2008 00:40:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Jan 2008 00:40:44 +0000 (UTC) Cc: ross@rosslaird.info To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 20 01:41:02 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JGOFA-00018X-8U for geh-help-gnu-emacs@m.gmane.org; Sun, 20 Jan 2008 01:41:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JGOEk-0001uh-W3 for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Jan 2008 19:40:35 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!news.ks.uiuc.edu!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 65 Original-NNTP-Posting-Host: emr.cs.iit.edu Original-X-Trace: news.ks.uiuc.edu 1200788254 9917 216.47.142.126 (20 Jan 2008 00:17:34 GMT) Original-X-Complaints-To: news+abuse@ks.uiuc.edu Original-NNTP-Posting-Date: Sun, 20 Jan 2008 00:17:34 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Original-Xref: shelby.stanford.edu gnu.emacs.help:155427 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:50831 Archived-At: >>>>> "RAL" == Ross A Laird writes: RAL> I teach a class on Monday nights, and there are sometimes holiday RAL> Mondays when we skip class. In my diary file, I have this for the RAL> class schedule (eg): RAL> %%(and (= 1 (calendar-day-of-week date)) (diary-block 01 07 2008 03 RAL> 10 2008)) 18:30-21:30 Class RAL> How do I modify this so that I can add the exception dates and have RAL> the calendar not show a class on a holiday? Here is what I use (to get the effect you want) for my recycling dates and payroll deposits; my diary has the entries &%%(recycling) Skokie recycling pickup &%%(let* ((month (extract-calendar-month date)) (day (extract-calendar-day date)) (year (extract-calendar-year date)) (last (calendar-last-day-of-month month year)) (dayname (calendar-day-of-week date))) (or (and (= day last) (memq dayname '(1 2 3 4 5))) (and (or (= day (1- last)) (= day (- last 2))) (= dayname 5)))) 8am Print IIT/NWU pay stubs and I have the following defined in my .emacs (this stuff could be in the diary file also, but then it would be redefined wach time the diary is examined): (defun h-days (year);; Holidays that defer recycling and paychecks (list (calendar-absolute-from-gregorian (list 1 1 year));; New Year (calendar-dayname-on-or-before 1;; Monday (calendar-absolute-from-gregorian (list 5 31 year)));; Memorial Day (calendar-absolute-from-gregorian (list 7 4 year));; July 4 (calendar-nth-named-absday 1 1 9 year);; Labor Day (calendar-nth-named-absday 4 4 11 year);; Thanksgiving (calendar-absolute-from-gregorian (list 12 31 year));; Christmas )) (defun recycle-date (d) ;; True if absolute date d should be a recycling date (let* ((diff (- d (calendar-absolute-from-gregorian (list 6 30 2003)))));; first recycyling pickup (and (>= diff 0) (zerop (% diff 14))))) (defun recycling () (let* ((month (extract-calendar-month date)) (day (extract-calendar-day date)) (year (extract-calendar-year date)) (a (calendar-absolute-from-gregorian date)) (h (h-days year))) (or (and (recycle-date a) (not (memq a h))) (and (recycle-date (1- a)) (memq (1- a) h))))) -- Professor Edward M. Reingold Email: reingold@iit.edu Department of Computer Science Voice: (312) 567-3309 Illinois Institute of Technology Fax: (312) 567-5067 Stuart Building, 228F 10 West 31st Street Chicago, IL 60616-3729 U.S.A.