[Top][All Lists]

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

Re: calendar-goto-iso-week

From: Emilio Lopes
Subject: Re: calendar-goto-iso-week
Date: Sat, 11 Sep 2004 11:43:17 +0200
User-agent: Emacs Gnus

Ed Reingold writes:

> I would add the following to cal-iso.el; this requires the
> user to hit return after the year, but allows movement
> more generally to other years:

It's my experience that one more often wants to move to a
week in the current year.  So I changed your code to only
ask for YEAR when called with a prefix argument.  What do
you think?

Also note the use of calendar-week-start-day bellow.

(defun calendar-goto-iso-week (week year &optional noecho)
  "Move cursor to start of ISO WEEK in YEAR; echo ISO date unless NOECHO is t.
Interactively asks for YEAR only when called with a prefix argument."
   (let* ((today (calendar-current-date))
          (year (if current-prefix-arg
                     "ISO calendar year (>0): "
                     '(lambda (x) (> x 0))
                     (int-to-string (extract-calendar-year today)))
                  (extract-calendar-year today)))
          (no-weeks (extract-calendar-month
                        1 (calendar-absolute-from-gregorian
                           (list 1 4 (1+ year))))))))
          (week (calendar-read
                 (format "ISO calendar week (1-%d): " no-weeks)
                 '(lambda (x) (and (> x 0) (<= x no-weeks))))))
     (list week year)))
  (calendar-goto-date (calendar-gregorian-from-absolute
                        (list week calendar-week-start-day year))))
  (or noecho (calendar-print-iso-date)))

reply via email to

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