Mercurial > emacs
comparison lisp/calendar/calendar.el @ 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 | 4e21455e4410 |
children | 4d4a9542d49c |
comparison
equal
deleted
inserted
replaced
93448:9d52e0832665 | 93449:64521597b7dd |
---|---|
1214 "Name of the buffer used by `list-yahrzeit-dates'.") | 1214 "Name of the buffer used by `list-yahrzeit-dates'.") |
1215 | 1215 |
1216 (defmacro increment-calendar-month (mon yr n) | 1216 (defmacro increment-calendar-month (mon yr n) |
1217 "Increment the variables MON and YR by N months. | 1217 "Increment the variables MON and YR by N months. |
1218 Forward if N is positive or backward if N is negative. | 1218 Forward if N is positive or backward if N is negative. |
1219 A negative YR is interpreted as BC; -1 being 1 BC, and so on." | 1219 A negative YR is interpreted as BC; -1 being 1 BC, and so on. |
1220 This is only appropriate for calendars with 12 months per year." | |
1220 `(let (macro-y) | 1221 `(let (macro-y) |
1222 ;; FIXME 12 could be an optional arg, if needed. | |
1221 (if (< ,yr 0) (setq ,yr (1+ ,yr))) ; -1 BC -> 0 AD, etc | 1223 (if (< ,yr 0) (setq ,yr (1+ ,yr))) ; -1 BC -> 0 AD, etc |
1222 (setq macro-y (+ (* ,yr 12) ,mon -1 ,n) | 1224 (setq macro-y (+ (* ,yr 12) ,mon -1 ,n) |
1223 ,mon (1+ (mod macro-y 12)) | 1225 ,mon (1+ (mod macro-y 12)) |
1224 ,yr (/ macro-y 12)) | 1226 ,yr (/ macro-y 12)) |
1227 ;;; (setq macro-y (+ (* ,yr 12) ,mon -1 ,n) | |
1228 ;;; ,yr (/ macro-y 12) | |
1229 ;;; ,mon (- macro-y (* ,yr 12))) | |
1225 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) | 1230 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) |
1226 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc | 1231 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc |
1227 | 1232 |
1228 (defvar displayed-month) | 1233 (defvar displayed-month) |
1229 (defvar displayed-year) | 1234 (defvar displayed-year) |
1255 (while ,condition | 1260 (while ,condition |
1256 (setq sum (+ sum ,expression) | 1261 (setq sum (+ sum ,expression) |
1257 ,index (1+ ,index))) | 1262 ,index (1+ ,index))) |
1258 sum)) | 1263 sum)) |
1259 | 1264 |
1265 ;; FIXME bind q to bury-buffer? | |
1260 (defmacro calendar-in-read-only-buffer (buffer &rest body) | 1266 (defmacro calendar-in-read-only-buffer (buffer &rest body) |
1261 "Switch to BUFFER and executes the forms in BODY. | 1267 "Switch to BUFFER and executes the forms in BODY. |
1262 First creates or erases BUFFER as needed. Leaves BUFFER read-only, | 1268 First creates or erases BUFFER as needed. Leaves BUFFER read-only, |
1263 with disabled undo. Leaves point at point-min, displays BUFFER." | 1269 with disabled undo. Leaves point at point-min, displays BUFFER." |
1264 (declare (indent 1) (debug t)) | 1270 (declare (indent 1) (debug t)) |
2308 (setq mark-holidays-in-calendar nil | 2314 (setq mark-holidays-in-calendar nil |
2309 mark-diary-entries-in-calendar nil) | 2315 mark-diary-entries-in-calendar nil) |
2310 (redraw-calendar)) | 2316 (redraw-calendar)) |
2311 | 2317 |
2312 (defun calendar-date-is-visible-p (date) | 2318 (defun calendar-date-is-visible-p (date) |
2313 "Return t if DATE is valid and is visible in the calendar window." | 2319 "Return non-nil if DATE is valid and is visible in the calendar window." |
2314 (let ((gap (calendar-interval | 2320 (and (calendar-date-is-valid-p date) |
2315 displayed-month displayed-year | 2321 (< (abs (calendar-interval |
2316 (extract-calendar-month date) (extract-calendar-year date)))) | 2322 displayed-month displayed-year |
2317 (and (calendar-date-is-valid-p date) (> 2 gap) (< -2 gap)))) | 2323 (extract-calendar-month date) (extract-calendar-year date))) |
2324 2))) | |
2318 | 2325 |
2319 (defun calendar-date-is-valid-p (date) | 2326 (defun calendar-date-is-valid-p (date) |
2320 "Return t if DATE is a valid date." | 2327 "Return t if DATE is a valid date." |
2321 (let ((month (extract-calendar-month date)) | 2328 (let ((month (extract-calendar-month date)) |
2322 (day (extract-calendar-day date)) | 2329 (day (extract-calendar-day date)) |