diff options
| -rw-r--r-- | lisp/calendar/diary-lib.el | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 4a960e0ec49..08eb40b5672 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el | |||
| @@ -583,6 +583,64 @@ is created." | |||
| 583 | (error "Your diary file is not readable!")) | 583 | (error "Your diary file is not readable!")) |
| 584 | (error "You don't have a diary file!")))) | 584 | (error "You don't have a diary file!")))) |
| 585 | 585 | ||
| 586 | |||
| 587 | |||
| 588 | (defcustom diary-mail-addr | ||
| 589 | (if (boundp 'user-mail-address) user-mail-address nil) | ||
| 590 | "*Email address that `diary-mail-entries' will send email to." | ||
| 591 | :group 'diary | ||
| 592 | :type 'string) | ||
| 593 | |||
| 594 | (defcustom diary-mail-days 7 | ||
| 595 | "*Number of days for `diary-mail-entries' to check." | ||
| 596 | :group 'diary | ||
| 597 | :type integer) | ||
| 598 | |||
| 599 | (defun diary-mail-entries (&optional ndays) | ||
| 600 | "Send a mail message showing diary entries for next NDAYS days. | ||
| 601 | If no prefix argument is given, NDAYS is set to `diary-mail-days'. | ||
| 602 | |||
| 603 | You can call `diary-mail-entries' every night using an at/cron job. | ||
| 604 | For example, this script will run the program at 2am daily. Since | ||
| 605 | `emacs -batch' does not load your `.emacs' file, you must ensure that | ||
| 606 | all relevant variables are set, as done here. | ||
| 607 | |||
| 608 | #!/bin/sh | ||
| 609 | # diary-rem.sh -- repeatedly run the Emacs diary-reminder | ||
| 610 | emacs -batch \\ | ||
| 611 | -eval \"(setq diary-mail-days 3 \\ | ||
| 612 | european-calendar-style t \\ | ||
| 613 | diary-mail-addr \\\"user@host.name\\\" )\" \\ | ||
| 614 | -l diary-lib -f diary-mail-entries | ||
| 615 | at -f diary-rem.sh 0200 tomorrow | ||
| 616 | |||
| 617 | You may have to tweak the syntax of the `at' command to suit your | ||
| 618 | system. Alternatively, you can specify a cron entry: | ||
| 619 | 0 1 * * * diary-rem.sh | ||
| 620 | to run it every morning at 1am." | ||
| 621 | (interactive "p") | ||
| 622 | (let ((text nil) | ||
| 623 | ;; Use the fancy-diary-display as it doesn't hide rest of | ||
| 624 | ;; diary file with ^M characters. It also looks nicer. | ||
| 625 | (diary-display-hook 'fancy-diary-display)) | ||
| 626 | (if (not current-prefix-arg) | ||
| 627 | (setq ndays diary-mail-days)) | ||
| 628 | (calendar) | ||
| 629 | (view-diary-entries ndays) | ||
| 630 | (set-buffer "*Fancy Diary Entries*") | ||
| 631 | (setq text (buffer-substring (point-min) (point-max))) | ||
| 632 | |||
| 633 | ;; Now send text as a mail message. | ||
| 634 | (mail) | ||
| 635 | (mail-to) | ||
| 636 | (insert diary-mail-addr) | ||
| 637 | (mail-subject) | ||
| 638 | (insert "Diary entries generated ") | ||
| 639 | (insert (format-time-string "%a %d %b %y" (current-time))) | ||
| 640 | (mail-text) | ||
| 641 | (insert text) | ||
| 642 | (mail-send-and-exit nil))) | ||
| 643 | |||
| 586 | (defun diary-name-pattern (string-array &optional fullname) | 644 | (defun diary-name-pattern (string-array &optional fullname) |
| 587 | "Convert an STRING-ARRAY, an array of strings to a pattern. | 645 | "Convert an STRING-ARRAY, an array of strings to a pattern. |
| 588 | The pattern will match any of the strings, either entirely or abbreviated | 646 | The pattern will match any of the strings, either entirely or abbreviated |