comparison lisp/calendar/diary-lib.el @ 46826:e020f18c490a

(diary-mail-entries): Use `compose-mail' and `mail-user-agent' instead of straight sendmail. (diary-modified, diary-entries-list, displayed-year) (displayed-month, entry, date, number, date-string, d-file) (original-date): defvar without binding to avoid compiler warnings.
author Sam Steingold <sds@gnu.org>
date Tue, 06 Aug 2002 15:11:26 +0000
parents f367f20901c0
children 88f34e3227e6
comparison
equal deleted inserted replaced
46825:f43392bbb789 46826:e020f18c490a
172 syntax of `*' changed to be a word constituent.") 172 syntax of `*' changed to be a word constituent.")
173 173
174 (modify-syntax-entry ?* "w" diary-syntax-table) 174 (modify-syntax-entry ?* "w" diary-syntax-table)
175 (modify-syntax-entry ?: "w" diary-syntax-table) 175 (modify-syntax-entry ?: "w" diary-syntax-table)
176 176
177 (defvar diary-modified)
178 (defvar diary-entries-list)
179 (defvar displayed-year)
180 (defvar displayed-month)
181 (defvar entry)
182 (defvar date)
183 (defvar number)
184 (defvar date-string)
185 (defvar d-file)
186 (defvar original-date)
187
177 (defun list-diary-entries (date number) 188 (defun list-diary-entries (date number)
178 "Create and display a buffer containing the relevant lines in diary-file. 189 "Create and display a buffer containing the relevant lines in diary-file.
179 The arguments are DATE and NUMBER; the entries selected are those 190 The arguments are DATE and NUMBER; the entries selected are those
180 for NUMBER days starting with date DATE. The other entries are hidden 191 for NUMBER days starting with date DATE. The other entries are hidden
181 using selective display. 192 using selective display.
208 `diary-hook' is run last. This can be used for an appointment 219 `diary-hook' is run last. This can be used for an appointment
209 notification function." 220 notification function."
210 221
211 (if (< 0 number) 222 (if (< 0 number)
212 (let* ((original-date date);; save for possible use in the hooks 223 (let* ((original-date date);; save for possible use in the hooks
213 (old-diary-syntax-table) 224 old-diary-syntax-table
214 (diary-entries-list) 225 diary-entries-list
215 (date-string (calendar-date-string date)) 226 (date-string (calendar-date-string date))
216 (d-file (substitute-in-file-name diary-file))) 227 (d-file (substitute-in-file-name diary-file)))
217 (message "Preparing diary...") 228 (message "Preparing diary...")
218 (save-excursion 229 (save-excursion
219 (let ((diary-buffer (find-buffer-visiting d-file))) 230 (let ((diary-buffer (find-buffer-visiting d-file)))
614 (diary-list-include-blanks t) 625 (diary-list-include-blanks t)
615 (text (progn (list-diary-entries (calendar-current-date) 626 (text (progn (list-diary-entries (calendar-current-date)
616 (if ndays ndays diary-mail-days)) 627 (if ndays ndays diary-mail-days))
617 (set-buffer fancy-diary-buffer) 628 (set-buffer fancy-diary-buffer)
618 (buffer-substring (point-min) (point-max))))) 629 (buffer-substring (point-min) (point-max)))))
619 (mail) 630 (compose-mail diary-mail-addr
620 (mail-to) (insert diary-mail-addr) 631 (concat "Diary entries generated "
621 (mail-subject) (insert "Diary entries generated " 632 (calendar-date-string (calendar-current-date))))
622 (calendar-date-string (calendar-current-date))) 633 (insert text)
623 (mail-text) (insert text) 634 (funcall (get mail-user-agent 'sendfunc))))
624 (mail-send-and-exit nil)))
625 635
626 636
627 (defun diary-name-pattern (string-array &optional fullname) 637 (defun diary-name-pattern (string-array &optional fullname)
628 "Convert an STRING-ARRAY, an array of strings to a pattern. 638 "Convert an STRING-ARRAY, an array of strings to a pattern.
629 The pattern will match any of the strings, either entirely or abbreviated 639 The pattern will match any of the strings, either entirely or abbreviated
833 (aset entry (match-beginning 0) ?\n ))) 843 (aset entry (match-beginning 0) ?\n )))
834 (calendar-for-loop date from first-date to last-date do 844 (calendar-for-loop date from first-date to last-date do
835 (if (setq mark (diary-sexp-entry sexp entry 845 (if (setq mark (diary-sexp-entry sexp entry
836 (calendar-gregorian-from-absolute date))) 846 (calendar-gregorian-from-absolute date)))
837 (mark-visible-calendar-date 847 (mark-visible-calendar-date
838 (calendar-gregorian-from-absolute date) 848 (calendar-gregorian-from-absolute date)
839 (if (consp mark) 849 (if (consp mark)
840 (car mark))))))))) 850 (car mark)))))))))
841 851
842 (defun mark-included-diary-files () 852 (defun mark-included-diary-files ()
843 "Mark the diary entries from other diary files with those of the diary file. 853 "Mark the diary entries from other diary files with those of the diary file.
1001 %%(diary-date MONTH DAY YEAR &optional MARK) text 1011 %%(diary-date MONTH DAY YEAR &optional MARK) text
1002 Entry applies if date is MONTH, DAY, YEAR if 1012 Entry applies if date is MONTH, DAY, YEAR if
1003 `european-calendar-style' is nil, and DAY, MONTH, YEAR if 1013 `european-calendar-style' is nil, and DAY, MONTH, YEAR if
1004 `european-calendar-style' is t. DAY, MONTH, and YEAR 1014 `european-calendar-style' is t. DAY, MONTH, and YEAR
1005 can be lists of integers, the constant t, or an integer. 1015 can be lists of integers, the constant t, or an integer.
1006 The constant t means all values. An optional parameter 1016 The constant t means all values. An optional parameter
1007 MARK specifies a face or single-character string to use 1017 MARK specifies a face or single-character string to use
1008 when highlighting the day in the calendar. 1018 when highlighting the day in the calendar.
1009 1019
1010 %%(diary-float MONTH DAYNAME N &optional DAY MARK) text 1020 %%(diary-float MONTH DAYNAME N &optional DAY MARK) text
1011 Entry will appear on the Nth DAYNAME of MONTH. 1021 Entry will appear on the Nth DAYNAME of MONTH.
1012 (DAYNAME=0 means Sunday, 1 means Monday, and so on; 1022 (DAYNAME=0 means Sunday, 1 means Monday, and so on;
1013 if N is negative it counts backward from the end of 1023 if N is negative it counts backward from the end of
1014 the month. MONTH can be a list of months, a single 1024 the month. MONTH can be a list of months, a single
1015 month, or t to specify all months. Optional DAY means 1025 month, or t to specify all months. Optional DAY means
1016 Nth DAYNAME of MONTH on or after/before DAY. DAY defaults 1026 Nth DAYNAME of MONTH on or after/before DAY. DAY defaults
1017 to 1 if N>0 and the last day of the month if N<0. An 1027 to 1 if N>0 and the last day of the month if N<0. An
1018 optional parameter MARK specifies a face or single-character 1028 optional parameter MARK specifies a face or single-character
1019 string to use when highlighting the day in the calendar. 1029 string to use when highlighting the day in the calendar.
1020 1030
1021 %%(diary-block M1 D1 Y1 M2 D2 Y2 &optional MARK) text 1031 %%(diary-block M1 D1 Y1 M2 D2 Y2 &optional MARK) text
1022 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2, 1032 Entry will appear on dates between M1/D1/Y1 and M2/D2/Y2,
1023 inclusive. (If `european-calendar-style' is t, the 1033 inclusive. (If `european-calendar-style' is t, the
1024 order of the parameters should be changed to D1, M1, Y1, 1034 order of the parameters should be changed to D1, M1, Y1,
1025 D2, M2, Y2.) An optional parameter MARK specifies a face 1035 D2, M2, Y2.) An optional parameter MARK specifies a face
1026 or single-character string to use when highlighting the 1036 or single-character string to use when highlighting the
1027 day in the calendar. 1037 day in the calendar.
1028 1038
1029 %%(diary-anniversary MONTH DAY YEAR &optional MARK) text 1039 %%(diary-anniversary MONTH DAY YEAR &optional MARK) text
1030 Entry will appear on anniversary dates of MONTH DAY, YEAR. 1040 Entry will appear on anniversary dates of MONTH DAY, YEAR.
1031 (If `european-calendar-style' is t, the order of the 1041 (If `european-calendar-style' is t, the order of the
1032 parameters should be changed to DAY, MONTH, YEAR.) Text 1042 parameters should be changed to DAY, MONTH, YEAR.) Text
1033 can contain %d or %d%s; %d will be replaced by the number 1043 can contain %d or %d%s; %d will be replaced by the number
1034 of years since the MONTH DAY, YEAR and %s will be replaced 1044 of years since the MONTH DAY, YEAR and %s will be replaced
1035 by the ordinal ending of that number (that is, `st', `nd', 1045 by the ordinal ending of that number (that is, `st', `nd',
1036 `rd' or `th', as appropriate. The anniversary of February 1046 `rd' or `th', as appropriate. The anniversary of February
1037 29 is considered to be March 1 in a non-leap year. An 1047 29 is considered to be March 1 in a non-leap year. An
1038 optional parameter MARK specifies a face or single-character 1048 optional parameter MARK specifies a face or single-character
1039 string to use when highlighting the day in the calendar. 1049 string to use when highlighting the day in the calendar.
1040 1050
1041 %%(diary-cyclic N MONTH DAY YEAR &optional MARK) text 1051 %%(diary-cyclic N MONTH DAY YEAR &optional MARK) text
1042 Entry will appear every N days, starting MONTH DAY, YEAR. 1052 Entry will appear every N days, starting MONTH DAY, YEAR.
1043 (If `european-calendar-style' is t, the order of the 1053 (If `european-calendar-style' is t, the order of the
1044 parameters should be changed to N, DAY, MONTH, YEAR.) Text 1054 parameters should be changed to N, DAY, MONTH, YEAR.) Text
1045 can contain %d or %d%s; %d will be replaced by the number 1055 can contain %d or %d%s; %d will be replaced by the number
1046 of repetitions since the MONTH DAY, YEAR and %s will 1056 of repetitions since the MONTH DAY, YEAR and %s will
1047 be replaced by the ordinal ending of that number (that is, 1057 be replaced by the ordinal ending of that number (that is,
1048 `st', `nd', `rd' or `th', as appropriate. An optional 1058 `st', `nd', `rd' or `th', as appropriate. An optional
1049 parameter MARK specifies a face or single-character string 1059 parameter MARK specifies a face or single-character string
1050 to use when highlighting the day in the calendar. 1060 to use when highlighting the day in the calendar.
1051 1061
1052 %%(diary-remind SEXP DAYS &optional MARKING) text 1062 %%(diary-remind SEXP DAYS &optional MARKING) text
1053 Entry is a reminder for diary sexp SEXP. DAYS is either a 1063 Entry is a reminder for diary sexp SEXP. DAYS is either a
1054 single number or a list of numbers indicating the number(s) 1064 single number or a list of numbers indicating the number(s)
1170 (while (string-match "[\^M]" entry) 1180 (while (string-match "[\^M]" entry)
1171 (aset entry (match-beginning 0) ?\n ))) 1181 (aset entry (match-beginning 0) ?\n )))
1172 (let ((diary-entry (diary-sexp-entry sexp entry date))) 1182 (let ((diary-entry (diary-sexp-entry sexp entry date)))
1173 (if diary-entry 1183 (if diary-entry
1174 (subst-char-in-region line-start (point) ?\^M ?\n t)) 1184 (subst-char-in-region line-start (point) ?\^M ?\n t))
1175 (add-to-diary-list date 1185 (add-to-diary-list date
1176 (if (consp diary-entry) 1186 (if (consp diary-entry)
1177 (cdr diary-entry) 1187 (cdr diary-entry)
1178 diary-entry) 1188 diary-entry)
1179 specifier) 1189 specifier)
1180 (setq entry-found (or entry-found diary-entry))))) 1190 (setq entry-found (or entry-found diary-entry)))))
1211 Entry applies if date is MONTH, DAY, YEAR if `european-calendar-style' is nil, 1221 Entry applies if date is MONTH, DAY, YEAR if `european-calendar-style' is nil,
1212 and DAY, MONTH, YEAR if `european-calendar-style' is t. DAY, MONTH, and YEAR 1222 and DAY, MONTH, YEAR if `european-calendar-style' is t. DAY, MONTH, and YEAR
1213 can be lists of integers, the constant t, or an integer. The constant t means 1223 can be lists of integers, the constant t, or an integer. The constant t means
1214 all values. 1224 all values.
1215 1225
1216 An optional parameter MARK specifies a face or single-character string to 1226 An optional parameter MARK specifies a face or single-character string to
1217 use when highlighting the day in the calendar." 1227 use when highlighting the day in the calendar."
1218 (let* ((dd (if european-calendar-style 1228 (let* ((dd (if european-calendar-style
1219 month 1229 month
1220 day)) 1230 day))
1221 (mm (if european-calendar-style 1231 (mm (if european-calendar-style
1241 Entry applies if date is between, or on one of, two dates. 1251 Entry applies if date is between, or on one of, two dates.
1242 The order of the parameters is 1252 The order of the parameters is
1243 M1, D1, Y1, M2, D2, Y2 if `european-calendar-style' is nil, and 1253 M1, D1, Y1, M2, D2, Y2 if `european-calendar-style' is nil, and
1244 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t. 1254 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t.
1245 1255
1246 An optional parameter MARK specifies a face or single-character string to 1256 An optional parameter MARK specifies a face or single-character string to
1247 use when highlighting the day in the calendar." 1257 use when highlighting the day in the calendar."
1248 1258
1249 (let ((date1 (calendar-absolute-from-gregorian 1259 (let ((date1 (calendar-absolute-from-gregorian
1250 (if european-calendar-style 1260 (if european-calendar-style
1251 (list d1 m1 y1) 1261 (list d1 m1 y1)
1263 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant 1273 Parameters are MONTH, DAYNAME, N. MONTH can be a list of months, the constant
1264 t, or an integer. The constant t means all months. If N is negative, count 1274 t, or an integer. The constant t means all months. If N is negative, count
1265 backward from the end of the month. 1275 backward from the end of the month.
1266 1276
1267 An optional parameter DAY means the Nth DAYNAME on or after/before MONTH DAY. 1277 An optional parameter DAY means the Nth DAYNAME on or after/before MONTH DAY.
1268 Optional MARK specifies a face or single-character string to use when 1278 Optional MARK specifies a face or single-character string to use when
1269 highlighting the day in the calendar." 1279 highlighting the day in the calendar."
1270 ;; This is messy because the diary entry may apply, but the date on which it 1280 ;; This is messy because the diary entry may apply, but the date on which it
1271 ;; is based can be in a different month/year. For example, asking for the 1281 ;; is based can be in a different month/year. For example, asking for the
1272 ;; first Monday after December 30. For large values of |n| the problem is 1282 ;; first Monday after December 30. For large values of |n| the problem is
1273 ;; more grotesque. 1283 ;; more grotesque.
1331 %d will be replaced by the number of years since the MONTH DAY, YEAR and the 1341 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
1332 %s will be replaced by the ordinal ending of that number (that is, `st', `nd', 1342 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
1333 `rd' or `th', as appropriate. The anniversary of February 29 is considered 1343 `rd' or `th', as appropriate. The anniversary of February 29 is considered
1334 to be March 1 in non-leap years. 1344 to be March 1 in non-leap years.
1335 1345
1336 An optional parameter MARK specifies a face or single-character string to 1346 An optional parameter MARK specifies a face or single-character string to
1337 use when highlighting the day in the calendar." 1347 use when highlighting the day in the calendar."
1338 (let* ((d (if european-calendar-style 1348 (let* ((d (if european-calendar-style
1339 month 1349 month
1340 day)) 1350 day))
1341 (m (if european-calendar-style 1351 (m (if european-calendar-style
1355 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of 1365 ENTRY can contain `%d' or `%d%s'; the %d will be replaced by the number of
1356 repetitions since the MONTH DAY, YEAR and %s will be replaced by the 1366 repetitions since the MONTH DAY, YEAR and %s will be replaced by the
1357 ordinal ending of that number (that is, `st', `nd', `rd' or `th', as 1367 ordinal ending of that number (that is, `st', `nd', `rd' or `th', as
1358 appropriate. 1368 appropriate.
1359 1369
1360 An optional parameter MARK specifies a face or single-character string to 1370 An optional parameter MARK specifies a face or single-character string to
1361 use when highlighting the day in the calendar." 1371 use when highlighting the day in the calendar."
1362 (let* ((d (if european-calendar-style 1372 (let* ((d (if european-calendar-style
1363 month 1373 month
1364 day)) 1374 day))
1365 (m (if european-calendar-style 1375 (m (if european-calendar-style