diff options
author | Glenn Morris <rgm@gnu.org> | 2008-06-21 19:28:58 +0000 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2008-06-21 19:28:58 +0000 |
commit | 3eee90de6e9157dae8053f40006b6264ce5040cf (patch) | |
tree | f5a21f874e274e0bcfe474dacf638c741d9b8bfe /lisp/calendar/cal-move.el | |
parent | 0c74d40b024c2ae2ae94947cfb37cc9a4bbafb33 (diff) | |
download | emacs-3eee90de6e9157dae8053f40006b6264ce5040cf.tar.gz |
(calendar-forward-day): Scroll in one month increments.
(calendar-cursor-to-nearest-date): Use layout variables.
Use calendar-column-to-month.
(calendar-cursor-to-visible-date): Use layout variables.
Diffstat (limited to 'lisp/calendar/cal-move.el')
-rw-r--r-- | lisp/calendar/cal-move.el | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/lisp/calendar/cal-move.el b/lisp/calendar/cal-move.el index ec902c1da47..1a489d4577f 100644 --- a/lisp/calendar/cal-move.el +++ b/lisp/calendar/cal-move.el @@ -29,6 +29,7 @@ ;;; Code: +;; FIXME should calendar just require this? (require 'calendar) ;;;###cal-autoload @@ -38,20 +39,21 @@ The position of the cursor is unchanged if it is already on a date. Returns the list (month day year) giving the cursor position." (or (calendar-cursor-to-date) (let ((column (current-column))) - (when (> 3 (count-lines (point-min) (point))) - (goto-line 3) + (when (> calendar-first-date-row (count-lines (point-min) (point))) + (goto-line calendar-first-date-row) (move-to-column column)) - (if (not (looking-at "[0-9]")) - (if (and (not (looking-at " *$")) - (or (< column 25) - (and (> column 27) - (< column 50)) - (and (> column 52) - (< column 75)))) - (progn - (re-search-forward "[0-9]" nil t) - (backward-char 1)) - (re-search-backward "[0-9]" nil t))) + ;; FIXME the date positions are fixed and computable, + ;; but searching is probably more flexible. + ;; Note also that this may not be the "nearest" date. + ;; Eg with cursor just after end of month, can skip to next month. + (or (looking-at "[0-9]") + ;; We search forwards for a number, except close to the RH + ;; margin of a month, where we search backwards. + (if (or (looking-at " *$") + (< (calendar-column-to-month) 0)) + (re-search-backward "[0-9]" nil t) + (re-search-forward "[0-9]" nil t) + (backward-char 1))) (calendar-cursor-to-date)))) (defvar displayed-month) ; from calendar-generate @@ -63,21 +65,22 @@ Returns the list (month day year) giving the cursor position." (let ((month (calendar-extract-month date)) (day (calendar-extract-day date)) (year (calendar-extract-year date))) - (goto-line (+ 3 + (goto-line (+ calendar-first-date-row (/ (+ day -1 (mod (- (calendar-day-of-week (list month 1 year)) calendar-week-start-day) 7)) 7))) - (move-to-column (+ 6 - (* 25 + (move-to-column (+ calendar-left-margin (1- calendar-day-digit-width) + (* calendar-month-width (1+ (calendar-interval displayed-month displayed-year month year))) - (* 3 (mod - (- (calendar-day-of-week date) - calendar-week-start-day) - 7)))))) + (* calendar-column-width + (mod + (- (calendar-day-of-week date) + calendar-week-start-day) + 7)))))) ;;;###cal-autoload (defun calendar-goto-today () @@ -213,9 +216,13 @@ Moves backward if ARG is negative." (new-display-month (calendar-extract-month new-cursor-date)) (new-display-year (calendar-extract-year new-cursor-date))) ;; Put the new month on the screen, if needed, and go to the new date. - (if (not (calendar-date-is-visible-p new-cursor-date)) - (calendar-other-month new-display-month new-display-year)) - (calendar-cursor-to-visible-date new-cursor-date))) + (if (calendar-date-is-visible-p new-cursor-date) + (calendar-cursor-to-visible-date new-cursor-date) + ;; The next line gives smoother scrolling IMO (one month at a + ;; time rather than two). + (calendar-increment-month new-display-month new-display-year + (if (< arg 0) 1 -1)) + (calendar-other-month new-display-month new-display-year)))) (run-hooks 'calendar-move-hook)) ;;;###cal-autoload |