Only in calendar: #calendar.el# diff -u calendar-orig/cal-move.el calendar/cal-move.el --- calendar-orig/cal-move.el Fri Sep 12 17:53:14 1997 +++ calendar/cal-move.el Fri Nov 5 04:51:30 1999 @@ -1,4 +1,4 @@ -;;; cal-move.el --- calendar functions for movement in the calendar +;;; Cal-move.el --- calendar functions for movement in the calendar ;; Copyright (C) 1995 Free Software Foundation, Inc. @@ -137,12 +137,17 @@ (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 + (or (< column 21) + (and (and (> column 21) + (< column 50)) + (>= calendar-months 2)) + ; don't count the third column if we are + ; only showing two + ;(and (and (> column (* calendar-width 2)) + ; (< column (* calendar-width 3))) + ; (eql column-width 2)))) + )) + (progn (re-search-forward "[0-9]" nil t) (backward-char 1)) (re-search-backward "[0-9]" nil t))) @@ -155,7 +160,7 @@ (if (/= 0 arg) (let* ((cursor-date (calendar-cursor-to-date)) - (cursor-date (if cursor-date + (cursor-date (if cursor-date cursor-date (if (> arg 0) (setq arg (1- arg))) (calendar-cursor-to-nearest-date))) @@ -165,9 +170,9 @@ (new-display-month (extract-calendar-month new-cursor-date)) (new-display-year (extract-calendar-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 (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)))) (defun calendar-backward-day (arg) "Move the cursor back ARG days. @@ -279,10 +284,12 @@ (defun calendar-cursor-to-visible-date (date) "Move the cursor to DATE that is on the screen." + (let* ((month (extract-calendar-month date)) (day (extract-calendar-day date)) (year (extract-calendar-year date)) (first-of-month-weekday (calendar-day-of-week (list month 1 year)))) + (goto-line (+ 3 (/ (+ day -1 (mod @@ -290,14 +297,24 @@ calendar-week-start-day) 7)) 7))) - (move-to-column (+ 6 - (* 25 - (1+ (calendar-interval - displayed-month displayed-year month year))) - (* 3 (mod - (- (calendar-day-of-week date) - calendar-week-start-day) - 7)))))) + + (if (>= calendar-months 2) + (move-to-column (+ 1 + (* 22 + (1+ (calendar-interval + displayed-month displayed-year month year))) + (* 3 (mod + (- (calendar-day-of-week date) + calendar-week-start-day) + 7))))) + (if (< calendar-months 2) + (move-to-column (+ 1 + (* 3 (mod + (- (calendar-day-of-week date) + calendar-week-start-day) + 7))))) + )) + (defun calendar-goto-date (date) "Move cursor to DATE." @@ -315,3 +332,4 @@ (provide 'cal-move) ;;; cal-move.el ends here + diff -u calendar-orig/calendar.el calendar/calendar.el --- calendar-orig/calendar.el Wed Nov 3 20:56:49 1999 +++ calendar/calendar.el Sat Nov 6 13:19:34 1999 @@ -19,6 +19,7 @@ ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. + ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, @@ -93,6 +94,10 @@ ;;; Code: +(defconst calendar-width 22) + + + (defun calendar-version () (interactive) (message "Version 6, October 12, 1995")) @@ -131,14 +136,21 @@ ;;;###autoload +(defcustom calendar-months 1 + "1 means 1 month is displayed at a time up to 3 where 3 are displayed at +a time." + :type 'integer + :group 'calendar) + (defcustom calendar-week-start-day 0 "*The day of the week on which a week in the calendar begins. 0 means Sunday (default), 1 means Monday, and so on." :type 'integer :group 'calendar) + ;;;###autoload -(defcustom calendar-offset 0 +(defcustom calendar-offset -1 "*The offset of the principal month from the center of the calendar window. 0 means the principal month is in the center (default), -1 means on the left, +1 means on the right. Larger (or smaller) values push the principal month off @@ -1395,7 +1407,10 @@ (month (extract-calendar-month date)) (year (extract-calendar-year date))) (pop-to-buffer calendar-buffer) - (increment-calendar-month month year (- calendar-offset)) + (increment-calendar-month month year + (cond ((= calendar-months 1) 1) + (t 0))) + ; (- calendar-offset)) (generate-calendar-window month year) (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) (view-diary-entries @@ -1749,10 +1764,9 @@ (month (extract-calendar-month today)) (day (extract-calendar-day today)) (year (extract-calendar-year today)) - (today-visible - (or (not mon) - (let ((offset (calendar-interval mon yr month year))) - (and (<= offset 1) (>= offset -1))))) + (today-visible (or (not mon) + (let ((offset (calendar-interval mon yr month year))) + (and (<= offset 1) (>= offset -1))))) (day-in-week (calendar-day-of-week today))) (update-calendar-mode-line) (if mon @@ -1780,11 +1794,14 @@ (error "Months before February, 1 AD are not available.")) (setq displayed-month month) (setq displayed-year year) + + (erase-buffer) (increment-calendar-month month year -1) - (calendar-for-loop i from 0 to 2 do - (generate-calendar-month month year (+ 5 (* 25 i))) - (increment-calendar-month month year 1))) + (calendar-for-loop i from 0 to (- calendar-months 1) do + (generate-calendar-month month year (+ 0 (* calendar-width i))) + (increment-calendar-month month year 1)) + ) (defun generate-calendar-month (month year indent) "Produce a calendar for MONTH, YEAR on the Gregorian calendar. @@ -2139,7 +2156,7 @@ "Returns a list (month day year) of current cursor position. If cursor is not on a specific date, signals an error if optional parameter ERROR is t, otherwise just returns nil." - (let* ((segment (/ (current-column) 25)) + (let* ((segment (/ (current-column) calendar-width)) (month (% (+ displayed-month segment -1) 12)) (month (if (= 0 month) 12 month)) (year @@ -2218,11 +2235,15 @@ (defun calendar-other-month (month year) "Display a three-month calendar centered around MONTH and YEAR." (interactive (calendar-read-date 'noday)) - (if (and (= month displayed-month) + (if (and (= (- month (cond ((= calendar-months 1) 1) + (t 0))) displayed-month) (= year displayed-year)) nil (let ((old-date (calendar-cursor-to-date)) (today (calendar-current-date))) + (increment-calendar-month month year + (cond ((= calendar-months 1) 1) + (t 0))) (generate-calendar-window month year) (calendar-cursor-to-visible-date (cond @@ -2378,12 +2399,29 @@ (setq mark-diary-entries-in-calendar nil) (redraw-calendar)) + +;;; CAUTION KLUDGE THERE IS A MAJOR HACK IN THIS FUNCTION TO ALLOW FOR +;;; SINGLE COLUMN (1 calendar) DISPLAY SINCE THIS WAS PRIMARLY +;;; DESIGNED TO DO 3, AND TWO WORKS ALRIGHT BY LUCK +;;; IT SHOULD NOT AFFECT 2 AND 3 COLUMNS !!! +;;; THIS FUNCTION DOES THINGS THE CALLER MIGHT NOT EXPECT +;;; UNDER ITS NOSE TO FIX IT UP +;;; SEE ALSO (other-month) (defun calendar-date-is-visible-p (date) "Returns t if DATE is legal and is visible in the calendar window." (let ((gap (calendar-interval - displayed-month displayed-year - (extract-calendar-month date) (extract-calendar-year date)))) - (and (calendar-date-is-legal-p date) (> 2 gap) (< -2 gap)))) + displayed-month displayed-year + (extract-calendar-month date) (extract-calendar-year date))) + (left-gap (cond ((eq calendar-months 3) -2) + ((eq calendar-months 2) -2))) + (right-gap (cond ((eq calendar-months 3) 2) + ((eq calendar-months 2) 1))) + ) + (if (> calendar-months 1) + (and (calendar-date-is-legal-p date) + (> right-gap gap) + (< left-gap gap)) + (= gap -1)))) (defun calendar-date-is-legal-p (date) "Returns t if DATE is a legal date." Only in calendar: calendar.el~ diff -u calendar-orig/diary-lib.el calendar/diary-lib.el --- calendar-orig/diary-lib.el Fri Jul 3 17:05:33 1998 +++ calendar/diary-lib.el Sun Nov 7 02:37:27 1999 @@ -684,7 +684,7 @@ (if (file-readable-p d-file) (save-excursion (message "Marking diary entries...") - (set-buffer (find-file-noselect d-file t)) + (set-buffer (find-file-noselect d-file t)) (let ((d diary-date-forms) (old-diary-syntax-table)) (setq old-diary-syntax-table (syntax-table)) @@ -763,7 +763,7 @@ (+ y 100) y))) (string-to-int y-str))))) - (if dd-name + (if dd-name (mark-calendar-days-named (cdr (assoc (capitalize (substring dd-name 0 3)) (calendar-make-alist @@ -771,7 +771,7 @@ 0 '(lambda (x) (substring x 0 3)))))) (if mm-name - (if (string-equal mm-name "*") + (if (string-equal mm-name "*") (setq mm 0) (setq mm (cdr (assoc @@ -915,9 +915,9 @@ (let ((m displayed-month) (y displayed-year)) (increment-calendar-month m y -1) - (calendar-for-loop i from 0 to 2 do - (mark-calendar-month m y month day year) - (increment-calendar-month m y 1))))) + (calendar-for-loop i from 0 to (- calendar-months 1) do + (mark-calendar-month m y month day year) + (increment-calendar-month m y 1))))) (defun mark-calendar-month (month year p-month p-day p-year) "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR. Only in calendar-orig/: diary-lib.elc Only in calendar: diary-lib.el~