如题

先上效果图

Figure 1: 开启 emacs 时的提示

Figure 1: 开启 emacs 时的提示

Figure 2: 开启 terminal 时的提示

Figure 2: 开启 terminal 时的提示

下面是代码:

(with-eval-after-load 'org
  ;; Task reminding
  (defun colawithsauce/org-agenda-get-todos ()
    "Get todo and scheduled items until today."
    (let ((matched-items '())
          (print-result ""))
      (dolist (match
               (org-map-entries 'org-heading-components "SCHEDULED<=\"<today>\"" 'agenda))
        (when (member (nth 2 match) '("[!]" "TODO" "[?]" "HACKING"))
          (push (concat "■ " (nth 4 match)) matched-items)))
      (while matched-items
        (setq print-result (concat (car matched-items) "\n" print-result))
        (setq matched-items (cdr matched-items)))
      (message print-result)))
  (defun colawithsauce/org-agenda-write-file ()
    "Write todo and scheduled items list to FILENAME."
    (with-temp-buffer
      (insert (colawithsauce/org-agenda-get-todos))
      (write-file "~/.task_today")))
  (defun colawithsauce/org-agenda-write-scratch-buffer ()
    "Write todo and scheduled item list to scratch buffer after-init."
    (with-current-buffer "*scratch*"
      (let* ((todo-list (butlast (split-string (colawithsauce/org-agenda-get-todos) "\n")))
             (todo-count (length todo-list)))
        (insert
         (format "%s\n" (make-string 70 ?\;))
         (format ";; Hey! ♥%s♥ !\n;; There are %d tasks to do today !!!\n" (user-login-name) todo-count))
        (while todo-list
          (insert (format ";;   %s\n" (car todo-list)))
          (setq todo-list (cdr todo-list)))
        (insert (format "%s\n" (make-string 70 ?\;)))
        (end-of-buffer))))

  (add-hook 'org-after-todo-state-change-hook 'colawithsauce/org-agenda-write-file)
  (add-hook 'after-init-hook 'colawithsauce/org-agenda-write-file)
  (add-hook 'after-init-hook 'colawithsauce/org-agenda-write-scratch-buffer)
)

上面的配置直接粘贴到配置文件里面就可以用,但是要注意一点:我的定义 todo 状态标签是: ("[!]" "TODO" "[?]" "HACKING") ,可能与你不一样,因此需要将这里换成你定义的 todo 状态标签。