[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patches to calendar
From: |
Glenn Morris |
Subject: |
Re: Patches to calendar |
Date: |
Tue, 28 Sep 2004 18:48:36 +0100 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
"Emilio C. Lopes" wrote:
> Here is the "refactored" code:
Thanks for that. What do you think of this version?
Index: cal-iso.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/cal-iso.el,v
retrieving revision 1.6
diff -c -w -c -r1.6 cal-iso.el
*** cal-iso.el 1 Sep 2003 15:45:19 -0000 1.6
--- cal-iso.el 28 Sep 2004 17:43:37 -0000
***************
*** 96,104 ****
(message "ISO date: %s"
(calendar-iso-date-string (calendar-cursor-to-date t))))
! (defun calendar-goto-iso-date (date &optional noecho)
! "Move cursor to ISO DATE; echo ISO date unless NOECHO is t."
! (interactive
(let* ((today (calendar-current-date))
(year (calendar-read
"ISO calendar year (>0): "
--- 96,103 ----
(message "ISO date: %s"
(calendar-iso-date-string (calendar-cursor-to-date t))))
! (defun calendar-iso-read-args (&optional dayflag)
! "Interactively read the arguments for an iso date command."
(let* ((today (calendar-current-date))
(year (calendar-read
"ISO calendar year (>0): "
***************
*** 113,122 ****
(week (calendar-read
(format "ISO calendar week (1-%d): " no-weeks)
'(lambda (x) (and (> x 0) (<= x no-weeks)))))
! (day (calendar-read
"ISO day (1-7): "
! '(lambda (x) (and (<= 1 x) (<= x 7))))))
(list (list week day year))))
(calendar-goto-date (calendar-gregorian-from-absolute
(calendar-absolute-from-iso date)))
(or noecho (calendar-print-iso-date)))
--- 112,134 ----
(week (calendar-read
(format "ISO calendar week (1-%d): " no-weeks)
'(lambda (x) (and (> x 0) (<= x no-weeks)))))
! (day (if dayflag (calendar-read
"ISO day (1-7): "
! '(lambda (x) (and (<= 1 x) (<= x 7))))
! 1)))
(list (list week day year))))
+
+ (defun calendar-goto-iso-date (date &optional noecho)
+ "Move cursor to ISO DATE; echo ISO date unless NOECHO is t."
+ (interactive (calendar-iso-read-args t))
+ (calendar-goto-date (calendar-gregorian-from-absolute
+ (calendar-absolute-from-iso date)))
+ (or noecho (calendar-print-iso-date)))
+
+ (defun calendar-goto-iso-week (date &optional noecho)
+ "Move cursor to ISO DATE; echo ISO date unless NOECHO is t.
+ Interactively, goes to the first day of the specified week."
+ (interactive (calendar-iso-read-args))
(calendar-goto-date (calendar-gregorian-from-absolute
(calendar-absolute-from-iso date)))
(or noecho (calendar-print-iso-date)))
Re: Patches to calendar, Glenn Morris, 2004/09/20
Re: Patches to calendar, Emilio C . Lopes, 2004/09/21