Mercurial > emacs
comparison lisp/calendar/calendar.el @ 93026:8e1a78482251
(calendar-today-marker, initial-calendar-window-hook)
(today-visible-calendar-hook, today-invisible-calendar-hook)
(diary-file, calendar-basic-setup, calendar-star-date)
(calendar-mark-today): Doc fixes.
(today-visible-calendar-hook): Add options.
(calendar-in-read-only-buffer): New macro.
(calendar-basic-setup): Adapt for change in calendar-read-date.
Place holiday let inside if.
(calendar-day-name-array, calendar-month-name-array): Make defcustoms.
(calendar-read-date): Set day to 1 rather than nil in the NODAY case.
(calendar-print-other-dates): Use one let rather than many.
Use calendar-in-read-only-buffer to replace previous code and disable undo.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 17 Mar 2008 02:30:06 +0000 |
parents | 189ca7ef805d |
children | 0e73f340ef25 |
comparison
equal
deleted
inserted
replaced
93025:1e3b2cf969d4 | 93026:8e1a78482251 |
---|---|
250 :group 'diary) | 250 :group 'diary) |
251 | 251 |
252 (defcustom calendar-today-marker (if (display-color-p) 'calendar-today "=") | 252 (defcustom calendar-today-marker (if (display-color-p) 'calendar-today "=") |
253 "How to mark today's date in the calendar. | 253 "How to mark today's date in the calendar. |
254 The value can be either a single-character string or a face. | 254 The value can be either a single-character string or a face. |
255 Marking today's date is done only if you set up `today-visible-calendar-hook' | 255 Used by `calendar-mark-today'." |
256 to request that." | |
257 :type '(choice string face) | 256 :type '(choice string face) |
258 :group 'calendar) | 257 :group 'calendar) |
259 | 258 |
260 (defcustom calendar-holiday-marker (if (display-color-p) 'holiday "*") | 259 (defcustom calendar-holiday-marker (if (display-color-p) 'holiday "*") |
261 "How to mark notable dates in the calendar. | 260 "How to mark notable dates in the calendar. |
286 This is the place to add key bindings to `calendar-mode-map'." | 285 This is the place to add key bindings to `calendar-mode-map'." |
287 :type 'hook | 286 :type 'hook |
288 :group 'calendar-hooks) | 287 :group 'calendar-hooks) |
289 | 288 |
290 (defcustom initial-calendar-window-hook nil | 289 (defcustom initial-calendar-window-hook nil |
291 "List of functions to be called when the calendar window is first opened. | 290 "List of functions to be called when the calendar window is created. |
292 The functions invoked are called after the calendar window is opened, but | 291 Qutting the calendar and re-entering it will cause these functions |
293 once opened is never called again. Leaving the calendar with the `q' command | 292 to be called again." |
294 and reentering it will cause these functions to be called again." | |
295 :type 'hook | 293 :type 'hook |
296 :group 'calendar-hooks) | 294 :group 'calendar-hooks) |
297 | 295 |
298 (defcustom today-visible-calendar-hook nil | 296 (defcustom today-visible-calendar-hook nil |
299 "List of functions called whenever the current date is visible. | 297 "List of functions called whenever the current date is visible. |
300 This can be used, for example, to replace today's date with asterisks; a | 298 To mark today's date, add the function `calendar-mark-today'. |
301 function `calendar-star-date' is included for this purpose: | 299 To replace the date with asterisks, add the function `calendar-star-date'. |
302 (setq today-visible-calendar-hook 'calendar-star-date) | 300 |
303 It can also be used to mark the current date with `calendar-today-marker'; | 301 See also `today-invisible-calendar-hook'. |
304 a function is also provided for this: | 302 |
305 (setq today-visible-calendar-hook 'calendar-mark-today) | 303 Changing characters in the calendar buffer, except via the provided |
306 | 304 functions, may cause the calendar movement commands to fail." |
307 The corresponding variable `today-invisible-calendar-hook' is the list of | 305 :type 'hook |
308 functions called when the calendar function was called when the current | 306 :options '(calendar-mark-today calendar-star-date) |
309 date is not visible in the window. | 307 :group 'calendar-hooks) |
310 | 308 |
311 Other than the use of the provided functions, the changing of any | 309 (defcustom today-invisible-calendar-hook nil |
312 characters in the calendar buffer by the hooks may cause the failure of the | 310 "List of functions called whenever the current date is not visible. |
313 functions that move by days and weeks." | 311 See also `today-visible-calendar-hook'." |
314 :type 'hook | 312 :type 'hook |
315 :group 'calendar-hooks) | 313 :group 'calendar-hooks) |
316 | 314 |
317 (defcustom today-invisible-calendar-hook nil | |
318 "List of functions called whenever the current date is not visible. | |
319 | |
320 The corresponding variable `today-visible-calendar-hook' is the list of | |
321 functions called when the calendar function was called when the current | |
322 date is visible in the window. | |
323 | |
324 Other than the use of the provided functions, the changing of any | |
325 characters in the calendar buffer by the hooks may cause the failure of the | |
326 functions that move by days and weeks." | |
327 :type 'hook | |
328 :group 'calendar-hooks) | |
329 | |
330 (defcustom calendar-move-hook nil | 315 (defcustom calendar-move-hook nil |
331 "List of functions called whenever the cursor moves in the calendar. | 316 "List of functions called whenever the cursor moves in the calendar. |
332 | |
333 For example, | 317 For example, |
334 | 318 |
335 (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1))) | 319 (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1))) |
336 | 320 |
337 redisplays the diary for whatever date the cursor is moved to." | 321 redisplays the diary for whatever date the cursor is moved to." |
437 | 421 |
438 Diary entries based on the Hebrew, the Islamic and/or the Baha'i | 422 Diary entries based on the Hebrew, the Islamic and/or the Baha'i |
439 calendar are also possible, but because these are somewhat slow, they | 423 calendar are also possible, but because these are somewhat slow, they |
440 are ignored unless you set the `nongregorian-diary-listing-hook' and | 424 are ignored unless you set the `nongregorian-diary-listing-hook' and |
441 the `nongregorian-diary-marking-hook' appropriately. See the | 425 the `nongregorian-diary-marking-hook' appropriately. See the |
442 documentation for these functions for details. | 426 documentation of these hooks for details. |
443 | 427 |
444 Diary files can contain directives to include the contents of other files; for | 428 Diary files can contain directives to include the contents of other files; for |
445 details, see the documentation for the variable `list-diary-entries-hook'." | 429 details, see the documentation for the variable `list-diary-entries-hook'." |
446 :type 'file | 430 :type 'file |
447 :group 'diary) | 431 :group 'diary) |
448 | 432 |
433 ;; FIXME do these have to be single characters? | |
449 (defcustom diary-nonmarking-symbol "&" | 434 (defcustom diary-nonmarking-symbol "&" |
450 "Symbol indicating that a diary entry is not to be marked in the calendar." | 435 "Symbol indicating that a diary entry is not to be marked in the calendar." |
451 :type 'string | 436 :type 'string |
452 :group 'diary) | 437 :group 'diary) |
453 | 438 |
464 (defcustom bahai-diary-entry-symbol "B" | 449 (defcustom bahai-diary-entry-symbol "B" |
465 "Symbol indicating a diary entry according to the Baha'i calendar." | 450 "Symbol indicating a diary entry according to the Baha'i calendar." |
466 :type 'string | 451 :type 'string |
467 :group 'diary) | 452 :group 'diary) |
468 | 453 |
454 ;; FIXME explain range. FIXME tweak range to always be +-50 of | |
455 ;; present, if not already. | |
469 (defcustom abbreviated-calendar-year t | 456 (defcustom abbreviated-calendar-year t |
470 "Interpret a two-digit year DD in a diary entry as either 19DD or 20DD. | 457 "Interpret a two-digit year DD in a diary entry as either 19DD or 20DD. |
471 For the Gregorian calendar; similarly for the Hebrew, Islamic and | 458 For the Gregorian calendar; similarly for the Hebrew, Islamic and |
472 Baha'i calendars. If this variable is nil, years must be written in | 459 Baha'i calendars. If this variable is nil, years must be written in |
473 full." | 460 full." |
649 calendar-date-display-form american-calendar-display-form | 636 calendar-date-display-form american-calendar-display-form |
650 diary-date-forms american-date-diary-pattern) | 637 diary-date-forms american-date-diary-pattern) |
651 (update-calendar-mode-line)) | 638 (update-calendar-mode-line)) |
652 | 639 |
653 ;; FIXME move to diary-lib and adjust appt. | 640 ;; FIXME move to diary-lib and adjust appt. |
641 ;; Add appt-make-list as an option? | |
654 (defcustom diary-hook nil | 642 (defcustom diary-hook nil |
655 "List of functions called after the display of the diary. | 643 "List of functions called after the display of the diary. |
656 Can be used for appointment notification." | 644 Can be used for appointment notification." |
657 :type 'hook | 645 :type 'hook |
658 :group 'diary) | 646 :group 'diary) |
1223 (while ,condition | 1211 (while ,condition |
1224 (setq sum (+ sum ,expression) | 1212 (setq sum (+ sum ,expression) |
1225 ,index (1+ ,index))) | 1213 ,index (1+ ,index))) |
1226 sum)) | 1214 sum)) |
1227 | 1215 |
1216 (defmacro calendar-in-read-only-buffer (buffer &rest body) | |
1217 "Switch to BUFFER and executes the forms in BODY. | |
1218 First creates or erases BUFFER as needed. Leaves BUFFER read-only, | |
1219 with disabled undo. Leaves point at point-min, displays BUFFER." | |
1220 (declare (indent 1) (debug t)) | |
1221 `(progn | |
1222 (set-buffer (get-buffer-create ,buffer)) | |
1223 (setq buffer-read-only nil | |
1224 buffer-undo-list t) | |
1225 (erase-buffer) | |
1226 ,@body | |
1227 (goto-char (point-min)) | |
1228 (set-buffer-modified-p nil) | |
1229 (setq buffer-read-only t) | |
1230 (display-buffer ,buffer))) | |
1231 | |
1228 ;; The following are in-line for speed; they can be called thousands of times | 1232 ;; The following are in-line for speed; they can be called thousands of times |
1229 ;; when looking up holidays or processing the diary. Here, for example, are | 1233 ;; when looking up holidays or processing the diary. Here, for example, are |
1230 ;; the numbers of calls to calendar/diary/holiday functions in preparing the | 1234 ;; the numbers of calls to calendar/diary/holiday functions in preparing the |
1231 ;; fancy diary display, for a moderately complex diary file, with functions | 1235 ;; fancy diary display, for a moderately complex diary file, with functions |
1232 ;; used instead of macros. There were a total of 10000 such calls: | 1236 ;; used instead of macros. There were a total of 10000 such calls: |
1255 | 1259 |
1256 (defsubst extract-calendar-month (date) | 1260 (defsubst extract-calendar-month (date) |
1257 "Extract the month part of DATE which has the form (month day year)." | 1261 "Extract the month part of DATE which has the form (month day year)." |
1258 (car date)) | 1262 (car date)) |
1259 | 1263 |
1260 ;; Note gives wrong answer for result of (calendar-read-date 'noday). | 1264 ;; Note gives wrong answer for result of (calendar-read-date 'noday), |
1265 ;; but that is only used by `calendar-other-month'. | |
1261 (defsubst extract-calendar-day (date) | 1266 (defsubst extract-calendar-day (date) |
1262 "Extract the day part of DATE which has the form (month day year)." | 1267 "Extract the day part of DATE which has the form (month day year)." |
1263 (cadr date)) | 1268 (cadr date)) |
1264 | 1269 |
1265 (defsubst extract-calendar-year (date) | 1270 (defsubst extract-calendar-year (date) |
1379 | 1384 |
1380 After loading the calendar, the hooks given by the variable | 1385 After loading the calendar, the hooks given by the variable |
1381 `calendar-load-hook' are run. This is the place to add key bindings to the | 1386 `calendar-load-hook' are run. This is the place to add key bindings to the |
1382 `calendar-mode-map'. | 1387 `calendar-mode-map'. |
1383 | 1388 |
1384 After preparing the calendar window initially, the hooks given by the variable | |
1385 `initial-calendar-window-hook' are run. | |
1386 | |
1387 The hooks given by the variable `today-visible-calendar-hook' are run | 1389 The hooks given by the variable `today-visible-calendar-hook' are run |
1388 every time the calendar window gets scrolled, if the current date is visible | 1390 every time the calendar window gets scrolled, if the current date is visible |
1389 in the window. If it is not visible, the hooks given by the variable | 1391 in the window. If it is not visible, the hooks given by the variable |
1390 `today-invisible-calendar-hook' are run. Thus, for example, setting | 1392 `today-invisible-calendar-hook' are run. |
1391 `today-visible-calendar-hook' to 'calendar-star-date will cause today's date | 1393 |
1392 to be replaced by asterisks to highlight it whenever it is in the window." | 1394 Finally this command runs `initial-calendar-window-hook'." |
1393 (interactive "P") | 1395 (interactive "P") |
1394 (set-buffer (get-buffer-create calendar-buffer)) | 1396 (set-buffer (get-buffer-create calendar-buffer)) |
1395 (calendar-mode) | 1397 (calendar-mode) |
1396 (let* ((pop-up-windows t) | 1398 (let* ((pop-up-windows t) |
1397 (split-height-threshold 1000) | 1399 (split-height-threshold 1000) |
1398 (date (if arg (calendar-read-date t) | 1400 (date (if arg (calendar-read-date t) |
1399 (calendar-current-date))) | 1401 (calendar-current-date))) |
1400 (month (extract-calendar-month date)) | 1402 (month (extract-calendar-month date)) |
1401 (year (extract-calendar-year date))) | 1403 (year (extract-calendar-year date))) |
1402 ;; (calendar-read-date t) returns a date with day = nil, which is | |
1403 ;; not a valid date for the visible test in the diary section. | |
1404 (if arg (setcar (cdr date) 1)) | |
1405 (increment-calendar-month month year (- calendar-offset)) | 1404 (increment-calendar-month month year (- calendar-offset)) |
1406 ;; Display the buffer before calling generate-calendar-window so that it | 1405 ;; Display the buffer before calling generate-calendar-window so that it |
1407 ;; can get a chance to adjust the window sizes to the frame size. | 1406 ;; can get a chance to adjust the window sizes to the frame size. |
1408 (pop-to-buffer calendar-buffer) | 1407 (pop-to-buffer calendar-buffer) |
1409 (generate-calendar-window month year) | 1408 (generate-calendar-window month year) |
1410 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) | 1409 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) |
1411 (diary-view-entries))) | 1410 (diary-view-entries))) |
1412 (let* ((diary-buffer (get-file-buffer diary-file)) | 1411 (if view-calendar-holidays-initially |
1413 (diary-window (if diary-buffer (get-buffer-window diary-buffer))) | 1412 (let* ((diary-buffer (get-file-buffer diary-file)) |
1414 (split-height-threshold (if diary-window 2 1000))) | 1413 (diary-window (if diary-buffer (get-buffer-window diary-buffer))) |
1415 (if view-calendar-holidays-initially | 1414 (split-height-threshold (if diary-window 2 1000))) |
1415 ;; FIXME display buffer? | |
1416 (calendar-list-holidays))) | 1416 (calendar-list-holidays))) |
1417 (run-hooks 'initial-calendar-window-hook)) | 1417 (run-hooks 'initial-calendar-window-hook)) |
1418 | 1418 |
1419 (defun generate-calendar-window (&optional mon yr) | 1419 (defun generate-calendar-window (&optional mon yr) |
1420 "Generate the calendar window for the current date. | 1420 "Generate the calendar window for the current date. |
2073 | 2073 |
2074 (defvar calendar-abbrev-length 3 | 2074 (defvar calendar-abbrev-length 3 |
2075 "*Length of abbreviations to be used for day and month names. | 2075 "*Length of abbreviations to be used for day and month names. |
2076 See also `calendar-day-abbrev-array' and `calendar-month-abbrev-array'.") | 2076 See also `calendar-day-abbrev-array' and `calendar-month-abbrev-array'.") |
2077 | 2077 |
2078 (defvar calendar-day-name-array | 2078 ;; FIXME does it have to start from Sunday? |
2079 (defcustom calendar-day-name-array | |
2079 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"] | 2080 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"] |
2080 "*Array of capitalized strings giving, in order, the day names. | 2081 "Array of capitalized strings giving, in order, the day names. |
2081 The first two characters of each string will be used to head the | 2082 The first two characters of each string will be used to head the |
2082 day columns in the calendar. See also the variable | 2083 day columns in the calendar. See also the variable |
2083 `calendar-day-abbrev-array'.") | 2084 `calendar-day-abbrev-array'." |
2085 :group 'calendar | |
2086 :type '(vector (string :tag "Sunday") | |
2087 (string :tag "Monday") | |
2088 (string :tag "Tuesday") | |
2089 (string :tag "Wednesday") | |
2090 (string :tag "Thursday") | |
2091 (string :tag "Friday") | |
2092 (string :tag "Saturday"))) | |
2084 | 2093 |
2085 (defvar calendar-day-abbrev-array | 2094 (defvar calendar-day-abbrev-array |
2086 [nil nil nil nil nil nil nil] | 2095 [nil nil nil nil nil nil nil] |
2087 "*Array of capitalized strings giving the abbreviated day names. | 2096 "*Array of capitalized strings giving the abbreviated day names. |
2088 The order should be the same as that of the full names specified | 2097 The order should be the same as that of the full names specified |
2091 trailing `.' in the strings specified in this variable, though | 2100 trailing `.' in the strings specified in this variable, though |
2092 you may use such in the diary file. If any element of this array | 2101 you may use such in the diary file. If any element of this array |
2093 is nil, then the abbreviation will be constructed as the first | 2102 is nil, then the abbreviation will be constructed as the first |
2094 `calendar-abbrev-length' characters of the corresponding full name.") | 2103 `calendar-abbrev-length' characters of the corresponding full name.") |
2095 | 2104 |
2096 (defvar calendar-month-name-array | 2105 (defcustom calendar-month-name-array |
2097 ["January" "February" "March" "April" "May" "June" | 2106 ["January" "February" "March" "April" "May" "June" |
2098 "July" "August" "September" "October" "November" "December"] | 2107 "July" "August" "September" "October" "November" "December"] |
2099 "*Array of capitalized strings giving, in order, the month names. | 2108 "Array of capitalized strings giving, in order, the month names. |
2100 See also the variable `calendar-month-abbrev-array'.") | 2109 See also the variable `calendar-month-abbrev-array'." |
2110 :group 'calendar | |
2111 :type '(vector (string :tag "January") | |
2112 (string :tag "February") | |
2113 (string :tag "March") | |
2114 (string :tag "April") | |
2115 (string :tag "May") | |
2116 (string :tag "June") | |
2117 (string :tag "July") | |
2118 (string :tag "August") | |
2119 (string :tag "September") | |
2120 (string :tag "October") | |
2121 (string :tag "November") | |
2122 (string :tag "December"))) | |
2101 | 2123 |
2102 (defvar calendar-month-abbrev-array | 2124 (defvar calendar-month-abbrev-array |
2103 [nil nil nil nil nil nil nil nil nil nil nil nil] | 2125 [nil nil nil nil nil nil nil nil nil nil nil nil] |
2104 "*Array of capitalized strings giving the abbreviated month names. | 2126 "*Array of capitalized strings giving the abbreviated month names. |
2105 The order should be the same as that of the full names specified | 2127 The order should be the same as that of the full names specified |
2141 index) alist)))))) | 2163 index) alist)))))) |
2142 | 2164 |
2143 (defun calendar-read-date (&optional noday) | 2165 (defun calendar-read-date (&optional noday) |
2144 "Prompt for Gregorian date. Return a list (month day year). | 2166 "Prompt for Gregorian date. Return a list (month day year). |
2145 If optional NODAY is t, does not ask for day, but just returns | 2167 If optional NODAY is t, does not ask for day, but just returns |
2146 \(month nil year); if NODAY is any other non-nil value the value returned is | 2168 \(month 1 year); if NODAY is any other non-nil value the value returned is |
2147 \(month year)" | 2169 \(month year)" |
2148 (let* ((year (calendar-read | 2170 (let* ((year (calendar-read |
2149 "Year (>0): " | 2171 "Year (>0): " |
2150 (lambda (x) (> x 0)) | 2172 (lambda (x) (> x 0)) |
2151 (int-to-string (extract-calendar-year | 2173 (int-to-string (extract-calendar-year |
2159 nil t) | 2181 nil t) |
2160 (calendar-make-alist month-array 1) t))) | 2182 (calendar-make-alist month-array 1) t))) |
2161 (last (calendar-last-day-of-month month year))) | 2183 (last (calendar-last-day-of-month month year))) |
2162 (if noday | 2184 (if noday |
2163 (if (eq noday t) | 2185 (if (eq noday t) |
2164 (list month nil year) | 2186 (list month 1 year) |
2165 (list month year)) | 2187 (list month year)) |
2166 (list month | 2188 (list month |
2167 (calendar-read (format "Day (1-%d): " last) | 2189 (calendar-read (format "Day (1-%d): " last) |
2168 (lambda (x) (and (< 0 x) (<= x last)))) | 2190 (lambda (x) (and (< 0 x) (<= x last)))) |
2169 year)))) | 2191 year)))) |
2259 "Return t if DATE is a valid date." | 2281 "Return t if DATE is a valid date." |
2260 (let ((month (extract-calendar-month date)) | 2282 (let ((month (extract-calendar-month date)) |
2261 (day (extract-calendar-day date)) | 2283 (day (extract-calendar-day date)) |
2262 (year (extract-calendar-year date))) | 2284 (year (extract-calendar-year date))) |
2263 (and (<= 1 month) (<= month 12) | 2285 (and (<= 1 month) (<= month 12) |
2264 ;; (calendar-read-date t) returns a date with day = nil. | 2286 ;; (calendar-read-date t) used to return a date with day = nil. |
2265 ;; Should not be valid (?), since many funcs prob assume integer. | 2287 ;; Should not be valid (?), since many funcs prob assume integer. |
2266 ;; (calendar-read-date 'noday) returns (month year), which | 2288 ;; (calendar-read-date 'noday) returns (month year), which |
2267 ;; currently results in extract-calendar-year returning nil. | 2289 ;; currently results in extract-calendar-year returning nil. |
2268 day year (<= 1 day) (<= day (calendar-last-day-of-month month year)) | 2290 day year (<= 1 day) (<= day (calendar-last-day-of-month month year)) |
2269 ;; BC dates left as non-valid, to suppress errors from | 2291 ;; BC dates left as non-valid, to suppress errors from |
2330 (overlay-put | 2352 (overlay-put |
2331 (make-overlay (1- (point)) (1+ (point))) 'face temp-face)))))))) | 2353 (make-overlay (1- (point)) (1+ (point))) 'face temp-face)))))))) |
2332 | 2354 |
2333 (defun calendar-star-date () | 2355 (defun calendar-star-date () |
2334 "Replace the date under the cursor in the calendar window with asterisks. | 2356 "Replace the date under the cursor in the calendar window with asterisks. |
2335 This function can be used with the `today-visible-calendar-hook' run after the | 2357 You might want to add this function to `today-visible-calendar-hook'." |
2336 calendar window has been prepared." | |
2337 (let ((inhibit-read-only t) | 2358 (let ((inhibit-read-only t) |
2338 (modified (buffer-modified-p))) | 2359 (modified (buffer-modified-p))) |
2339 (forward-char 1) | 2360 (forward-char 1) |
2340 (setq calendar-starred-day | 2361 (setq calendar-starred-day |
2341 (string-to-number (buffer-substring (point) (- (point) 2)))) | 2362 (string-to-number (buffer-substring (point) (- (point) 2)))) |
2346 (forward-char 1) | 2367 (forward-char 1) |
2347 (restore-buffer-modified-p modified))) | 2368 (restore-buffer-modified-p modified))) |
2348 | 2369 |
2349 (defun calendar-mark-today () | 2370 (defun calendar-mark-today () |
2350 "Mark the date under the cursor in the calendar window. | 2371 "Mark the date under the cursor in the calendar window. |
2351 The date is marked with `calendar-today-marker'. This function can be used with | 2372 The date is marked with `calendar-today-marker'. You might want to add |
2352 the `today-visible-calendar-hook' run after the calendar window has been | 2373 this function to `today-visible-calendar-hook'." |
2353 prepared." | 2374 (mark-visible-calendar-date (calendar-cursor-to-date) calendar-today-marker)) |
2354 (mark-visible-calendar-date | |
2355 (calendar-cursor-to-date) | |
2356 calendar-today-marker)) | |
2357 | 2375 |
2358 (defun calendar-date-compare (date1 date2) | 2376 (defun calendar-date-compare (date1 date2) |
2359 "Return t if DATE1 is before DATE2, nil otherwise. | 2377 "Return t if DATE1 is before DATE2, nil otherwise. |
2360 The actual dates are in the car of DATE1 and DATE2." | 2378 The actual dates are in the car of DATE1 and DATE2." |
2361 (< (calendar-absolute-from-gregorian (car date1)) | 2379 (< (calendar-absolute-from-gregorian (car date1)) |
2428 day year days-remaining (if (= days-remaining 1) "" "s")))) | 2446 day year days-remaining (if (= days-remaining 1) "" "s")))) |
2429 | 2447 |
2430 (defun calendar-print-other-dates () | 2448 (defun calendar-print-other-dates () |
2431 "Show dates on other calendars for date under the cursor." | 2449 "Show dates on other calendars for date under the cursor." |
2432 (interactive) | 2450 (interactive) |
2433 (let ((date (calendar-cursor-to-date t))) | 2451 (let ((date (calendar-cursor-to-date t)) |
2434 (with-current-buffer (get-buffer-create other-calendars-buffer) | 2452 odate) |
2435 (let ((inhibit-read-only t) | 2453 (calendar-in-read-only-buffer other-calendars-buffer |
2436 (modified (buffer-modified-p))) | 2454 (calendar-set-mode-line (format "%s (Gregorian)" |
2437 (calendar-set-mode-line | 2455 (calendar-date-string date))) |
2438 (concat (calendar-date-string date) " (Gregorian)")) | 2456 (apply |
2439 (erase-buffer) | 2457 'insert |
2440 (apply | 2458 (delq nil |
2441 'insert | 2459 (list |
2442 (delq nil | 2460 (calendar-day-of-year-string date) "\n" |
2443 (list | 2461 (format "ISO date: %s\n" (calendar-iso-date-string date)) |
2444 (calendar-day-of-year-string date) "\n" | 2462 (format "Julian date: %s\n" |
2445 (format "ISO date: %s\n" (calendar-iso-date-string date)) | 2463 (calendar-julian-date-string date)) |
2446 (format "Julian date: %s\n" | 2464 (format "Astronomical (Julian) day number (at noon UTC): %s.0\n" |
2447 (calendar-julian-date-string date)) | 2465 (calendar-astro-date-string date)) |
2448 (format "Astronomical (Julian) day number (at noon UTC): %s.0\n" | 2466 (format "Fixed (RD) date: %s\n" |
2449 (calendar-astro-date-string date)) | 2467 (calendar-absolute-from-gregorian date)) |
2450 (format "Fixed (RD) date: %s\n" | 2468 (format "Hebrew date (before sunset): %s\n" |
2451 (calendar-absolute-from-gregorian date)) | 2469 (calendar-hebrew-date-string date)) |
2452 (format "Hebrew date (before sunset): %s\n" | 2470 (format "Persian date: %s\n" |
2453 (calendar-hebrew-date-string date)) | 2471 (calendar-persian-date-string date)) |
2454 (format "Persian date: %s\n" | 2472 (unless (string-equal |
2455 (calendar-persian-date-string date)) | 2473 (setq odate (calendar-islamic-date-string date)) |
2456 (let ((i (calendar-islamic-date-string date))) | 2474 "") |
2457 (unless (string-equal i "") | 2475 (format "Islamic date (before sunset): %s\n" odate)) |
2458 (format "Islamic date (before sunset): %s\n" i))) | 2476 (unless (string-equal |
2459 (let ((b (calendar-bahai-date-string date))) | 2477 (setq odate (calendar-bahai-date-string date)) |
2460 (unless (string-equal b "") | 2478 "") |
2461 (format "Baha'i date (before sunset): %s\n" b))) | 2479 (format "Baha'i date (before sunset): %s\n" odate)) |
2462 (format "Chinese date: %s\n" | 2480 (format "Chinese date: %s\n" |
2463 (calendar-chinese-date-string date)) | 2481 (calendar-chinese-date-string date)) |
2464 (let ((c (calendar-coptic-date-string date))) | 2482 (unless (string-equal |
2465 (unless (string-equal c "") | 2483 (setq odate (calendar-coptic-date-string date)) |
2466 (format "Coptic date: %s\n" c))) | 2484 "") |
2467 (let ((e (calendar-ethiopic-date-string date))) | 2485 (format "Coptic date: %s\n" odate)) |
2468 (unless (string-equal e "") | 2486 (unless (string-equal |
2469 (format "Ethiopic date: %s\n" e))) | 2487 (setq odate (calendar-ethiopic-date-string date)) |
2470 (let ((f (calendar-french-date-string date))) | 2488 "") |
2471 (unless (string-equal f "") | 2489 (format "Ethiopic date: %s\n" e)) |
2472 (format "French Revolutionary date: %s\n" f))) | 2490 (unless (string-equal |
2473 (format "Mayan date: %s\n" | 2491 (setq odate (calendar-french-date-string date)) |
2474 (calendar-mayan-date-string date))))) | 2492 "") |
2475 (goto-char (point-min)) | 2493 (format "French Revolutionary date: %s\n" odate)) |
2476 (restore-buffer-modified-p modified)) | 2494 (format "Mayan date: %s\n" |
2477 (display-buffer other-calendars-buffer)))) | 2495 (calendar-mayan-date-string date)))))))) |
2478 | 2496 |
2479 (defun calendar-print-day-of-year () | 2497 (defun calendar-print-day-of-year () |
2480 "Show day number in year/days remaining in year for date under the cursor." | 2498 "Show day number in year/days remaining in year for date under the cursor." |
2481 (interactive) | 2499 (interactive) |
2482 (message "%s" (calendar-day-of-year-string (calendar-cursor-to-date t)))) | 2500 (message "%s" (calendar-day-of-year-string (calendar-cursor-to-date t)))) |