help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: diary sexp question


From: Edward M. Reingold
Subject: Re: diary sexp question
Date: 12 Dec 2005 20:31:45 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

>>>>> "b" == bxf4  <bxf4@yahoo.com> writes:

    b> Hello, First, I'm not very knowledgeable about emacs lisp, but I'm
    b> working on it.  I'm trying to create some weekly meetings (class times)
    b> in my diary and I'd like them to appear every TWThF through the end of
    b> the quarter.

There are some examples in the documentation, but none have all the bells and
whistles you ask for.  The following applies to the last weekday of the month:

&%%(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 pay stub

    b> I'd like a sexp that took the following arguments: - weekdays - times -
    b> range of dates for the appointments

The following example uses the time and date, along with an optional
parameter:

(defmacro squash (month day year time &optional court)
  (` (squash-internal (, month) (, day) (, year) (quote (, time)) (, court))))

(defun squash-internal (month day year time &optional court)
  "Squash date with court reservation the day before."
  (let* ((d (if european-calendar-style
                month
              day))
         (m (if european-calendar-style
                day
              month))
         (game-date (list m d year))
         (reservation-date
          (calendar-gregorian-from-absolute
           (- (calendar-absolute-from-gregorian game-date)
              (if (zerop (calendar-day-of-week game-date))
                  2 1))))
         (calendar-date-display-form '(month "/" day)))
    (if (calendar-date-equal date game-date)
        ;; Game on date
        (format "%s Squash (%s)" time entry)
      (if (and court (calendar-date-equal date reservation-date))
          ;; Reserve court the day before
          (format
           "8am Reserve court at SPAC (491-4300, option 4): %s %s"
           time
           (calendar-date-string game-date))))))

If you can be more specific about what you are trying to do, I can be of more
help.

-- 

Professor Edward M. Reingold                Email: reingold@iit.edu
Chairman, Department of Computer Science    Voice: (312) 567-3309
Illinois Institute of Technology            Assistant: (312) 567-5152
Stuart Building                             Fax:   (312) 567-5067
10 West 31st Street, Suite 236
Chicago, IL  60616-3729  U.S.A.


reply via email to

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