diff options
| -rw-r--r-- | lisp/calendar/calendar.el | 240 |
1 files changed, 125 insertions, 115 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 51312b9eadb..53394352123 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el | |||
| @@ -91,6 +91,24 @@ | |||
| 91 | ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and | 91 | ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and |
| 92 | ;; the message BODY containing your mailing address (snail). | 92 | ;; the message BODY containing your mailing address (snail). |
| 93 | 93 | ||
| 94 | |||
| 95 | ;; A note on free variables: | ||
| 96 | |||
| 97 | ;; The calendar passes around a few dynamically bound variables, which | ||
| 98 | ;; unfortunately have rather common names. They are meant to be | ||
| 99 | ;; available for external functions, so the names can't be changed. | ||
| 100 | |||
| 101 | ;; displayed-month, displayed-year: bound in generate-calendar, the | ||
| 102 | ;; central month of the 3 month calendar window | ||
| 103 | ;; original-date, number: bound in diary-list-entries, the arguments | ||
| 104 | ;; with which that function was called. | ||
| 105 | ;; date, entry: bound in list-sexp-diary-entries (qv) | ||
| 106 | |||
| 107 | ;; Bound in diary-list-entries: | ||
| 108 | ;; diary-entries-list: use in d-l, appt.el, and by add-to-diary-list | ||
| 109 | ;; diary-saved-point: only used in diary-lib.el, passed to the display func | ||
| 110 | ;; date-string: only used in diary-lib.el FIXME could be removed? | ||
| 111 | |||
| 94 | ;;; Code: | 112 | ;;; Code: |
| 95 | 113 | ||
| 96 | ;; (elisp) Eval During Compile: "Effectively `require' is | 114 | ;; (elisp) Eval During Compile: "Effectively `require' is |
| @@ -457,9 +475,9 @@ full." | |||
| 457 | ;;;###autoload | 475 | ;;;###autoload |
| 458 | (defcustom european-calendar-style nil | 476 | (defcustom european-calendar-style nil |
| 459 | "Use the European style of dates in the diary and in any displays. | 477 | "Use the European style of dates in the diary and in any displays. |
| 460 | If this variable is t, a date 1/2/1990 would be interpreted as February 1, | 478 | If this variable is non-nil, a date 1/2/1990 would be interpreted as |
| 461 | 1990. The default European date styles (see `european-date-diary-pattern') | 479 | February 1, 1990. The default European date styles (see |
| 462 | are | 480 | `european-date-diary-pattern') are |
| 463 | 481 | ||
| 464 | DAY/MONTH | 482 | DAY/MONTH |
| 465 | DAY/MONTH/YEAR | 483 | DAY/MONTH/YEAR |
| @@ -746,17 +764,16 @@ calendar." | |||
| 746 | (if all-hebrew-calendar-holidays | 764 | (if all-hebrew-calendar-holidays |
| 747 | (holiday-julian | 765 | (holiday-julian |
| 748 | 11 | 766 | 11 |
| 749 | (let* ((m displayed-month) | 767 | (let ((m displayed-month) |
| 750 | (y displayed-year) | 768 | (y displayed-year) |
| 751 | (year)) | 769 | year) |
| 752 | (increment-calendar-month m y -1) | 770 | (increment-calendar-month m y -1) |
| 753 | (let ((year (extract-calendar-year | 771 | (setq year (extract-calendar-year |
| 754 | (calendar-julian-from-absolute | 772 | (calendar-julian-from-absolute |
| 755 | (calendar-absolute-from-gregorian | 773 | (calendar-absolute-from-gregorian (list m 1 y))))) |
| 756 | (list m 1 y)))))) | 774 | (if (zerop (% (1+ year) 4)) |
| 757 | (if (zerop (% (1+ year) 4)) | 775 | 22 |
| 758 | 22 | 776 | 21)) "\"Tal Umatar\" (evening)"))) |
| 759 | 21))) "\"Tal Umatar\" (evening)"))) | ||
| 760 | "Component of the default value of `hebrew-holidays'.") | 777 | "Component of the default value of `hebrew-holidays'.") |
| 761 | ;;;###autoload | 778 | ;;;###autoload |
| 762 | (put 'hebrew-holidays-1 'risky-local-variable t) | 779 | (put 'hebrew-holidays-1 'risky-local-variable t) |
| @@ -773,9 +790,8 @@ calendar." | |||
| 773 | (calendar-hebrew-from-absolute | 790 | (calendar-hebrew-from-absolute |
| 774 | (calendar-absolute-from-gregorian | 791 | (calendar-absolute-from-gregorian |
| 775 | (list displayed-month 28 displayed-year)))))) | 792 | (list displayed-month 28 displayed-year)))))) |
| 776 | (if (= (% (calendar-absolute-from-hebrew (list 10 10 h-year)) | 793 | (if (= 6 (% (calendar-absolute-from-hebrew (list 10 10 h-year)) |
| 777 | 7) | 794 | 7)) |
| 778 | 6) | ||
| 779 | 11 10)) | 795 | 11 10)) |
| 780 | "Tzom Teveth")) | 796 | "Tzom Teveth")) |
| 781 | (if all-hebrew-calendar-holidays | 797 | (if all-hebrew-calendar-holidays |
| @@ -800,11 +816,10 @@ calendar." | |||
| 800 | y))))) | 816 | y))))) |
| 801 | (s-s | 817 | (s-s |
| 802 | (calendar-hebrew-from-absolute | 818 | (calendar-hebrew-from-absolute |
| 803 | (if (= | 819 | (if (= 6 |
| 804 | (% (calendar-absolute-from-hebrew | 820 | (% (calendar-absolute-from-hebrew |
| 805 | (list 7 1 h-year)) | 821 | (list 7 1 h-year)) |
| 806 | 7) | 822 | 7)) |
| 807 | 6) | ||
| 808 | (calendar-dayname-on-or-before | 823 | (calendar-dayname-on-or-before |
| 809 | 6 (calendar-absolute-from-hebrew | 824 | 6 (calendar-absolute-from-hebrew |
| 810 | (list 11 17 h-year))) | 825 | (list 11 17 h-year))) |
| @@ -822,15 +837,15 @@ calendar." | |||
| 822 | (defvar hebrew-holidays-4 | 837 | (defvar hebrew-holidays-4 |
| 823 | '((holiday-passover-etc) | 838 | '((holiday-passover-etc) |
| 824 | (if (and all-hebrew-calendar-holidays | 839 | (if (and all-hebrew-calendar-holidays |
| 825 | (let* ((m displayed-month) | 840 | (let ((m displayed-month) |
| 826 | (y displayed-year) | 841 | (y displayed-year) |
| 827 | (year)) | 842 | year) |
| 828 | (increment-calendar-month m y -1) | 843 | (increment-calendar-month m y -1) |
| 829 | (let ((year (extract-calendar-year | 844 | (setq year (extract-calendar-year |
| 830 | (calendar-julian-from-absolute | 845 | (calendar-julian-from-absolute |
| 831 | (calendar-absolute-from-gregorian | 846 | (calendar-absolute-from-gregorian |
| 832 | (list m 1 y)))))) | 847 | (list m 1 y))))) |
| 833 | (= 21 (% year 28))))) | 848 | (= 21 (% year 28)))) |
| 834 | (holiday-julian 3 26 "Kiddush HaHamah")) | 849 | (holiday-julian 3 26 "Kiddush HaHamah")) |
| 835 | (if all-hebrew-calendar-holidays | 850 | (if all-hebrew-calendar-holidays |
| 836 | (holiday-tisha-b-av-etc))) | 851 | (holiday-tisha-b-av-etc))) |
| @@ -1191,20 +1206,20 @@ MON defaults to `displayed-month'. YR defaults to `displayed-year'." | |||
| 1191 | (defmacro calendar-for-loop (var from init to final do &rest body) | 1206 | (defmacro calendar-for-loop (var from init to final do &rest body) |
| 1192 | "Execute a for loop. | 1207 | "Execute a for loop. |
| 1193 | Evaluate BODY with VAR bound to successive integers from INIT to FINAL, | 1208 | Evaluate BODY with VAR bound to successive integers from INIT to FINAL, |
| 1194 | inclusive." | 1209 | inclusive. The standard macro `dotimes' is preferable in most cases." |
| 1195 | (declare (debug (symbolp "from" form "to" form "do" body))) | 1210 | (declare (debug (symbolp "from" form "to" form "do" body))) |
| 1196 | `(let ((,var (1- ,init))) | 1211 | `(let ((,var (1- ,init))) |
| 1197 | (while (>= ,final (setq ,var (1+ ,var))) | 1212 | (while (>= ,final (setq ,var (1+ ,var))) |
| 1198 | ,@body))) | 1213 | ,@body))) |
| 1199 | 1214 | ||
| 1200 | (defmacro calendar-sum (index initial condition expression) | 1215 | (defmacro calendar-sum (index initial condition expression) |
| 1201 | "For INDEX = INITIAL et seq, as long as CONDITION holds, sum EXPRESSION." | 1216 | "For INDEX = INITIAL, +1, ... (as long as CONDITION holds), sum EXPRESSION." |
| 1202 | (declare (debug (symbolp form form form))) | 1217 | (declare (debug (symbolp form form form))) |
| 1203 | `(let ((,index ,initial) | 1218 | `(let ((,index ,initial) |
| 1204 | (sum 0)) | 1219 | (sum 0)) |
| 1205 | (while ,condition | 1220 | (while ,condition |
| 1206 | (setq sum (+ sum ,expression)) | 1221 | (setq sum (+ sum ,expression) |
| 1207 | (setq ,index (1+ ,index))) | 1222 | ,index (1+ ,index))) |
| 1208 | sum)) | 1223 | sum)) |
| 1209 | 1224 | ||
| 1210 | ;; The following are in-line for speed; they can be called thousands of times | 1225 | ;; The following are in-line for speed; they can be called thousands of times |
| @@ -1242,11 +1257,11 @@ inclusive." | |||
| 1242 | ;; Note gives wrong answer for result of (calendar-read-date 'noday). | 1257 | ;; Note gives wrong answer for result of (calendar-read-date 'noday). |
| 1243 | (defsubst extract-calendar-day (date) | 1258 | (defsubst extract-calendar-day (date) |
| 1244 | "Extract the day part of DATE which has the form (month day year)." | 1259 | "Extract the day part of DATE which has the form (month day year)." |
| 1245 | (car (cdr date))) | 1260 | (cadr date)) |
| 1246 | 1261 | ||
| 1247 | (defsubst extract-calendar-year (date) | 1262 | (defsubst extract-calendar-year (date) |
| 1248 | "Extract the year part of DATE which has the form (month day year)." | 1263 | "Extract the year part of DATE which has the form (month day year)." |
| 1249 | (car (cdr (cdr date)))) | 1264 | (nth 2 date)) |
| 1250 | 1265 | ||
| 1251 | (defsubst calendar-leap-year-p (year) | 1266 | (defsubst calendar-leap-year-p (year) |
| 1252 | "Return t if YEAR is a Gregorian leap year. | 1267 | "Return t if YEAR is a Gregorian leap year. |
| @@ -1279,16 +1294,15 @@ A negative year is interpreted as BC; -1 being 1 BC, and so on." | |||
| 1279 | "Return the day number within the year of the date DATE. | 1294 | "Return the day number within the year of the date DATE. |
| 1280 | For example, (calendar-day-number '(1 1 1987)) returns the value 1, | 1295 | For example, (calendar-day-number '(1 1 1987)) returns the value 1, |
| 1281 | while (calendar-day-number '(12 31 1980)) returns 366." | 1296 | while (calendar-day-number '(12 31 1980)) returns 366." |
| 1282 | (let* ((month (extract-calendar-month date)) | 1297 | (let* ((month (extract-calendar-month date)) |
| 1283 | (day (extract-calendar-day date)) | 1298 | (day (extract-calendar-day date)) |
| 1284 | (year (extract-calendar-year date)) | 1299 | (year (extract-calendar-year date)) |
| 1285 | (day-of-year (+ day (* 31 (1- month))))) | 1300 | (day-of-year (+ day (* 31 (1- month))))) |
| 1286 | (if (> month 2) | 1301 | (when (> month 2) |
| 1287 | (progn | 1302 | (setq day-of-year (- day-of-year (/ (+ 23 (* 4 month)) 10))) |
| 1288 | (setq day-of-year (- day-of-year (/ (+ 23 (* 4 month)) 10))) | 1303 | (if (calendar-leap-year-p year) |
| 1289 | (if (calendar-leap-year-p year) | 1304 | (setq day-of-year (1+ day-of-year)))) |
| 1290 | (setq day-of-year (1+ day-of-year))))) | 1305 | day-of-year)) |
| 1291 | day-of-year)) | ||
| 1292 | 1306 | ||
| 1293 | (defsubst calendar-absolute-from-gregorian (date) | 1307 | (defsubst calendar-absolute-from-gregorian (date) |
| 1294 | "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE. | 1308 | "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE. |
| @@ -1378,8 +1392,7 @@ to be replaced by asterisks to highlight it whenever it is in the window." | |||
| 1378 | (calendar-mode) | 1392 | (calendar-mode) |
| 1379 | (let* ((pop-up-windows t) | 1393 | (let* ((pop-up-windows t) |
| 1380 | (split-height-threshold 1000) | 1394 | (split-height-threshold 1000) |
| 1381 | (date (if arg | 1395 | (date (if arg (calendar-read-date t) |
| 1382 | (calendar-read-date t) | ||
| 1383 | (calendar-current-date))) | 1396 | (calendar-current-date))) |
| 1384 | (month (extract-calendar-month date)) | 1397 | (month (extract-calendar-month date)) |
| 1385 | (year (extract-calendar-year date))) | 1398 | (year (extract-calendar-year date))) |
| @@ -1465,11 +1478,11 @@ The calendar is inserted at the top of the buffer in which point is currently | |||
| 1465 | located, but indented INDENT spaces. The indentation is done from the first | 1478 | located, but indented INDENT spaces. The indentation is done from the first |
| 1466 | character on the line and does not disturb the first INDENT characters on the | 1479 | character on the line and does not disturb the first INDENT characters on the |
| 1467 | line." | 1480 | line." |
| 1468 | (let* ((blank-days ; at start of month | 1481 | (let ((blank-days ; at start of month |
| 1469 | (mod | 1482 | (mod |
| 1470 | (- (calendar-day-of-week (list month 1 year)) | 1483 | (- (calendar-day-of-week (list month 1 year)) |
| 1471 | calendar-week-start-day) | 1484 | calendar-week-start-day) |
| 1472 | 7)) | 1485 | 7)) |
| 1473 | (last (calendar-last-day-of-month month year))) | 1486 | (last (calendar-last-day-of-month month year))) |
| 1474 | (goto-char (point-min)) | 1487 | (goto-char (point-min)) |
| 1475 | (calendar-insert-indented | 1488 | (calendar-insert-indented |
| @@ -1491,22 +1504,22 @@ line." | |||
| 1491 | ;; Add blank days before the first of the month. | 1504 | ;; Add blank days before the first of the month. |
| 1492 | (dotimes (idummy blank-days) (insert " ")) | 1505 | (dotimes (idummy blank-days) (insert " ")) |
| 1493 | ;; Put in the days of the month. | 1506 | ;; Put in the days of the month. |
| 1494 | (calendar-for-loop i from 1 to last do | 1507 | (dotimes (i last) |
| 1495 | (insert (format "%2d " i)) | 1508 | (insert (format "%2d " (1+ i))) |
| 1496 | (add-text-properties | 1509 | (add-text-properties |
| 1497 | (- (point) 3) (1- (point)) | 1510 | (- (point) 3) (1- (point)) |
| 1498 | '(mouse-face highlight | 1511 | '(mouse-face highlight |
| 1499 | help-echo "mouse-2: menu of operations for this date")) | 1512 | help-echo "mouse-2: menu of operations for this date")) |
| 1500 | (and (zerop (mod (+ i blank-days) 7)) | 1513 | (and (zerop (mod (+ i 1 blank-days) 7)) |
| 1501 | (/= i last) | 1514 | (/= i (1- last)) |
| 1502 | (calendar-insert-indented "" 0 t) ; force onto following line | 1515 | (calendar-insert-indented "" 0 t) ; force onto following line |
| 1503 | (calendar-insert-indented "" indent))))) ; go to proper spot | 1516 | (calendar-insert-indented "" indent))))) ; go to proper spot |
| 1504 | 1517 | ||
| 1505 | (defun calendar-insert-indented (string indent &optional newline) | 1518 | (defun calendar-insert-indented (string indent &optional newline) |
| 1506 | "Insert STRING at column INDENT. | 1519 | "Insert STRING at column INDENT. |
| 1507 | If the optional parameter NEWLINE is t, leave point at start of next line, | 1520 | If the optional parameter NEWLINE is non-nil, leave point at start of next |
| 1508 | inserting a newline if there was no next line; otherwise, leave point after | 1521 | line, inserting a newline if there was no next line; otherwise, leave point |
| 1509 | the inserted text. Returns t." | 1522 | after the inserted text. Returns t." |
| 1510 | ;; Try to move to that column. | 1523 | ;; Try to move to that column. |
| 1511 | (move-to-column indent) | 1524 | (move-to-column indent) |
| 1512 | ;; If line is too short, indent out to that column. | 1525 | ;; If line is too short, indent out to that column. |
| @@ -1758,7 +1771,8 @@ under the cursor: | |||
| 1758 | :group 'calendar) | 1771 | :group 'calendar) |
| 1759 | 1772 | ||
| 1760 | (defun mouse-calendar-other-month (event) | 1773 | (defun mouse-calendar-other-month (event) |
| 1761 | "Display a three-month calendar centered around a specified month and year." | 1774 | "Display a three-month calendar centered around a specified month and year. |
| 1775 | EVENT is the last mouse event." | ||
| 1762 | (interactive "e") | 1776 | (interactive "e") |
| 1763 | (save-selected-window | 1777 | (save-selected-window |
| 1764 | (select-window (posn-window (event-start event))) | 1778 | (select-window (posn-window (event-start event))) |
| @@ -1864,7 +1878,7 @@ the STRINGS are just concatenated and the result truncated." | |||
| 1864 | (defun exit-calendar () | 1878 | (defun exit-calendar () |
| 1865 | "Get out of the calendar window and hide it and related buffers." | 1879 | "Get out of the calendar window and hide it and related buffers." |
| 1866 | (interactive) | 1880 | (interactive) |
| 1867 | (let* ((diary-buffer (get-file-buffer diary-file))) | 1881 | (let ((diary-buffer (get-file-buffer diary-file))) |
| 1868 | (if (or (not diary-buffer) | 1882 | (if (or (not diary-buffer) |
| 1869 | (not (buffer-modified-p diary-buffer)) | 1883 | (not (buffer-modified-p diary-buffer)) |
| 1870 | (yes-or-no-p | 1884 | (yes-or-no-p |
| @@ -1902,7 +1916,7 @@ the STRINGS are just concatenated and the result truncated." | |||
| 1902 | (defun calendar-cursor-to-date (&optional error) | 1916 | (defun calendar-cursor-to-date (&optional error) |
| 1903 | "Return a list (month day year) of current cursor position. | 1917 | "Return a list (month day year) of current cursor position. |
| 1904 | If cursor is not on a specific date, signals an error if optional parameter | 1918 | If cursor is not on a specific date, signals an error if optional parameter |
| 1905 | ERROR is t, otherwise just returns nil." | 1919 | ERROR is non-nil, otherwise just returns nil." |
| 1906 | (let* ((segment (/ (current-column) 25)) | 1920 | (let* ((segment (/ (current-column) 25)) |
| 1907 | (month (% (+ displayed-month segment -1) 12)) | 1921 | (month (% (+ displayed-month segment -1) 12)) |
| 1908 | (month (if (zerop month) 12 month)) | 1922 | (month (if (zerop month) 12 month)) |
| @@ -2002,20 +2016,19 @@ With no prefix argument, push current date onto marked date ring. | |||
| 2002 | With argument ARG, jump to mark, pop it, and put point at end of ring." | 2016 | With argument ARG, jump to mark, pop it, and put point at end of ring." |
| 2003 | (interactive "P") | 2017 | (interactive "P") |
| 2004 | (let ((date (calendar-cursor-to-date t))) | 2018 | (let ((date (calendar-cursor-to-date t))) |
| 2005 | (if (null arg) | 2019 | (if arg |
| 2006 | (progn | 2020 | (if (null calendar-mark-ring) |
| 2007 | (push date calendar-mark-ring) | 2021 | (error "No mark set in this buffer") |
| 2008 | ;; Since the top of the mark ring is the marked date in the | 2022 | (calendar-goto-date (car calendar-mark-ring)) |
| 2009 | ;; calendar, the mark ring in the calendar is one longer than | 2023 | (setq calendar-mark-ring |
| 2010 | ;; in other buffers to get the same effect. | 2024 | (cdr (nconc calendar-mark-ring (list date))))) |
| 2011 | (if (> (length calendar-mark-ring) (1+ mark-ring-max)) | 2025 | (push date calendar-mark-ring) |
| 2012 | (setcdr (nthcdr mark-ring-max calendar-mark-ring) nil)) | 2026 | ;; Since the top of the mark ring is the marked date in the |
| 2013 | (message "Mark set")) | 2027 | ;; calendar, the mark ring in the calendar is one longer than |
| 2014 | (if (null calendar-mark-ring) | 2028 | ;; in other buffers to get the same effect. |
| 2015 | (error "No mark set in this buffer") | 2029 | (if (> (length calendar-mark-ring) (1+ mark-ring-max)) |
| 2016 | (calendar-goto-date (car calendar-mark-ring)) | 2030 | (setcdr (nthcdr mark-ring-max calendar-mark-ring) nil)) |
| 2017 | (setq calendar-mark-ring | 2031 | (message "Mark set")))) |
| 2018 | (cdr (nconc calendar-mark-ring (list date)))))))) | ||
| 2019 | 2032 | ||
| 2020 | (defun calendar-exchange-point-and-mark () | 2033 | (defun calendar-exchange-point-and-mark () |
| 2021 | "Exchange the current cursor position with the marked date." | 2034 | "Exchange the current cursor position with the marked date." |
| @@ -2096,6 +2109,34 @@ element of this array is nil, then the abbreviation will be | |||
| 2096 | constructed as the first `calendar-abbrev-length' characters of the | 2109 | constructed as the first `calendar-abbrev-length' characters of the |
| 2097 | corresponding full name.") | 2110 | corresponding full name.") |
| 2098 | 2111 | ||
| 2112 | (defun calendar-make-alist (sequence &optional start-index filter abbrevs) | ||
| 2113 | "Make an assoc list corresponding to SEQUENCE. | ||
| 2114 | Each element of sequence will be associated with an integer, starting | ||
| 2115 | from 1, or from START-INDEX if that is non-nil. If a sequence ABBREVS | ||
| 2116 | is supplied, the function `calendar-abbrev-construct' is used to | ||
| 2117 | construct abbreviations corresponding to the elements in SEQUENCE. | ||
| 2118 | Each abbreviation is entered into the alist with the same | ||
| 2119 | association index as the full name it represents. | ||
| 2120 | If FILTER is provided, apply it to each key in the alist." | ||
| 2121 | (let ((index 0) | ||
| 2122 | (offset (or start-index 1)) | ||
| 2123 | (aseq (if abbrevs (calendar-abbrev-construct abbrevs sequence))) | ||
| 2124 | (aseqp (if abbrevs (calendar-abbrev-construct abbrevs sequence | ||
| 2125 | 'period))) | ||
| 2126 | alist elem) | ||
| 2127 | (dotimes (i (length sequence) (reverse alist)) | ||
| 2128 | (setq index (+ i offset) | ||
| 2129 | elem (elt sequence i) | ||
| 2130 | alist | ||
| 2131 | (cons (cons (if filter (funcall filter elem) elem) index) alist)) | ||
| 2132 | (if aseq | ||
| 2133 | (setq elem (elt aseq i) | ||
| 2134 | alist (cons (cons (if filter (funcall filter elem) elem) | ||
| 2135 | index) alist))) | ||
| 2136 | (if aseqp | ||
| 2137 | (setq elem (elt aseqp i) | ||
| 2138 | alist (cons (cons (if filter (funcall filter elem) elem) | ||
| 2139 | index) alist)))))) | ||
| 2099 | 2140 | ||
| 2100 | (defun calendar-read-date (&optional noday) | 2141 | (defun calendar-read-date (&optional noday) |
| 2101 | "Prompt for Gregorian date. Return a list (month day year). | 2142 | "Prompt for Gregorian date. Return a list (month day year). |
| @@ -2180,35 +2221,6 @@ the variable `calendar-day-abbrev-array' is used." | |||
| 2180 | calendar-day-name-array) | 2221 | calendar-day-name-array) |
| 2181 | (if absolute date (calendar-day-of-week date)))) | 2222 | (if absolute date (calendar-day-of-week date)))) |
| 2182 | 2223 | ||
| 2183 | (defun calendar-make-alist (sequence &optional start-index filter abbrevs) | ||
| 2184 | "Make an assoc list corresponding to SEQUENCE. | ||
| 2185 | Each element of sequence will be associated with an integer, starting | ||
| 2186 | from 1, or from START-INDEX if that is non-nil. If a sequence ABBREVS | ||
| 2187 | is supplied, the function `calendar-abbrev-construct' is used to | ||
| 2188 | construct abbreviations corresponding to the elements in SEQUENCE. | ||
| 2189 | Each abbreviation is entered into the alist with the same | ||
| 2190 | association index as the full name it represents. | ||
| 2191 | If FILTER is provided, apply it to each key in the alist." | ||
| 2192 | (let ((index 0) | ||
| 2193 | (offset (or start-index 1)) | ||
| 2194 | (aseq (if abbrevs (calendar-abbrev-construct abbrevs sequence))) | ||
| 2195 | (aseqp (if abbrevs (calendar-abbrev-construct abbrevs sequence | ||
| 2196 | 'period))) | ||
| 2197 | alist elem) | ||
| 2198 | (dotimes (i (length sequence) (reverse alist)) | ||
| 2199 | (setq index (+ i offset) | ||
| 2200 | elem (elt sequence i) | ||
| 2201 | alist | ||
| 2202 | (cons (cons (if filter (funcall filter elem) elem) index) alist)) | ||
| 2203 | (if aseq | ||
| 2204 | (setq elem (elt aseq i) | ||
| 2205 | alist (cons (cons (if filter (funcall filter elem) elem) | ||
| 2206 | index) alist))) | ||
| 2207 | (if aseqp | ||
| 2208 | (setq elem (elt aseqp i) | ||
| 2209 | alist (cons (cons (if filter (funcall filter elem) elem) | ||
| 2210 | index) alist)))))) | ||
| 2211 | |||
| 2212 | (defun calendar-month-name (month &optional abbrev) | 2224 | (defun calendar-month-name (month &optional abbrev) |
| 2213 | "Return a string with the name of month number MONTH. | 2225 | "Return a string with the name of month number MONTH. |
| 2214 | Months are numbered from one. Month names are taken from the | 2226 | Months are numbered from one. Month names are taken from the |
| @@ -2354,9 +2366,7 @@ and day names to be abbreviated as specified by | |||
| 2354 | `calendar-month-abbrev-array' and `calendar-day-abbrev-array', | 2366 | `calendar-month-abbrev-array' and `calendar-day-abbrev-array', |
| 2355 | respectively. An optional parameter NODAYNAME, when t, omits the | 2367 | respectively. An optional parameter NODAYNAME, when t, omits the |
| 2356 | name of the day of the week." | 2368 | name of the day of the week." |
| 2357 | (let* ((dayname | 2369 | (let* ((dayname (unless nodayname (calendar-day-name date abbreviate))) |
| 2358 | (unless nodayname | ||
| 2359 | (calendar-day-name date abbreviate))) | ||
| 2360 | (month (extract-calendar-month date)) | 2370 | (month (extract-calendar-month date)) |
| 2361 | (monthname (calendar-month-name month abbreviate)) | 2371 | (monthname (calendar-month-name month abbreviate)) |
| 2362 | (day (int-to-string (extract-calendar-day date))) | 2372 | (day (int-to-string (extract-calendar-day date))) |
| @@ -2418,7 +2428,7 @@ Defaults to today's date if DATE is not given." | |||
| 2418 | (defun calendar-print-other-dates () | 2428 | (defun calendar-print-other-dates () |
| 2419 | "Show dates on other calendars for date under the cursor." | 2429 | "Show dates on other calendars for date under the cursor." |
| 2420 | (interactive) | 2430 | (interactive) |
| 2421 | (let* ((date (calendar-cursor-to-date t))) | 2431 | (let ((date (calendar-cursor-to-date t))) |
| 2422 | (with-current-buffer (get-buffer-create other-calendars-buffer) | 2432 | (with-current-buffer (get-buffer-create other-calendars-buffer) |
| 2423 | (let ((inhibit-read-only t) | 2433 | (let ((inhibit-read-only t) |
| 2424 | (modified (buffer-modified-p))) | 2434 | (modified (buffer-modified-p))) |
| @@ -2473,7 +2483,7 @@ Defaults to today's date if DATE is not given." | |||
| 2473 | "Set mode line to STR, centered, surrounded by dashes." | 2483 | "Set mode line to STR, centered, surrounded by dashes." |
| 2474 | (let* ((edges (window-edges)) | 2484 | (let* ((edges (window-edges)) |
| 2475 | ;; As per doc of window-width, total visible mode-line length. | 2485 | ;; As per doc of window-width, total visible mode-line length. |
| 2476 | (width (- (nth 2 edges) (nth 0 edges)))) | 2486 | (width (- (nth 2 edges) (car edges)))) |
| 2477 | (setq mode-line-format | 2487 | (setq mode-line-format |
| 2478 | (if buffer-file-name | 2488 | (if buffer-file-name |
| 2479 | `("-" mode-line-modified | 2489 | `("-" mode-line-modified |