emacs-devel
[Top][All Lists]
Advanced

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

Re: calendar-goto-iso-week


From: Ed Reingold
Subject: Re: calendar-goto-iso-week
Date: Sat, 11 Sep 2004 20:16:33 -0500

> > 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?

I prefer what I had because it is consistent with the other "go-to" date 
functions.

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

I did not use that because on the ISO calendar it is Monday that is the first 
day of the week,; what is displayed is irrelevant--it is a matter of the ISO 
definition!

> 
> 
> (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."
>   (interactive
>    (let* ((today (calendar-current-date))
>           (year (if current-prefix-arg
>                     (calendar-read
>                      "ISO calendar year (>0): "
>                      '(lambda (x) (> x 0))
>                      (int-to-string (extract-calendar-year today)))
>                   (extract-calendar-year today)))
>           (no-weeks (extract-calendar-month
>                      (calendar-iso-from-absolute
>                       (1-
>                        (calendar-dayname-on-or-before
>                         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
>                        (calendar-absolute-from-iso
>                         (list week calendar-week-start-day year))))
>   (or noecho (calendar-print-iso-date)))
> 
> 
> 
> _______________________________________________
> Emacs-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-devel






reply via email to

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