Mercurial > emacs
comparison lisp/calendar/diary-lib.el @ 39615:4287ce76bf9f
(diary-entry-compare): When times are identical, compare the entries
lexicographically.
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Fri, 05 Oct 2001 15:53:02 +0000 |
parents | 7a94f1c588c4 |
children | 82d4ad3abe8c |
comparison
equal
deleted
inserted
replaced
39614:fc453faec402 | 39615:4287ce76bf9f |
---|---|
329 (buffer-substring-no-properties | 329 (buffer-substring-no-properties |
330 (1+ date-start) (1- entry-start))))))) | 330 (1+ date-start) (1- entry-start))))))) |
331 (setq d (cdr d))) | 331 (setq d (cdr d))) |
332 (or entry-found | 332 (or entry-found |
333 (not diary-list-include-blanks) | 333 (not diary-list-include-blanks) |
334 (setq diary-entries-list | 334 (setq diary-entries-list |
335 (append diary-entries-list | 335 (append diary-entries-list |
336 (list (list date "" ""))))) | 336 (list (list date "" ""))))) |
337 (setq date | 337 (setq date |
338 (calendar-gregorian-from-absolute | 338 (calendar-gregorian-from-absolute |
339 (1+ (calendar-absolute-from-gregorian date)))) | 339 (1+ (calendar-absolute-from-gregorian date)))) |
595 (error "Your diary file is not readable!")) | 595 (error "Your diary file is not readable!")) |
596 (error "You don't have a diary file!")))) | 596 (error "You don't have a diary file!")))) |
597 | 597 |
598 | 598 |
599 | 599 |
600 (defcustom diary-mail-addr | 600 (defcustom diary-mail-addr |
601 (if (boundp 'user-mail-address) user-mail-address nil) | 601 (if (boundp 'user-mail-address) user-mail-address nil) |
602 "*Email address that `diary-mail-entries' will send email to." | 602 "*Email address that `diary-mail-entries' will send email to." |
603 :group 'diary | 603 :group 'diary |
604 :type '(choice string (const nil)) | 604 :type '(choice string (const nil)) |
605 :version "20.3") | 605 :version "20.3") |
624 # diary-rem.sh -- repeatedly run the Emacs diary-reminder | 624 # diary-rem.sh -- repeatedly run the Emacs diary-reminder |
625 emacs -batch \\ | 625 emacs -batch \\ |
626 -eval \"(setq diary-mail-days 3 \\ | 626 -eval \"(setq diary-mail-days 3 \\ |
627 european-calendar-style t \\ | 627 european-calendar-style t \\ |
628 diary-mail-addr \\\"user@host.name\\\" )\" \\ | 628 diary-mail-addr \\\"user@host.name\\\" )\" \\ |
629 -l diary-lib -f diary-mail-entries | 629 -l diary-lib -f diary-mail-entries |
630 at -f diary-rem.sh 0200 tomorrow | 630 at -f diary-rem.sh 0200 tomorrow |
631 | 631 |
632 You may have to tweak the syntax of the `at' command to suit your | 632 You may have to tweak the syntax of the `at' command to suit your |
633 system. Alternatively, you can specify a cron entry: | 633 system. Alternatively, you can specify a cron entry: |
634 0 1 * * * diary-rem.sh | 634 0 1 * * * diary-rem.sh |
945 | 945 |
946 (defun diary-entry-compare (e1 e2) | 946 (defun diary-entry-compare (e1 e2) |
947 "Returns t if E1 is earlier than E2." | 947 "Returns t if E1 is earlier than E2." |
948 (or (calendar-date-compare e1 e2) | 948 (or (calendar-date-compare e1 e2) |
949 (and (calendar-date-equal (car e1) (car e2)) | 949 (and (calendar-date-equal (car e1) (car e2)) |
950 (< (diary-entry-time (car (cdr e1))) | 950 (let* ((ts1 (cadr e1)) (t1 (diary-entry-time ts1)) |
951 (diary-entry-time (car (cdr e2))))))) | 951 (ts2 (cadr e2)) (t2 (diary-entry-time ts2))) |
952 (or (< t1 t2) | |
953 (and (= t1 t2) | |
954 (string-lessp ts1 ts2))))))) | |
952 | 955 |
953 (defcustom diary-unknown-time | 956 (defcustom diary-unknown-time |
954 -9999 | 957 -9999 |
955 "*Value returned by diary-entry-time when no time is found. | 958 "*Value returned by diary-entry-time when no time is found. |
956 The default value -9999 causes entries with no recognizable time to be placed | 959 The default value -9999 causes entries with no recognizable time to be placed |
957 before those with times; 9999 would place entries with no recognizable time | 960 before those with times; 9999 would place entries with no recognizable time |
958 after those with times." | 961 after those with times." |
959 :type 'integer | 962 :type 'integer |
960 :group 'diary | 963 :group 'diary |
961 :version "20.3") | 964 :version "20.3") |
962 | 965 |
963 (defun diary-entry-time (s) | 966 (defun diary-entry-time (s) |
964 "Time at the beginning of the string S in a military-style integer. For | 967 "Time at the beginning of the string S in a military-style integer. For |
965 example, returns 1325 for 1:25pm. Returns `diary-unknown-time' (default value | 968 example, returns 1325 for 1:25pm. Returns `diary-unknown-time' (default value |
966 -9999) if no time is recognized. The recognized forms are XXXX, X:XX, or | 969 -9999) if no time is recognized. The recognized forms are XXXX, X:XX, or |
967 XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm, | 970 XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm, |
968 or XX:XXPM." | 971 or XX:XXPM." |
969 (let ((case-fold-search nil)) | 972 (let ((case-fold-search nil)) |
970 (cond ((string-match;; Military time | 973 (cond ((string-match ; Military time |
971 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s) | 974 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s) |
972 (+ (* 100 (string-to-int | 975 (+ (* 100 (string-to-int |
973 (substring s (match-beginning 1) (match-end 1)))) | 976 (substring s (match-beginning 1) (match-end 1)))) |
974 (string-to-int (substring s (match-beginning 2) (match-end 2))))) | 977 (string-to-int (substring s (match-beginning 2) (match-end 2))))) |
975 ((string-match;; Hour only XXam or XXpm | 978 ((string-match ; Hour only XXam or XXpm |
976 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s) | 979 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s) |
977 (+ (* 100 (% (string-to-int | 980 (+ (* 100 (% (string-to-int |
978 (substring s (match-beginning 1) (match-end 1))) | 981 (substring s (match-beginning 1) (match-end 1))) |
979 12)) | 982 12)) |
980 (if (equal ?a (downcase (aref s (match-beginning 2)))) | 983 (if (equal ?a (downcase (aref s (match-beginning 2)))) |
981 0 1200))) | 984 0 1200))) |
982 ((string-match;; Hour and minute XX:XXam or XX:XXpm | 985 ((string-match ; Hour and minute XX:XXam or XX:XXpm |
983 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s) | 986 "\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\):\\([0-9][0-9]\\)\\([ap]\\)m\\>" s) |
984 (+ (* 100 (% (string-to-int | 987 (+ (* 100 (% (string-to-int |
985 (substring s (match-beginning 1) (match-end 1))) | 988 (substring s (match-beginning 1) (match-end 1))) |
986 12)) | 989 12)) |
987 (string-to-int (substring s (match-beginning 2) (match-end 2))) | 990 (string-to-int (substring s (match-beginning 2) (match-end 2))) |
988 (if (equal ?a (downcase (aref s (match-beginning 3)))) | 991 (if (equal ?a (downcase (aref s (match-beginning 3)))) |
989 0 1200))) | 992 0 1200))) |
990 (t diary-unknown-time))));; Unrecognizable | 993 (t diary-unknown-time)))) ; Unrecognizable |
991 | |
992 ;; Unrecognizable | |
993 | 994 |
994 (defun list-sexp-diary-entries (date) | 995 (defun list-sexp-diary-entries (date) |
995 "Add sexp entries for DATE from the diary file to `diary-entries-list'. | 996 "Add sexp entries for DATE from the diary file to `diary-entries-list'. |
996 Also, Make them visible in the diary file. Returns t if any entries were | 997 Also, Make them visible in the diary file. Returns t if any entries were |
997 found. | 998 found. |
1124 Text is assumed to be the name of the person; the date is | 1125 Text is assumed to be the name of the person; the date is |
1125 the date of death on the *civil* calendar. The diary entry | 1126 the date of death on the *civil* calendar. The diary entry |
1126 will appear on the proper Hebrew-date anniversary and on the | 1127 will appear on the proper Hebrew-date anniversary and on the |
1127 day before. (If `european-calendar-style' is t, the order | 1128 day before. (If `european-calendar-style' is t, the order |
1128 of the parameters should be changed to DAY, MONTH, YEAR.) | 1129 of the parameters should be changed to DAY, MONTH, YEAR.) |
1129 | 1130 |
1130 %%(diary-rosh-hodesh) | 1131 %%(diary-rosh-hodesh) |
1131 Diary entries will be made on the dates of Rosh Hodesh on | 1132 Diary entries will be made on the dates of Rosh Hodesh on |
1132 the Hebrew calendar. Note that since there is no text, it | 1133 the Hebrew calendar. Note that since there is no text, it |
1133 makes sense only if the fancy diary display is used. | 1134 makes sense only if the fancy diary display is used. |
1134 | 1135 |
1380 (concat (int-to-string days) (if (= 1 days) " day" " days"))) | 1381 (concat (int-to-string days) (if (= 1 days) " day" " days"))) |
1381 " until " | 1382 " until " |
1382 diary-entry) | 1383 diary-entry) |
1383 "*Pseudo-pattern giving form of reminder messages in the fancy diary | 1384 "*Pseudo-pattern giving form of reminder messages in the fancy diary |
1384 display. | 1385 display. |
1385 | 1386 |
1386 Used by the function `diary-remind', a pseudo-pattern is a list of | 1387 Used by the function `diary-remind', a pseudo-pattern is a list of |
1387 expressions that can involve the keywords `days' (a number), `date' (a list of | 1388 expressions that can involve the keywords `days' (a number), `date' (a list of |
1388 month, day, year), and `diary-entry' (a string)." | 1389 month, day, year), and `diary-entry' (a string)." |
1389 :type 'sexp | 1390 :type 'sexp |
1390 :group 'diary) | 1391 :group 'diary) |
1426 | 1427 |
1427 (defun add-to-diary-list (date string specifier) | 1428 (defun add-to-diary-list (date string specifier) |
1428 "Add the entry (DATE STRING SPECIFIER) to `diary-entries-list'. | 1429 "Add the entry (DATE STRING SPECIFIER) to `diary-entries-list'. |
1429 Do nothing if DATE or STRING is nil." | 1430 Do nothing if DATE or STRING is nil." |
1430 (and date string | 1431 (and date string |
1431 (setq diary-entries-list | 1432 (setq diary-entries-list |
1432 (append diary-entries-list (list (list date string specifier)))))) | 1433 (append diary-entries-list (list (list date string specifier)))))) |
1433 | 1434 |
1434 (defun make-diary-entry (string &optional nonmarking file) | 1435 (defun make-diary-entry (string &optional nonmarking file) |
1435 "Insert a diary entry STRING which may be NONMARKING in FILE. | 1436 "Insert a diary entry STRING which may be NONMARKING in FILE. |
1436 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file." | 1437 If omitted, NONMARKING defaults to nil and FILE defaults to diary-file." |