Mercurial > emacs
comparison lisp/calendar/calendar.el @ 90228:fa0da9b57058
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-82
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 542-553)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 116-121)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 19 Sep 2005 10:20:33 +0000 |
parents | 2d92f5c9d6ae a08c0922f1c4 |
children | ee12d75eb214 |
comparison
equal
deleted
inserted
replaced
90227:10fe5fadaf89 | 90228:fa0da9b57058 |
---|---|
162 be overridden by the value of `calendar-setup'." | 162 be overridden by the value of `calendar-setup'." |
163 :type 'boolean | 163 :type 'boolean |
164 :group 'diary) | 164 :group 'diary) |
165 | 165 |
166 ;;;###autoload | 166 ;;;###autoload |
167 (defcustom number-of-diary-entries 1 | |
168 "*Specifies how many days of diary entries are to be displayed initially. | |
169 This variable affects the diary display when the command \\[diary] is used, | |
170 or if the value of the variable `view-diary-entries-initially' is t. For | |
171 example, if the default value 1 is used, then only the current day's diary | |
172 entries will be displayed. If the value 2 is used, then both the current | |
173 day's and the next day's entries will be displayed. | |
174 | |
175 The value can also be a vector such as [0 2 2 2 2 4 1]; this value | |
176 says to display no diary entries on Sunday, the display the entries | |
177 for the current date and the day after on Monday through Thursday, | |
178 display Friday through Monday's entries on Friday, and display only | |
179 Saturday's entries on Saturday. | |
180 | |
181 This variable does not affect the diary display with the `d' command | |
182 from the calendar; in that case, the prefix argument controls the | |
183 number of days of diary entries displayed." | |
184 :type '(choice (integer :tag "Entries") | |
185 (vector :value [0 0 0 0 0 0 0] | |
186 (integer :tag "Sunday") | |
187 (integer :tag "Monday") | |
188 (integer :tag "Tuesday") | |
189 (integer :tag "Wednesday") | |
190 (integer :tag "Thursday") | |
191 (integer :tag "Friday") | |
192 (integer :tag "Saturday"))) | |
193 :group 'diary) | |
194 | |
195 ;;;###autoload | |
196 (defcustom mark-diary-entries-in-calendar nil | 167 (defcustom mark-diary-entries-in-calendar nil |
197 "*Non-nil means mark dates with diary entries, in the calendar window. | 168 "*Non-nil means mark dates with diary entries, in the calendar window. |
198 The marking symbol is specified by the variable `diary-entry-marker'." | 169 The marking symbol is specified by the variable `diary-entry-marker'." |
199 :type 'boolean | 170 :type 'boolean |
200 :group 'diary) | 171 :group 'diary) |
391 (defcustom calendar-move-hook nil | 362 (defcustom calendar-move-hook nil |
392 "*List of functions called whenever the cursor moves in the calendar. | 363 "*List of functions called whenever the cursor moves in the calendar. |
393 | 364 |
394 For example, | 365 For example, |
395 | 366 |
396 (add-hook 'calendar-move-hook (lambda () (view-diary-entries 1))) | 367 (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1))) |
397 | 368 |
398 redisplays the diary for whatever date the cursor is moved to." | 369 redisplays the diary for whatever date the cursor is moved to." |
399 :type 'hook | 370 :type 'hook |
400 :group 'calendar-hooks) | 371 :group 'calendar-hooks) |
401 | 372 |
1333 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) | 1304 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) |
1334 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc | 1305 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc |
1335 | 1306 |
1336 (defmacro calendar-for-loop (var from init to final do &rest body) | 1307 (defmacro calendar-for-loop (var from init to final do &rest body) |
1337 "Execute a for loop." | 1308 "Execute a for loop." |
1309 (declare (debug (symbolp "from" form "to" form "do" body))) | |
1338 `(let ((,var (1- ,init))) | 1310 `(let ((,var (1- ,init))) |
1339 (while (>= ,final (setq ,var (1+ ,var))) | 1311 (while (>= ,final (setq ,var (1+ ,var))) |
1340 ,@body))) | 1312 ,@body))) |
1341 | 1313 |
1342 (defmacro calendar-sum (index initial condition expression) | 1314 (defmacro calendar-sum (index initial condition expression) |
1649 (year (extract-calendar-year date))) | 1621 (year (extract-calendar-year date))) |
1650 (pop-to-buffer calendar-buffer) | 1622 (pop-to-buffer calendar-buffer) |
1651 (increment-calendar-month month year (- calendar-offset)) | 1623 (increment-calendar-month month year (- calendar-offset)) |
1652 (generate-calendar-window month year) | 1624 (generate-calendar-window month year) |
1653 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) | 1625 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) |
1654 (view-diary-entries | 1626 (diary-view-entries))) |
1655 (if (vectorp number-of-diary-entries) | |
1656 (aref number-of-diary-entries (calendar-day-of-week date)) | |
1657 number-of-diary-entries)))) | |
1658 (let* ((diary-buffer (get-file-buffer diary-file)) | 1627 (let* ((diary-buffer (get-file-buffer diary-file)) |
1659 (diary-window (if diary-buffer (get-buffer-window diary-buffer))) | 1628 (diary-window (if diary-buffer (get-buffer-window diary-buffer))) |
1660 (split-height-threshold (if diary-window 2 1000))) | 1629 (split-height-threshold (if diary-window 2 1000))) |
1661 (if view-calendar-holidays-initially | 1630 (if view-calendar-holidays-initially |
1662 (list-calendar-holidays))) | 1631 (list-calendar-holidays))) |
1663 (run-hooks 'initial-calendar-window-hook)) | 1632 (run-hooks 'initial-calendar-window-hook)) |
1664 | 1633 |
1665 (autoload 'view-diary-entries "diary-lib" | 1634 (autoload 'diary-view-entries "diary-lib" |
1666 "Prepare and display a buffer with diary entries. | 1635 "Prepare and display a buffer with diary entries. |
1667 Searches your diary file for entries that match ARG days starting with | 1636 Searches your diary file for entries that match ARG days starting with |
1668 the date indicated by the cursor position in the displayed three-month | 1637 the date indicated by the cursor position in the displayed three-month |
1669 calendar." | 1638 calendar." |
1670 t) | 1639 t) |
2270 (define-key calendar-mode-map "a" 'list-calendar-holidays) | 2239 (define-key calendar-mode-map "a" 'list-calendar-holidays) |
2271 (define-key calendar-mode-map "h" 'calendar-cursor-holidays) | 2240 (define-key calendar-mode-map "h" 'calendar-cursor-holidays) |
2272 (define-key calendar-mode-map "x" 'mark-calendar-holidays) | 2241 (define-key calendar-mode-map "x" 'mark-calendar-holidays) |
2273 (define-key calendar-mode-map "u" 'calendar-unmark) | 2242 (define-key calendar-mode-map "u" 'calendar-unmark) |
2274 (define-key calendar-mode-map "m" 'mark-diary-entries) | 2243 (define-key calendar-mode-map "m" 'mark-diary-entries) |
2275 (define-key calendar-mode-map "d" 'view-diary-entries) | 2244 (define-key calendar-mode-map "d" 'diary-view-entries) |
2276 (define-key calendar-mode-map "D" 'view-other-diary-entries) | 2245 (define-key calendar-mode-map "D" 'view-other-diary-entries) |
2277 (define-key calendar-mode-map "s" 'show-all-diary-entries) | 2246 (define-key calendar-mode-map "s" 'show-all-diary-entries) |
2278 (define-key calendar-mode-map "pd" 'calendar-print-day-of-year) | 2247 (define-key calendar-mode-map "pd" 'calendar-print-day-of-year) |
2279 (define-key calendar-mode-map "pC" 'calendar-print-chinese-date) | 2248 (define-key calendar-mode-map "pC" 'calendar-print-chinese-date) |
2280 (define-key calendar-mode-map "pk" 'calendar-print-coptic-date) | 2249 (define-key calendar-mode-map "pk" 'calendar-print-coptic-date) |
2491 (substring s 0 length))) | 2460 (substring s 0 length))) |
2492 | 2461 |
2493 (defun update-calendar-mode-line () | 2462 (defun update-calendar-mode-line () |
2494 "Update the calendar mode line with the current date and date style." | 2463 "Update the calendar mode line with the current date and date style." |
2495 (if (bufferp (get-buffer calendar-buffer)) | 2464 (if (bufferp (get-buffer calendar-buffer)) |
2496 (save-excursion | 2465 (with-current-buffer calendar-buffer |
2497 (set-buffer calendar-buffer) | |
2498 (setq mode-line-format | 2466 (setq mode-line-format |
2499 (calendar-string-spread | 2467 (calendar-string-spread |
2500 (let ((date (condition-case nil | 2468 (let ((date (condition-case nil |
2501 (calendar-cursor-to-nearest-date) | 2469 (calendar-cursor-to-nearest-date) |
2502 (error (calendar-current-date))))) | 2470 (error (calendar-current-date))))) |
2587 (if (not (looking-at " ")) | 2555 (if (not (looking-at " ")) |
2588 (re-search-backward "[^0-9]")) | 2556 (re-search-backward "[^0-9]")) |
2589 (list month | 2557 (list month |
2590 (string-to-number (buffer-substring (1+ (point)) (+ 4 (point)))) | 2558 (string-to-number (buffer-substring (1+ (point)) (+ 4 (point)))) |
2591 year)) | 2559 year)) |
2592 (if (looking-at "\\*") | 2560 (if (and (looking-at "\\*") |
2593 (save-excursion | 2561 (save-excursion |
2594 (re-search-backward "[^*]") | 2562 (re-search-backward "[^*]") |
2595 (if (looking-at ".\\*\\*") | 2563 (looking-at ".\\*\\*"))) |
2596 (list month calendar-starred-day year) | 2564 (list month calendar-starred-day year) |
2597 (if error (error "Not on a date!")))) | |
2598 (if error (error "Not on a date!")))))) | 2565 (if error (error "Not on a date!")))))) |
2566 | |
2567 (add-to-list 'debug-ignored-errors "Not on a date!") | |
2599 | 2568 |
2600 ;; The following version of calendar-gregorian-from-absolute is preferred for | 2569 ;; The following version of calendar-gregorian-from-absolute is preferred for |
2601 ;; reasons of clarity, BUT it's much slower than the version that follows it. | 2570 ;; reasons of clarity, BUT it's much slower than the version that follows it. |
2602 | 2571 |
2603 ;;(defun calendar-gregorian-from-absolute (date) | 2572 ;;(defun calendar-gregorian-from-absolute (date) |
3069 | 3038 |
3070 (defun calendar-print-other-dates () | 3039 (defun calendar-print-other-dates () |
3071 "Show dates on other calendars for date under the cursor." | 3040 "Show dates on other calendars for date under the cursor." |
3072 (interactive) | 3041 (interactive) |
3073 (let* ((date (calendar-cursor-to-date t))) | 3042 (let* ((date (calendar-cursor-to-date t))) |
3074 (save-excursion | 3043 (with-current-buffer (get-buffer-create other-calendars-buffer) |
3075 (set-buffer (get-buffer-create other-calendars-buffer)) | |
3076 (setq buffer-read-only nil) | 3044 (setq buffer-read-only nil) |
3077 (calendar-set-mode-line | 3045 (calendar-set-mode-line |
3078 (concat (calendar-date-string date) " (Gregorian)")) | 3046 (concat (calendar-date-string date) " (Gregorian)")) |
3079 (erase-buffer) | 3047 (erase-buffer) |
3080 (insert | 3048 (insert |
3136 | 3104 |
3137 (run-hooks 'calendar-load-hook) | 3105 (run-hooks 'calendar-load-hook) |
3138 | 3106 |
3139 (provide 'calendar) | 3107 (provide 'calendar) |
3140 | 3108 |
3141 ;;; Local variables: | 3109 ;; Local variables: |
3142 ;;; byte-compile-dynamic: t | 3110 ;; byte-compile-dynamic: t |
3143 ;;; End: | 3111 ;; End: |
3144 | 3112 |
3145 ;;; arch-tag: 19c61596-c8fb-4c69-bcf1-7dd739919cd8 | 3113 ;; arch-tag: 19c61596-c8fb-4c69-bcf1-7dd739919cd8 |
3146 ;;; calendar.el ends here | 3114 ;;; calendar.el ends here |