aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1997-11-25 04:00:20 +0000
committerRichard M. Stallman1997-11-25 04:00:20 +0000
commit8ffbfaa96516203a8786a4f3285fe60f7eaecdaf (patch)
tree0859387a0867659233eddb238fac0b791252971b /lisp
parent85d27e9b108fc1da9fe8c5ba587dce4fa2bad2d9 (diff)
downloademacs-8ffbfaa96516203a8786a4f3285fe60f7eaecdaf.tar.gz
emacs-8ffbfaa96516203a8786a4f3285fe60f7eaecdaf.zip
(diary-mail-addr, diary-mail-days): New variables.
(diary-mail-entries): New function.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/calendar/diary-lib.el58
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.
601If no prefix argument is given, NDAYS is set to `diary-mail-days'.
602
603You can call `diary-mail-entries' every night using an at/cron job.
604For example, this script will run the program at 2am daily. Since
605`emacs -batch' does not load your `.emacs' file, you must ensure that
606all relevant variables are set, as done here.
607
608#!/bin/sh
609# diary-rem.sh -- repeatedly run the Emacs diary-reminder
610emacs -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
615at -f diary-rem.sh 0200 tomorrow
616
617You may have to tweak the syntax of the `at' command to suit your
618system. Alternatively, you can specify a cron entry:
6190 1 * * * diary-rem.sh
620to 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.
588The pattern will match any of the strings, either entirely or abbreviated 646The pattern will match any of the strings, either entirely or abbreviated