以下是如何检查由生成的项目的文本属性以及如何org-agenda-list
根据某些条件修改字符串的示例。在此示例中,将ts-date
获取text属性的值并将其与当前日期进行比较-如果过期,则添加OLD:
; 如果是当前,则添加CURRENT:
,如果是未来,则添加FUTURE:
。原始张贴者可以自定义此示例,在选定位置添加新行和/或分隔线。自定义设置可能会有所不同,具体取决于原始海报在中选择的排序标准org-agenda-sorting-strategy
等。
在此示例中,该功能org-agenda-finalize-entries
已在标有;; BEGIN modification
和的部分之间的底部附近进行了修改;; END modification
。
(require 'org-agenda)
(defun org-agenda-finalize-entries (list &optional type)
"Sort, limit and concatenate the LIST of agenda items.
The optional argument TYPE tells the agenda type."
(let ((max-effort (cond ((listp org-agenda-max-effort)
(cdr (assoc type org-agenda-max-effort)))
(t org-agenda-max-effort)))
(max-todo (cond ((listp org-agenda-max-todos)
(cdr (assoc type org-agenda-max-todos)))
(t org-agenda-max-todos)))
(max-tags (cond ((listp org-agenda-max-tags)
(cdr (assoc type org-agenda-max-tags)))
(t org-agenda-max-tags)))
(max-entries (cond ((listp org-agenda-max-entries)
(cdr (assoc type org-agenda-max-entries)))
(t org-agenda-max-entries))) l)
(when org-agenda-before-sorting-filter-function
(setq list
(delq nil
(mapcar
org-agenda-before-sorting-filter-function list))))
(setq list (mapcar 'org-agenda-highlight-todo list)
list (mapcar 'identity (sort list 'org-entries-lessp)))
(when max-effort
(setq list (org-agenda-limit-entries
list 'effort-minutes max-effort 'identity)))
(when max-todo
(setq list (org-agenda-limit-entries list 'todo-state max-todo)))
(when max-tags
(setq list (org-agenda-limit-entries list 'tags max-tags)))
(when max-entries
(setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
;; BEGIN modification
(setq list
(mapcar
(lambda (string)
(let* (
(current-date (time-to-days (current-time)))
(ts-date (get-text-property 0 'ts-date string)) )
(if ts-date
(cond
((< ts-date current-date)
(message "The task dated %s is overdue." ts-date)
;; The new value of `string' is returned/thrown as a result.
(replace-regexp-in-string "^" "OLD: " string))
((= ts-date current-date)
(message "The task dated %s is due today." ts-date)
;; The new value of `string' is returned/thrown as a result.
(replace-regexp-in-string "^" "CURRENT: " string))
((> ts-date current-date)
(message "The task dated %s is not due yet." ts-date)
;; The new value of `string' is returned/thrown as a result.
(replace-regexp-in-string "^" "FUTURE: " string)))
string)))
list))
;; END modification
(mapconcat 'identity list "\n")))
replace-regexp-in-string
添加分隔线和/或换行符为您的愿望);您可以具有string-equals
或匹配某些条件或您要寻找的任何其他条件。检查具有值的现有文本属性,以熟悉开箱即用的内容,然后使用它们。