diff options
| author | Juanma Barranquero | 2003-02-11 23:26:55 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-02-11 23:26:55 +0000 |
| commit | c47a201af79d6295c6bd21d0c563f1eeecef1a50 (patch) | |
| tree | cc98835d2a075d1716f17fac43b082a9ab859559 | |
| parent | d13c137897f5f1da4a06fe0bca8b46fa55bcb8e1 (diff) | |
| download | emacs-c47a201af79d6295c6bd21d0c563f1eeecef1a50.tar.gz emacs-c47a201af79d6295c6bd21d0c563f1eeecef1a50.zip | |
(diary-attrtype-convert): Convert an attribute value string to the desired type.
(diary-pull-attrs): New function that pulls the attributes off a diary entry,
merges with file-global attributes, and returns the (possibly modified) entry
and a list of attribute/values using diary-attrtype-convert above.
(list-diary-entries, fancy-diary-display, show-all-diary-entries)
(mark-diary-entries, mark-sexp-diary-entries, list-sexp-diary-entries): Add
handling of file-global attributes, add handling of entry attributes using
diary-pull-attrs above.
(mark-calendar-days-named, mark-calendar-days-named, mark-calendar-date-pattern)
(mark-calendar-month, add-to-diary-list): Add optional paramater `color' for
passing face attribute info through the callchain. Pass this parameter around.
| -rw-r--r-- | lisp/ChangeLog | 36 | ||||
| -rw-r--r-- | lisp/calendar/diary-lib.el | 243 |
2 files changed, 224 insertions, 55 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 18564b43c6d..661f697c045 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,39 @@ | |||
| 1 | 2003-02-12 Ami Fischman <ami@fischman.org> | ||
| 2 | |||
| 3 | Face markup of calendar and diary displays: Any entry line that | ||
| 4 | ends with [foo:value] where foo is a face attribute (except :box | ||
| 5 | :stipple) or with [face:blah] tags, will have these values applied | ||
| 6 | to the calendar and fancy diary displays. These attributes "stack" | ||
| 7 | on calendar displays. File-wide attributes can be defined as | ||
| 8 | follows: the first line matching "^# [tag:value]" defines the | ||
| 9 | value for that particular tag. All of the tags' regexps can be | ||
| 10 | customized. | ||
| 11 | |||
| 12 | * calendar/calendar.el (diary-face-attrs): New custom. | ||
| 13 | (diary-file-name-prefix-function): New custom. | ||
| 14 | (diary-glob-file-regexp-prefix): New custom. | ||
| 15 | (diary-file-name-prefix): New custom. | ||
| 16 | (generate-calendar-window): Check that font-lock-mode is bound | ||
| 17 | before checking value. | ||
| 18 | (mark-visible-calendar-date): Add the ability to pass face | ||
| 19 | attribute/value pairs in the mark argument. Handle the mark. | ||
| 20 | |||
| 21 | * diary-lib.el (diary-attrtype-convert): Convert an attribute | ||
| 22 | value string to the desired type. | ||
| 23 | (diary-pull-attrs): New function that pulls the attributes off a | ||
| 24 | diary entry, merges with file-global attributes, and returns | ||
| 25 | the (possibly modified) entry and a list of attribute/values using | ||
| 26 | diary-attrtype-convert. | ||
| 27 | (list-diary-entries, fancy-diary-display, show-all-diary-entries) | ||
| 28 | (mark-diary-entries, mark-sexp-diary-entries) | ||
| 29 | (list-sexp-diary-entries): Add handling of file-global attributes; | ||
| 30 | add handling of entry attributes using diary-pull-attrs. | ||
| 31 | (mark-calendar-days-named, mark-calendar-days-named) | ||
| 32 | (mark-calendar-date-pattern, mark-calendar-month) | ||
| 33 | (add-to-diary-list): Add optional paramater `color' for passing | ||
| 34 | face attribute info through the callchain. Pass this parameter | ||
| 35 | around. | ||
| 36 | |||
| 1 | 2003-02-11 John Paul Wallington <jpw@gnu.org> | 37 | 2003-02-11 John Paul Wallington <jpw@gnu.org> |
| 2 | 38 | ||
| 3 | * ibuffer.el (toplevel): Don't require `font-lock'; | 39 | * ibuffer.el (toplevel): Don't require `font-lock'; |
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index f83ba4eb134..b403e600152 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el | |||
| @@ -185,6 +185,82 @@ syntax of `*' changed to be a word constituent.") | |||
| 185 | (defvar d-file) | 185 | (defvar d-file) |
| 186 | (defvar original-date) | 186 | (defvar original-date) |
| 187 | 187 | ||
| 188 | (defun diary-attrtype-convert (attrvalue type) | ||
| 189 | "Convert the attrvalue from a string to the appropriate type for using | ||
| 190 | in a face description" | ||
| 191 | (let (ret) | ||
| 192 | (setq ret (cond ((eq type 'string) attrvalue) | ||
| 193 | ((eq type 'symbol) (read attrvalue)) | ||
| 194 | ((eq type 'int) (string-to-int attrvalue)) | ||
| 195 | ((eq type 'stringtnil) | ||
| 196 | (cond ((string= "t" attrvalue) t) | ||
| 197 | ((string= "nil" attrvalue) nil) | ||
| 198 | (t attrvalue))) | ||
| 199 | ((eq type 'tnil) | ||
| 200 | (cond ((string= "t" attrvalue) t) | ||
| 201 | ((string= "nil" attrvalue) nil))))) | ||
| 202 | ; (message "(%s)[%s]=[%s]" (print type) attrvalue ret) | ||
| 203 | ret)) | ||
| 204 | |||
| 205 | |||
| 206 | (defun diary-pull-attrs (entry fileglobattrs) | ||
| 207 | "Pull the face-related attributes off the entry, merge with the | ||
| 208 | fileglobattrs, and return the (possibly modified) entry and face | ||
| 209 | data in a list of attrname attrvalue values. | ||
| 210 | The entry will be modified to drop all tags that are used for face matching. | ||
| 211 | If entry is nil, then the fileglobattrs are being searched for, | ||
| 212 | the fileglobattrs variable is ignored, and | ||
| 213 | diary-glob-file-regexp-prefix is prepended to the regexps before each | ||
| 214 | search." | ||
| 215 | (save-excursion | ||
| 216 | (let (regexp regnum attrname attr-list attrname attrvalue type) | ||
| 217 | (if (null entry) | ||
| 218 | (progn | ||
| 219 | (setq ret-attr '() | ||
| 220 | attr-list diary-face-attrs) | ||
| 221 | (while attr-list | ||
| 222 | (goto-char (point-min)) | ||
| 223 | (setq attr (car attr-list) | ||
| 224 | regexp (nth 0 attr) | ||
| 225 | regnum (nth 1 attr) | ||
| 226 | attrname (nth 2 attr) | ||
| 227 | type (nth 3 attr) | ||
| 228 | regexp (concat diary-glob-file-regexp-prefix regexp)) | ||
| 229 | (setq attrvalue nil) | ||
| 230 | (if (re-search-forward regexp (point-max) t) | ||
| 231 | (setq attrvalue (buffer-substring-no-properties | ||
| 232 | (match-beginning regnum) | ||
| 233 | (match-end regnum)))) | ||
| 234 | (if (and attrvalue | ||
| 235 | (setq attrvalue (diary-attrtype-convert attrvalue type))) | ||
| 236 | (setq ret-attr (append ret-attr (list attrname attrvalue)))) | ||
| 237 | (setq attr-list (cdr attr-list))) | ||
| 238 | (setq fileglobattrs ret-attr)) | ||
| 239 | (progn | ||
| 240 | (setq ret-attr fileglobattrs | ||
| 241 | attr-list diary-face-attrs) | ||
| 242 | (while attr-list | ||
| 243 | (goto-char (point-min)) | ||
| 244 | (setq attr (car attr-list) | ||
| 245 | regexp (nth 0 attr) | ||
| 246 | regnum (nth 1 attr) | ||
| 247 | attrname (nth 2 attr) | ||
| 248 | type (nth 3 attr)) | ||
| 249 | (setq attrvalue nil) | ||
| 250 | (if (string-match regexp entry) | ||
| 251 | (progn | ||
| 252 | (setq attrvalue (substring-no-properties entry | ||
| 253 | (match-beginning regnum) | ||
| 254 | (match-end regnum))) | ||
| 255 | (setq entry (replace-match "" t t entry)))) | ||
| 256 | (if (and attrvalue | ||
| 257 | (setq attrvalue (diary-attrtype-convert attrvalue type))) | ||
| 258 | (setq ret-attr (append ret-attr (list attrname attrvalue)))) | ||
| 259 | (setq attr-list (cdr attr-list))))))) | ||
| 260 | (list entry ret-attr)) | ||
| 261 | |||
| 262 | |||
| 263 | |||
| 188 | (defun list-diary-entries (date number) | 264 | (defun list-diary-entries (date number) |
| 189 | "Create and display a buffer containing the relevant lines in diary-file. | 265 | "Create and display a buffer containing the relevant lines in diary-file. |
| 190 | The arguments are DATE and NUMBER; the entries selected are those | 266 | The arguments are DATE and NUMBER; the entries selected are those |
| @@ -223,6 +299,7 @@ These hooks have the following distinct roles: | |||
| 223 | (let* ((original-date date);; save for possible use in the hooks | 299 | (let* ((original-date date);; save for possible use in the hooks |
| 224 | old-diary-syntax-table | 300 | old-diary-syntax-table |
| 225 | diary-entries-list | 301 | diary-entries-list |
| 302 | file-glob-attrs | ||
| 226 | (date-string (calendar-date-string date)) | 303 | (date-string (calendar-date-string date)) |
| 227 | (d-file (substitute-in-file-name diary-file))) | 304 | (d-file (substitute-in-file-name diary-file))) |
| 228 | (message "Preparing diary...") | 305 | (message "Preparing diary...") |
| @@ -233,6 +310,7 @@ These hooks have the following distinct roles: | |||
| 233 | (set-buffer diary-buffer) | 310 | (set-buffer diary-buffer) |
| 234 | (or (verify-visited-file-modtime diary-buffer) | 311 | (or (verify-visited-file-modtime diary-buffer) |
| 235 | (revert-buffer t t)))) | 312 | (revert-buffer t t)))) |
| 313 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil ""))) | ||
| 236 | (setq selective-display t) | 314 | (setq selective-display t) |
| 237 | (setq selective-display-ellipses nil) | 315 | (setq selective-display-ellipses nil) |
| 238 | (setq old-diary-syntax-table (syntax-table)) | 316 | (setq old-diary-syntax-table (syntax-table)) |
| @@ -308,19 +386,22 @@ These hooks have the following distinct roles: | |||
| 308 | (backward-char 1) | 386 | (backward-char 1) |
| 309 | (subst-char-in-region date-start | 387 | (subst-char-in-region date-start |
| 310 | (point) ?\^M ?\n t) | 388 | (point) ?\^M ?\n t) |
| 389 | (setq entry (buffer-substring entry-start (point)) | ||
| 390 | temp (diary-pull-attrs entry file-glob-attrs) | ||
| 391 | entry (nth 0 temp) | ||
| 392 | marks (nth 1 temp)) | ||
| 311 | (add-to-diary-list | 393 | (add-to-diary-list |
| 312 | date | 394 | date |
| 313 | (buffer-substring | 395 | entry |
| 314 | entry-start (point)) | ||
| 315 | (buffer-substring | 396 | (buffer-substring |
| 316 | (1+ date-start) (1- entry-start)) | 397 | (1+ date-start) (1- entry-start)) |
| 317 | (copy-marker entry-start)))))) | 398 | (copy-marker entry-start) marks))))) |
| 318 | (setq d (cdr d))) | 399 | (setq d (cdr d))) |
| 319 | (or entry-found | 400 | (or entry-found |
| 320 | (not diary-list-include-blanks) | 401 | (not diary-list-include-blanks) |
| 321 | (setq diary-entries-list | 402 | (setq diary-entries-list |
| 322 | (append diary-entries-list | 403 | (append diary-entries-list |
| 323 | (list (list date "" ""))))) | 404 | (list (list date "" "" "" ""))))) |
| 324 | (setq date | 405 | (setq date |
| 325 | (calendar-gregorian-from-absolute | 406 | (calendar-gregorian-from-absolute |
| 326 | (1+ (calendar-absolute-from-gregorian date)))) | 407 | (1+ (calendar-absolute-from-gregorian date)))) |
| @@ -513,13 +594,33 @@ This function is provided for optional use as the `diary-display-hook'." | |||
| 513 | date-holiday-list | 594 | date-holiday-list |
| 514 | (concat "\n" (make-string l ? )))) | 595 | (concat "\n" (make-string l ? )))) |
| 515 | (insert ?\n (make-string (+ l longest) ?=) ?\n))))) | 596 | (insert ?\n (make-string (+ l longest) ?=) ?\n))))) |
| 516 | (if (< 0 (length (car (cdr (car entry-list))))) | 597 | |
| 517 | (if (nth 3 (car entry-list)) | 598 | (setq entry (car (cdr (car entry-list)))) |
| 518 | (insert-button (concat (car (cdr (car entry-list))) "\n") | 599 | (if (< 0 (length entry)) |
| 519 | 'marker (nth 3 (car entry-list)) | 600 | (progn |
| 520 | :type 'diary-entry) | 601 | (if (nth 3 (car entry-list)) |
| 521 | (insert (car (cdr (car entry-list))) ?\n))) | 602 | (insert-button (concat entry "\n") |
| 522 | (setq entry-list (cdr entry-list)))) | 603 | 'marker (nth 3 (car entry-list)) |
| 604 | :type 'diary-entry) | ||
| 605 | (insert entry ?\n)) | ||
| 606 | (save-excursion | ||
| 607 | (setq marks (nth 4 (car entry-list))) | ||
| 608 | (setq temp-face (make-symbol (apply 'concat "temp-face-" (mapcar '(lambda (sym) (if (not (stringp sym)) (symbol-name sym) sym)) marks)))) | ||
| 609 | (make-face temp-face) | ||
| 610 | ;; Remove :face info from the marks, copy the face info into temp-face | ||
| 611 | (setq faceinfo marks) | ||
| 612 | (while (setq faceinfo (memq :face faceinfo)) | ||
| 613 | (copy-face (read (nth 1 faceinfo)) temp-face) | ||
| 614 | (setcar faceinfo nil) | ||
| 615 | (setcar (cdr faceinfo) nil)) | ||
| 616 | (setq marks (delq nil marks)) | ||
| 617 | ;; Apply the font aspects | ||
| 618 | (apply 'set-face-attribute temp-face nil marks) | ||
| 619 | (search-backward entry) | ||
| 620 | (overlay-put | ||
| 621 | (make-overlay (match-beginning 0) (match-end 0)) 'face temp-face)) | ||
| 622 | )) | ||
| 623 | (setq entry-list (cdr entry-list)))) | ||
| 523 | (set-buffer-modified-p nil) | 624 | (set-buffer-modified-p nil) |
| 524 | (goto-char (point-min)) | 625 | (goto-char (point-min)) |
| 525 | (setq buffer-read-only t) | 626 | (setq buffer-read-only t) |
| @@ -690,13 +791,16 @@ After the entries are marked, the hooks `nongregorian-diary-marking-hook' and | |||
| 690 | `mark-diary-entries-hook' are run." | 791 | `mark-diary-entries-hook' are run." |
| 691 | (interactive) | 792 | (interactive) |
| 692 | (setq mark-diary-entries-in-calendar t) | 793 | (setq mark-diary-entries-in-calendar t) |
| 693 | (let ((d-file (substitute-in-file-name diary-file)) | 794 | (let (file-glob-attrs |
| 795 | marks | ||
| 796 | (d-file (substitute-in-file-name diary-file)) | ||
| 694 | (marking-diary-entries t)) | 797 | (marking-diary-entries t)) |
| 695 | (if (and d-file (file-exists-p d-file)) | 798 | (if (and d-file (file-exists-p d-file)) |
| 696 | (if (file-readable-p d-file) | 799 | (if (file-readable-p d-file) |
| 697 | (save-excursion | 800 | (save-excursion |
| 698 | (message "Marking diary entries...") | 801 | (message "Marking diary entries...") |
| 699 | (set-buffer (find-file-noselect d-file t)) | 802 | (set-buffer (find-file-noselect d-file t)) |
| 803 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))) | ||
| 700 | (let ((d diary-date-forms) | 804 | (let ((d diary-date-forms) |
| 701 | (old-diary-syntax-table)) | 805 | (old-diary-syntax-table)) |
| 702 | (setq old-diary-syntax-table (syntax-table)) | 806 | (setq old-diary-syntax-table (syntax-table)) |
| @@ -774,27 +878,32 @@ After the entries are marked, the hooks `nongregorian-diary-marking-hook' and | |||
| 774 | (if (> (- current-y y) 50) | 878 | (if (> (- current-y y) 50) |
| 775 | (+ y 100) | 879 | (+ y 100) |
| 776 | y))) | 880 | y))) |
| 777 | (string-to-int y-str))))) | 881 | (string-to-int y-str)))) |
| 778 | (if dd-name | 882 | (save-excursion |
| 779 | (mark-calendar-days-named | 883 | (setq entry (buffer-substring-no-properties (point) (line-end-position)) |
| 780 | (cdr (assoc-ignore-case | 884 | temp (diary-pull-attrs entry file-glob-attrs) |
| 781 | (substring dd-name 0 3) | 885 | entry (nth 0 temp) |
| 782 | (calendar-make-alist | 886 | marks (nth 1 temp)))) |
| 783 | calendar-day-name-array | 887 | (if dd-name |
| 784 | 0 | 888 | (mark-calendar-days-named |
| 785 | (lambda (x) (substring x 0 3)))))) | 889 | (cdr (assoc-ignore-case |
| 786 | (if mm-name | 890 | (substring dd-name 0 3) |
| 787 | (if (string-equal mm-name "*") | 891 | (calendar-make-alist |
| 788 | (setq mm 0) | 892 | calendar-day-name-array |
| 789 | (setq mm | 893 | 0 |
| 790 | (cdr (assoc-ignore-case | 894 | (lambda (x) (substring x 0 3))))) marks) |
| 791 | (substring mm-name 0 3) | 895 | (if mm-name |
| 792 | (calendar-make-alist | 896 | (if (string-equal mm-name "*") |
| 793 | calendar-month-name-array | 897 | (setq mm 0) |
| 794 | 1 | 898 | (setq mm |
| 795 | (lambda (x) (substring x 0 3))) | 899 | (cdr (assoc-ignore-case |
| 796 | ))))) | 900 | (substring mm-name 0 3) |
| 797 | (mark-calendar-date-pattern mm dd yy)))) | 901 | (calendar-make-alist |
| 902 | calendar-month-name-array | ||
| 903 | 1 | ||
| 904 | (lambda (x) (substring x 0 3))) | ||
| 905 | ))))) | ||
| 906 | (mark-calendar-date-pattern mm dd yy marks)))) | ||
| 798 | (setq d (cdr d)))) | 907 | (setq d (cdr d)))) |
| 799 | (mark-sexp-diary-entries) | 908 | (mark-sexp-diary-entries) |
| 800 | (run-hooks 'nongregorian-diary-marking-hook | 909 | (run-hooks 'nongregorian-diary-marking-hook |
| @@ -817,7 +926,9 @@ is marked. See the documentation for the function `list-sexp-diary-entries'." | |||
| 817 | (y) | 926 | (y) |
| 818 | (first-date) | 927 | (first-date) |
| 819 | (last-date) | 928 | (last-date) |
| 820 | (mark)) | 929 | (mark) |
| 930 | file-glob-attrs) | ||
| 931 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))) | ||
| 821 | (save-excursion | 932 | (save-excursion |
| 822 | (set-buffer calendar-buffer) | 933 | (set-buffer calendar-buffer) |
| 823 | (setq m displayed-month) | 934 | (setq m displayed-month) |
| @@ -867,10 +978,16 @@ is marked. See the documentation for the function `list-sexp-diary-entries'." | |||
| 867 | (calendar-for-loop date from first-date to last-date do | 978 | (calendar-for-loop date from first-date to last-date do |
| 868 | (if (setq mark (diary-sexp-entry sexp entry | 979 | (if (setq mark (diary-sexp-entry sexp entry |
| 869 | (calendar-gregorian-from-absolute date))) | 980 | (calendar-gregorian-from-absolute date))) |
| 870 | (mark-visible-calendar-date | 981 | (progn |
| 871 | (calendar-gregorian-from-absolute date) | 982 | (setq marks (diary-pull-attrs entry file-glob-attrs) |
| 872 | (if (consp mark) | 983 | temp (diary-pull-attrs entry file-glob-attrs) |
| 873 | (car mark))))))))) | 984 | marks (nth 1 temp)) |
| 985 | (mark-visible-calendar-date | ||
| 986 | (calendar-gregorian-from-absolute date) | ||
| 987 | (if (< 0 (length marks)) | ||
| 988 | marks | ||
| 989 | (if (consp mark) | ||
| 990 | (car mark))))))))))) | ||
| 874 | 991 | ||
| 875 | (defun mark-included-diary-files () | 992 | (defun mark-included-diary-files () |
| 876 | "Mark the diary entries from other diary files with those of the diary file. | 993 | "Mark the diary entries from other diary files with those of the diary file. |
| @@ -905,7 +1022,7 @@ changing the variable `diary-include-string'." | |||
| 905 | (sleep-for 2)))) | 1022 | (sleep-for 2)))) |
| 906 | (goto-char (point-min))) | 1023 | (goto-char (point-min))) |
| 907 | 1024 | ||
| 908 | (defun mark-calendar-days-named (dayname) | 1025 | (defun mark-calendar-days-named (dayname &optional color) |
| 909 | "Mark all dates in the calendar window that are day DAYNAME of the week. | 1026 | "Mark all dates in the calendar window that are day DAYNAME of the week. |
| 910 | 0 means all Sundays, 1 means all Mondays, and so on." | 1027 | 0 means all Sundays, 1 means all Mondays, and so on." |
| 911 | (save-excursion | 1028 | (save-excursion |
| @@ -923,10 +1040,10 @@ changing the variable `diary-include-string'." | |||
| 923 | (setq last-day (calendar-absolute-from-gregorian | 1040 | (setq last-day (calendar-absolute-from-gregorian |
| 924 | (calendar-nth-named-day -1 dayname succ-month succ-year))) | 1041 | (calendar-nth-named-day -1 dayname succ-month succ-year))) |
| 925 | (while (<= day last-day) | 1042 | (while (<= day last-day) |
| 926 | (mark-visible-calendar-date (calendar-gregorian-from-absolute day)) | 1043 | (mark-visible-calendar-date (calendar-gregorian-from-absolute day) color) |
| 927 | (setq day (+ day 7)))))) | 1044 | (setq day (+ day 7)))))) |
| 928 | 1045 | ||
| 929 | (defun mark-calendar-date-pattern (month day year) | 1046 | (defun mark-calendar-date-pattern (month day year &optional color) |
| 930 | "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR. | 1047 | "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR. |
| 931 | A value of 0 in any position is a wildcard." | 1048 | A value of 0 in any position is a wildcard." |
| 932 | (save-excursion | 1049 | (save-excursion |
| @@ -935,10 +1052,10 @@ A value of 0 in any position is a wildcard." | |||
| 935 | (y displayed-year)) | 1052 | (y displayed-year)) |
| 936 | (increment-calendar-month m y -1) | 1053 | (increment-calendar-month m y -1) |
| 937 | (calendar-for-loop i from 0 to 2 do | 1054 | (calendar-for-loop i from 0 to 2 do |
| 938 | (mark-calendar-month m y month day year) | 1055 | (mark-calendar-month m y month day year color) |
| 939 | (increment-calendar-month m y 1))))) | 1056 | (increment-calendar-month m y 1))))) |
| 940 | 1057 | ||
| 941 | (defun mark-calendar-month (month year p-month p-day p-year) | 1058 | (defun mark-calendar-month (month year p-month p-day p-year &optional color) |
| 942 | "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR. | 1059 | "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR. |
| 943 | A value of 0 in any position of the pattern is a wildcard." | 1060 | A value of 0 in any position of the pattern is a wildcard." |
| 944 | (if (or (and (= month p-month) | 1061 | (if (or (and (= month p-month) |
| @@ -948,8 +1065,8 @@ A value of 0 in any position of the pattern is a wildcard." | |||
| 948 | (if (= p-day 0) | 1065 | (if (= p-day 0) |
| 949 | (calendar-for-loop | 1066 | (calendar-for-loop |
| 950 | i from 1 to (calendar-last-day-of-month month year) do | 1067 | i from 1 to (calendar-last-day-of-month month year) do |
| 951 | (mark-visible-calendar-date (list month i year))) | 1068 | (mark-visible-calendar-date (list month i year) color)) |
| 952 | (mark-visible-calendar-date (list month p-day year))))) | 1069 | (mark-visible-calendar-date (list month p-day year) color)))) |
| 953 | 1070 | ||
| 954 | (defun sort-diary-entries () | 1071 | (defun sort-diary-entries () |
| 955 | "Sort the list of diary entries by time of day." | 1072 | "Sort the list of diary entries by time of day." |
| @@ -1170,8 +1287,12 @@ best if they are nonmarking." | |||
| 1170 | (let* ((mark (regexp-quote diary-nonmarking-symbol)) | 1287 | (let* ((mark (regexp-quote diary-nonmarking-symbol)) |
| 1171 | (sexp-mark (regexp-quote sexp-diary-entry-symbol)) | 1288 | (sexp-mark (regexp-quote sexp-diary-entry-symbol)) |
| 1172 | (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" mark "?" sexp-mark "(")) | 1289 | (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" mark "?" sexp-mark "(")) |
| 1173 | (entry-found)) | 1290 | (entry-found) |
| 1291 | (file-glob-attrs) | ||
| 1292 | (marks)) | ||
| 1174 | (goto-char (point-min)) | 1293 | (goto-char (point-min)) |
| 1294 | (save-excursion | ||
| 1295 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))) | ||
| 1175 | (while (re-search-forward s-entry nil t) | 1296 | (while (re-search-forward s-entry nil t) |
| 1176 | (backward-char 1) | 1297 | (backward-char 1) |
| 1177 | (let ((sexp-start (point)) | 1298 | (let ((sexp-start (point)) |
| @@ -1204,15 +1325,22 @@ best if they are nonmarking." | |||
| 1204 | (while (string-match "[\^M]" entry) | 1325 | (while (string-match "[\^M]" entry) |
| 1205 | (aset entry (match-beginning 0) ?\n ))) | 1326 | (aset entry (match-beginning 0) ?\n ))) |
| 1206 | (let ((diary-entry (diary-sexp-entry sexp entry date))) | 1327 | (let ((diary-entry (diary-sexp-entry sexp entry date))) |
| 1328 | (setq entry (if (consp diary-entry) | ||
| 1329 | (cdr diary-entry) | ||
| 1330 | diary-entry)) | ||
| 1207 | (if diary-entry | 1331 | (if diary-entry |
| 1208 | (subst-char-in-region line-start (point) ?\^M ?\n t)) | 1332 | (progn |
| 1209 | (add-to-diary-list date | 1333 | (subst-char-in-region line-start (point) ?\^M ?\n t) |
| 1210 | (if (consp diary-entry) | 1334 | (if (< 0 (length entry)) |
| 1211 | (cdr diary-entry) | 1335 | (setq temp (diary-pull-attrs entry file-glob-attrs) |
| 1212 | diary-entry) | 1336 | entry (nth 0 temp) |
| 1337 | marks (nth 1 temp))))) | ||
| 1338 | (add-to-diary-list date | ||
| 1339 | entry | ||
| 1213 | specifier | 1340 | specifier |
| 1214 | (if entry-start (copy-marker entry-start) | 1341 | (if entry-start (copy-marker entry-start) |
| 1215 | nil)) | 1342 | nil) |
| 1343 | marks) | ||
| 1216 | (setq entry-found (or entry-found diary-entry))))) | 1344 | (setq entry-found (or entry-found diary-entry))))) |
| 1217 | entry-found)) | 1345 | entry-found)) |
| 1218 | 1346 | ||
| @@ -1470,13 +1598,18 @@ marked on the calendar." | |||
| 1470 | (or (diary-remind sexp (car days) marking) | 1598 | (or (diary-remind sexp (car days) marking) |
| 1471 | (diary-remind sexp (cdr days) marking)))))) | 1599 | (diary-remind sexp (cdr days) marking)))))) |
| 1472 | 1600 | ||
| 1473 | (defun add-to-diary-list (date string specifier marker) | 1601 | (defun add-to-diary-list (date string specifier marker &optional globcolor) |
| 1474 | "Add the entry (DATE STRING SPECIFIER) to `diary-entries-list'. | 1602 | "Add the entry (DATE STRING SPECIFIER MARKER GLOBCOLOR) to `diary-entries-list'. |
| 1475 | Do nothing if DATE or STRING is nil." | 1603 | Do nothing if DATE or STRING is nil." |
| 1476 | (and date string | 1604 | (and date string |
| 1605 | (if (and diary-file-name-prefix | ||
| 1606 | (setq prefix (concat "[" (funcall diary-file-name-prefix-function (buffer-file-name)) "] ")) | ||
| 1607 | (not (string= prefix "[] "))) | ||
| 1608 | (setq string (concat prefix string)) | ||
| 1609 | t) | ||
| 1477 | (setq diary-entries-list | 1610 | (setq diary-entries-list |
| 1478 | (append diary-entries-list | 1611 | (append diary-entries-list |
| 1479 | (list (list date string specifier marker)))))) | 1612 | (list (list date string specifier marker globcolor)))))) |
| 1480 | 1613 | ||
| 1481 | (defun make-diary-entry (string &optional nonmarking file) | 1614 | (defun make-diary-entry (string &optional nonmarking file) |
| 1482 | "Insert a diary entry STRING which may be NONMARKING in FILE. | 1615 | "Insert a diary entry STRING which may be NONMARKING in FILE. |