[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
calendar-[beginning/end]-of-year bugged
From: |
Chong Yidong |
Subject: |
calendar-[beginning/end]-of-year bugged |
Date: |
Sun, 27 Feb 2005 01:03:29 -0500 (EST) |
User-agent: |
SquirrelMail/1.4.4 |
calendar-beginning-of-year and calendar-end-of-year are buggy. For example:
1. M-x calendar (Suppose it is February 27 2005)
2. M-> (Moves cursor to December 31 2005)
3. M-< (Moves cursor back to February 27 2005)
Expected behavior: move cursor to January 1 2005.
1. M-x calendar (Suppose it is February 27 2005)
2. C-u 2 M-> (Moves cursor to December 2004)
Expected behavior: move cursor to December 2006
I have re-written the relevant functions to be correct. Here is the patch:
*** emacs/lisp/calendar/cal-move.el~ Mon Sep 1 23:45:19 2003
--- emacs/lisp/calendar/cal-move.el Sun Feb 27 13:52:35 2005
***************
*** 257,294 ****
(defun calendar-beginning-of-year (arg)
"Move the cursor backward ARG year beginnings."
(interactive "p")
! (calendar-cursor-to-nearest-date)
! (let* ((date (calendar-cursor-to-date))
! (month (extract-calendar-month date))
! (day (extract-calendar-day date))
! (year (extract-calendar-year date))
! (jan-first (list 1 1 year))
(calendar-move-hook nil))
! (if (and (= day 1) (= 1 month))
! (calendar-backward-month (* 12 arg))
! (if (and (= arg 1)
! (calendar-date-is-visible-p jan-first))
! (calendar-cursor-to-visible-date jan-first)
! (calendar-other-month 1 (- year (1- arg))))))
(run-hooks 'calendar-move-hook))
(defun calendar-end-of-year (arg)
"Move the cursor forward ARG year beginnings."
(interactive "p")
! (calendar-cursor-to-nearest-date)
! (let* ((date (calendar-cursor-to-date))
! (month (extract-calendar-month date))
! (day (extract-calendar-day date))
! (year (extract-calendar-year date))
! (dec-31 (list 12 31 year))
(calendar-move-hook nil))
! (if (and (= day 31) (= 12 month))
! (calendar-forward-month (* 12 arg))
! (if (and (= arg 1)
! (calendar-date-is-visible-p dec-31))
! (calendar-cursor-to-visible-date dec-31)
! (calendar-other-month 12 (- year (1- arg)))
! (calendar-cursor-to-visible-date (list 12 31 displayed-year)))))
(run-hooks 'calendar-move-hook))
(defun calendar-cursor-to-visible-date (date)
--- 257,287 ----
(defun calendar-beginning-of-year (arg)
"Move the cursor backward ARG year beginnings."
(interactive "p")
! (let* ((cursor-date (calendar-cursor-to-nearest-date))
! (target-year (- (extract-calendar-year cursor-date) (1- arg)))
! (target-date (list 1 1 target-year))
(calendar-move-hook nil))
! (if (and (= (extract-calendar-day cursor-date) 1)
! (= (extract-calendar-month cursor-date) 1))
! (calendar-backward-year arg)
! (if (not (calendar-date-is-visible-p target-date))
! (calendar-other-month 1 target-year))
! (calendar-cursor-to-visible-date target-date)))
(run-hooks 'calendar-move-hook))
(defun calendar-end-of-year (arg)
"Move the cursor forward ARG year beginnings."
(interactive "p")
! (let* ((cursor-date (calendar-cursor-to-nearest-date))
! (target-year (+ (extract-calendar-year cursor-date) (1- arg)))
! (target-date (list 12 31 target-year))
(calendar-move-hook nil))
! (if (and (= (extract-calendar-day cursor-date) 31)
! (= (extract-calendar-month cursor-date) 12))
! (calendar-forward-year arg)
! (if (not (calendar-date-is-visible-p target-date))
! (calendar-other-month 12 target-year))
! (calendar-cursor-to-visible-date target-date)))
(run-hooks 'calendar-move-hook))
(defun calendar-cursor-to-visible-date (date)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- calendar-[beginning/end]-of-year bugged,
Chong Yidong <=