aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-11-17 01:59:28 +0000
committerKarl Heuer1997-11-17 01:59:28 +0000
commita14723d908668d6119eb1c33c18bfb135d439407 (patch)
treeae9cd1d7d097b67ece78c96a93f3cc3996c99cd0
parentbfc7bff6f9d115b945a0de2d0b6b81fda2a83e8c (diff)
downloademacs-a14723d908668d6119eb1c33c18bfb135d439407.tar.gz
emacs-a14723d908668d6119eb1c33c18bfb135d439407.zip
(list-diary-entries, list-sexp-diary-entries, add-to-diary-list):
Add the diary entry "specifier" to the entry on the list. (diary-unknown-time): New variable. (diary-entry-time): Use it.
-rw-r--r--lisp/calendar/diary-lib.el49
1 files changed, 33 insertions, 16 deletions
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index e002958978e..4a960e0ec49 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -205,9 +205,11 @@ for NUMBER days starting with date DATE. The other entries are hidden
205using selective display. 205using selective display.
206 206
207Returns a list of all relevant diary entries found, if any, in order by date. 207Returns a list of all relevant diary entries found, if any, in order by date.
208The list entries have the form ((month day year) string). If the variable 208The list entries have the form ((month day year) string specifier) where
209`diary-list-include-blanks' is t, this list includes a dummy diary entry 209\(month day year) is the date of the entry, string is the entry text, and
210\(consisting of the empty string) for a date with no diary entries. 210specifier is the applicability. If the variable `diary-list-include-blanks'
211is t, this list includes a dummy diary entry consisting of the empty string)
212for a date with no diary entries.
211 213
212After the list is prepared, the hooks `nongregorian-diary-listing-hook', 214After the list is prepared, the hooks `nongregorian-diary-listing-hook',
213`list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run. 215`list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
@@ -318,15 +320,17 @@ These hooks have the following distinct roles:
318 (subst-char-in-region date-start 320 (subst-char-in-region date-start
319 (point) ?\^M ?\n t) 321 (point) ?\^M ?\n t)
320 (add-to-diary-list 322 (add-to-diary-list
321 date 323 date
322 (buffer-substring-no-properties 324 (buffer-substring-no-properties
323 entry-start (point))))))) 325 entry-start (point))
326 (buffer-substring-no-properties
327 (1+ date-start) (1- entry-start)))))))
324 (setq d (cdr d))) 328 (setq d (cdr d)))
325 (or entry-found 329 (or entry-found
326 (not diary-list-include-blanks) 330 (not diary-list-include-blanks)
327 (setq diary-entries-list 331 (setq diary-entries-list
328 (append diary-entries-list 332 (append diary-entries-list
329 (list (list date ""))))) 333 (list (list date "" "")))))
330 (setq date 334 (setq date
331 (calendar-gregorian-from-absolute 335 (calendar-gregorian-from-absolute
332 (1+ (calendar-absolute-from-gregorian date)))) 336 (1+ (calendar-absolute-from-gregorian date))))
@@ -877,11 +881,21 @@ A value of 0 in any position of the pattern is a wildcard."
877 (< (diary-entry-time (car (cdr e1))) 881 (< (diary-entry-time (car (cdr e1)))
878 (diary-entry-time (car (cdr e2))))))) 882 (diary-entry-time (car (cdr e2)))))))
879 883
884(defcustom diary-unknown-time
885 -9999
886 "*Value returned by diary-entry-time when no time is found.
887The default value -9999 causes entries with no recognizable time to be placed
888before those with times; 9999 would place entries with no recognizable time
889after those with times."
890 :type 'integer
891 :group 'diary)
892
880(defun diary-entry-time (s) 893(defun diary-entry-time (s)
881 "Time at the beginning of the string S in a military-style integer. 894 "Time at the beginning of the string S in a military-style integer. For
882For example, returns 1325 for 1:25pm. Returns -9999 if no time is recognized. 895example, returns 1325 for 1:25pm. Returns `diary-unknown-time' (default value
883The recognized forms are XXXX or X:XX or XX:XX (military time), XXam or XXpm, 896-9999) if no time is recognized. The recognized forms are XXXX, X:XX, or
884and XX:XXam or XX:XXpm." 897XX:XX (military time), and XXam, XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm,
898or XX:XXPM."
885 (let ((case-fold-search nil)) 899 (let ((case-fold-search nil))
886 (cond ((string-match;; Military time 900 (cond ((string-match;; Military time
887 "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s) 901 "^[ \t]*\\([0-9]?[0-9]\\):?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" s)
@@ -903,7 +917,7 @@ and XX:XXam or XX:XXpm."
903 (string-to-int (substring s (match-beginning 2) (match-end 2))) 917 (string-to-int (substring s (match-beginning 2) (match-end 2)))
904 (if (equal ?a (downcase (aref s (match-beginning 3)))) 918 (if (equal ?a (downcase (aref s (match-beginning 3))))
905 0 1200))) 919 0 1200)))
906 (t -9999))));; Unrecognizable 920 (t diary-unknown-time))));; Unrecognizable
907 921
908(defun list-sexp-diary-entries (date) 922(defun list-sexp-diary-entries (date)
909 "Add sexp entries for DATE from the diary file to `diary-entries-list'. 923 "Add sexp entries for DATE from the diary file to `diary-entries-list'.
@@ -1068,6 +1082,7 @@ best if they are nonmarking."
1068 (let ((sexp-start (point)) 1082 (let ((sexp-start (point))
1069 (sexp) 1083 (sexp)
1070 (entry) 1084 (entry)
1085 (specifier)
1071 (entry-start) 1086 (entry-start)
1072 (line-start)) 1087 (line-start))
1073 (forward-sexp) 1088 (forward-sexp)
@@ -1075,6 +1090,8 @@ best if they are nonmarking."
1075 (save-excursion 1090 (save-excursion
1076 (re-search-backward "\^M\\|\n\\|\\`") 1091 (re-search-backward "\^M\\|\n\\|\\`")
1077 (setq line-start (point))) 1092 (setq line-start (point)))
1093 (setq specifier
1094 (buffer-substring-no-properties (1+ line-start) (point)))
1078 (forward-char 1) 1095 (forward-char 1)
1079 (if (and (or (char-equal (preceding-char) ?\^M) 1096 (if (and (or (char-equal (preceding-char) ?\^M)
1080 (char-equal (preceding-char) ?\n)) 1097 (char-equal (preceding-char) ?\n))
@@ -1093,7 +1110,7 @@ best if they are nonmarking."
1093 (let ((diary-entry (diary-sexp-entry sexp entry date))) 1110 (let ((diary-entry (diary-sexp-entry sexp entry date)))
1094 (if diary-entry 1111 (if diary-entry
1095 (subst-char-in-region line-start (point) ?\^M ?\n t)) 1112 (subst-char-in-region line-start (point) ?\^M ?\n t))
1096 (add-to-diary-list date diary-entry) 1113 (add-to-diary-list date diary-entry specifier)
1097 (setq entry-found (or entry-found diary-entry))))) 1114 (setq entry-found (or entry-found diary-entry)))))
1098 entry-found)) 1115 entry-found))
1099 1116
@@ -1324,12 +1341,12 @@ a marking or nonmarking one."
1324 (and (or (not marking-diary-entries) marking-diary-entry) 1341 (and (or (not marking-diary-entries) marking-diary-entry)
1325 (eval sexp))))) 1342 (eval sexp)))))
1326 1343
1327(defun add-to-diary-list (date string) 1344(defun add-to-diary-list (date string specifier)
1328 "Add the entry (DATE STRING) to `diary-entries-list'. 1345 "Add the entry (DATE STRING SPECIFIER) to `diary-entries-list'.
1329Do nothing if DATE or STRING is nil." 1346Do nothing if DATE or STRING is nil."
1330 (and date string 1347 (and date string
1331 (setq diary-entries-list 1348 (setq diary-entries-list
1332 (append diary-entries-list (list (list date string)))))) 1349 (append diary-entries-list (list (list date string specifier))))))
1333 1350
1334(defun make-diary-entry (string &optional nonmarking file) 1351(defun make-diary-entry (string &optional nonmarking file)
1335 "Insert a diary entry STRING which may be NONMARKING in FILE. 1352 "Insert a diary entry STRING which may be NONMARKING in FILE.