all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* diary sexp question
@ 2005-12-13  1:19 bxf4
  2005-12-13  2:31 ` Edward M. Reingold
  0 siblings, 1 reply; 7+ messages in thread
From: bxf4 @ 2005-12-13  1:19 UTC (permalink / raw)


Hello,

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

I started with code from the info manual and tried to get the entry to
show up on particular days of the week, without limiting to a certain
time period.  It didn't work, though.

&%%(let (dayname (calendar-day-of-week date))
      (or (memq dayname '(2 4))
          (memq dayname '(3 5)))) 13:30--14:20 Psych 315

I was also trying to put the entry on particular days of the month,
but I don't think that was working either.
&%%(let (day (car (cdr date)))
      (or (= day 22)
          (= day 25))) print success

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

I'd appreciate anyone pointing me in the right direction, or just
giving me the sexp (since I bet it's pretty easy for people who know
how they work).  Thank you for your time and help.




-- 
Brian P. Flaherty
Department of Psychology
University of Washington
Contact and other information at:
http://faculty.washington.edu/bxf4/index.shtml

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

* Re: diary sexp question
  2005-12-13  1:19 diary sexp question bxf4
@ 2005-12-13  2:31 ` Edward M. Reingold
  2005-12-14  7:27   ` bxf4
  0 siblings, 1 reply; 7+ messages in thread
From: Edward M. Reingold @ 2005-12-13  2:31 UTC (permalink / raw)
  Cc: bxf4

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

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

* Re: diary sexp question
  2005-12-13  2:31 ` Edward M. Reingold
@ 2005-12-14  7:27   ` bxf4
  2005-12-14 21:00     ` Edward M. Reingold
  0 siblings, 1 reply; 7+ messages in thread
From: bxf4 @ 2005-12-14  7:27 UTC (permalink / raw)


reingold@emr.cs.iit.edu (Edward M. Reingold) writes:

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

Hello and thank you for your response.  I've only had time to read
your functions once, but I'll try to look at them more closely soon.

Here are concrete examples of what I'm trying to do.  (Sorry for the
lack of specificity in the previous message.)

- I'll be teaching a course in the Winter quarter.  The course meets
  every Tue., Wed., Thurs., and Fri. from 1:30 to 2:20.  On Tues. and
  Thurs. I'm in one building, and on Wed. and Fri. another.  I'd like
  the entries to only show up during the quarter, and I'd like to get
  the building correct each day.  I don't want to just say that
  "Tues. I teach in Building 1" because it shows up every
  Tues. forever.  I was thinking something like this:

if today is in date_range and
   if today is Tues or Thurs then 1:30--2:20 teach Bldg 1
   else if today is Wed or Fri then 1:30--2:20 teach Bldg 7

- Another example is a weekly seminar that only meets during the
  quarter.

if today is in date_range and
   if today is Friday then 12:00 brown-bag seminar

This is where I was trying to go with my attempt at doctoring the
examples in the info file.  Thank you again.  I'll try to look at your
functions tomorrow.

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

* Re: diary sexp question
  2005-12-14  7:27   ` bxf4
@ 2005-12-14 21:00     ` Edward M. Reingold
  2005-12-15  8:13       ` bxf4
  0 siblings, 1 reply; 7+ messages in thread
From: Edward M. Reingold @ 2005-12-14 21:00 UTC (permalink / raw)
  Cc: bxf4

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

    b> if today is in date_range and if today is Tues or Thurs then 1:30--2:20
    b> teach Bldg 1 else if today is Wed or Fri then 1:30--2:20 teach Bldg 7

I would use

&%%(let ((dayname (calendar-day-of-week date))
         (day (extract-calendar-day date)))
     (and (memq dayname '(2 4))
          (diary-block 1 23 2006 5 8 2006))) 1:30pm-2:20pm teach Bldg 1

&%%(let ((dayname (calendar-day-of-week date))
         (day (extract-calendar-day date)))
     (and (memq dayname '(3 5))
          (diary-block 1 23 2006 5 8 2006))) 1:30pm-2:20pm teach Bldg 7

Combining these into a single entry makes it more confusing, not simpler.

    b> if today is in date_range and if today is Friday then 12:00 brown-bag
    b> seminar

Similarly, I'd use

&%%(let ((dayname (calendar-day-of-week date))
         (day (extract-calendar-day date)))
     (and (= dayname 5)
          (diary-block 1 23 2006 5 8 2006))) 12pm brown-bag seminar

If you use the definition of the quarter very often, you write this as

&%%(progn (defun this-quarter () (diary-block 1 23 2006 5 8 2006)) nil)

&%%(let ((dayname (calendar-day-of-week date))
         (day (extract-calendar-day date)))
     (and (memq dayname '(2 4)) (this-quarter))) 1:30pm--2:20pm teach Bldg 1

&%%(let ((dayname (calendar-day-of-week date))
         (day (extract-calendar-day date)))
     (and (memq dayname '(3 5)) (this-quarter))) 1:30pm--2:20pm teach Bldg 7


-- 

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.

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

* Re: diary sexp question
  2005-12-14 21:00     ` Edward M. Reingold
@ 2005-12-15  8:13       ` bxf4
  2005-12-15  8:46         ` bxf4
  2005-12-15 19:30         ` Edward M. Reingold
  0 siblings, 2 replies; 7+ messages in thread
From: bxf4 @ 2005-12-15  8:13 UTC (permalink / raw)


reingold@emr.cs.iit.edu (Edward M. Reingold) writes:

> I would use
>
> &%%(let ((dayname (calendar-day-of-week date))
>          (day (extract-calendar-day date)))
>      (and (memq dayname '(2 4))
>           (diary-block 1 23 2006 5 8 2006))) 1:30pm-2:20pm teach Bldg 1

Thank you very much for the functions.  They work quite well.

If I do this,

&%%(progn (defun fall-quarter () (diary-block 9 27 2006 12 8 2006)) nil)
&%%(progn (defun winter-quarter () (diary-block 1 3 2006 3 10 2006)) nil)
&%%(progn (defun spring-quarter () (diary-block 3 27 2006 6 2 2006)) nil)

how can I form the union of those three diary-blocks?  I tried 'or' and
'cons', but I'm sure I was doing it incorrectly.  I tried looking over
the emacslisp-intro and emacs-lisp reference, but 'or' is a pretty
common word.  I was after something like this:

&%%(let ((dayname (calendar-day-of-week date))
     (day (extract-calendar-day date)))
    (and (memq dayname '(4)) 
     (or fall-quarter winter-quarter spring-quarter))) 15:30 faculty meeting

Thank you again.  If I've worn out my welcome, please disregard this.
You've already helped me greatly.

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

* Re: diary sexp question
  2005-12-15  8:13       ` bxf4
@ 2005-12-15  8:46         ` bxf4
  2005-12-15 19:30         ` Edward M. Reingold
  1 sibling, 0 replies; 7+ messages in thread
From: bxf4 @ 2005-12-15  8:46 UTC (permalink / raw)


bxf4@yahoo.com writes:

> I was after something like this:
>
> &%%(let ((dayname (calendar-day-of-week date))
>      (day (extract-calendar-day date)))
>     (and (memq dayname '(4)) 
>      (or fall-quarter winter-quarter spring-quarter))) 15:30 faculty
>      meeting

Well, after posting this, it occurred to me to try adding parentheses
around the 'or' terms.  It appears to have worked.

&%%(let ((dayname (calendar-day-of-week date))
        (day (extract-calendar-day date)))
      (and (memq dayname '(4)) 
           (or (fall-quarter) (winter-quarter) (spring-quarter)))) 15:30 ...

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

* Re: diary sexp question
  2005-12-15  8:13       ` bxf4
  2005-12-15  8:46         ` bxf4
@ 2005-12-15 19:30         ` Edward M. Reingold
  1 sibling, 0 replies; 7+ messages in thread
From: Edward M. Reingold @ 2005-12-15 19:30 UTC (permalink / raw)
  Cc: bxf4

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


    b> If I do this,

    b> &%%(progn (defun fall-quarter () (diary-block 9 27 2006 12 8 2006))
    b> nil) &%%(progn (defun winter-quarter () (diary-block 1 3 2006 3 10
    b> 2006)) nil) &%%(progn (defun spring-quarter () (diary-block 3 27 2006 6
    b> 2 2006)) nil)

    b> how can I form the union of those three diary-blocks?

You can put all of those defuns in one progn:

&%%(progn (defun fall-quarter () (diary-block 9 27 2006 12 8 2006))
          (defun winter-quarter () (diary-block 1 3 2006 3 10 2006))
          (defun spring-quarter () (diary-block 3 27 2006 6 2 2006)) nil)

Then you can have a diary entry

&%%(or (fall-quarter) (winter-quarter) (spring-quarter)) Blah blah

-- 

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.

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

end of thread, other threads:[~2005-12-15 19:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-13  1:19 diary sexp question bxf4
2005-12-13  2:31 ` Edward M. Reingold
2005-12-14  7:27   ` bxf4
2005-12-14 21:00     ` Edward M. Reingold
2005-12-15  8:13       ` bxf4
2005-12-15  8:46         ` bxf4
2005-12-15 19:30         ` Edward M. Reingold

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.