changeset 93449:64521597b7dd

(increment-calendar-month): Doc fix. (calendar-date-is-visible-p): Doc fix. Simplify.
author Glenn Morris <rgm@gnu.org>
date Mon, 31 Mar 2008 07:10:20 +0000
parents 9d52e0832665
children 965ede514c5a
files lisp/calendar/calendar.el
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/calendar.el	Mon Mar 31 07:08:38 2008 +0000
+++ b/lisp/calendar/calendar.el	Mon Mar 31 07:10:20 2008 +0000
@@ -1216,12 +1216,17 @@
 (defmacro increment-calendar-month (mon yr n)
   "Increment the variables MON and YR by N months.
 Forward if N is positive or backward if N is negative.
-A negative YR is interpreted as BC; -1 being 1 BC, and so on."
+A negative YR is interpreted as BC; -1 being 1 BC, and so on.
+This is only appropriate for calendars with 12 months per year."
   `(let (macro-y)
+     ;; FIXME 12 could be an optional arg, if needed.
      (if (< ,yr 0) (setq ,yr (1+ ,yr))) ; -1 BC -> 0 AD, etc
      (setq macro-y (+ (* ,yr 12) ,mon -1 ,n)
            ,mon (1+ (mod macro-y 12))
            ,yr (/ macro-y 12))
+;;;      (setq macro-y (+ (* ,yr 12) ,mon -1 ,n)
+;;;            ,yr (/ macro-y 12)
+;;;            ,mon (- macro-y (* ,yr 12)))
      (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr)))
      (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc
 
@@ -1257,6 +1262,7 @@
             ,index (1+ ,index)))
     sum))
 
+;; FIXME bind q to bury-buffer?
 (defmacro calendar-in-read-only-buffer (buffer &rest body)
   "Switch to BUFFER and executes the forms in BODY.
 First creates or erases BUFFER as needed.  Leaves BUFFER read-only,
@@ -2310,11 +2316,12 @@
   (redraw-calendar))
 
 (defun calendar-date-is-visible-p (date)
-  "Return t if DATE is valid 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-valid-p date) (> 2 gap) (< -2 gap))))
+  "Return non-nil if DATE is valid and is visible in the calendar window."
+  (and (calendar-date-is-valid-p date)
+       (< (abs (calendar-interval
+                displayed-month displayed-year
+                (extract-calendar-month date) (extract-calendar-year date)))
+          2)))
 
 (defun calendar-date-is-valid-p (date)
   "Return t if DATE is a valid date."