如何获得 TODO property 比如 :STYLE: habit ?

如题,想要修改一个方法,把 TODO 当中是 habit track 的过滤掉,如何辨别它是 habit track?

就是下面的方法,想把 habit track 过滤掉。

(defun my/org-roam-copy-todo-to-today ()
  (interactive)
  (let ((org-refile-keep t) ;; Set this to nil to delete the original!
        (org-roam-dailies-capture-templates
          '(("t" "tasks" entry "%?"
             :if-new (file+head+olp "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n#+ARCHIVE: journal.org::\n" ("%<%Y-%m-%d>" "Tasks")))))
        (org-after-refile-insert-hook #'save-buffer)
        today-file
        pos)
    (save-window-excursion
      (org-roam-dailies--capture (current-time) t)
      (setq today-file (buffer-file-name))
      (setq pos (point)))

    ;; Only refile if the target file is different than the current file
    (unless (equal (file-truename today-file)
                   (file-truename (buffer-file-name)))
      (org-refile nil nil (list "Tasks" today-file nil pos)))))

(add-to-list 'org-after-todo-state-change-hook
             (lambda ()
               ;; DONE 和 CANCELLED 的 To-Dos 自动复制到今日
               (when (or (equal org-state "DONE") (equal org-state "CANCELLED"))
                 (my/org-roam-copy-todo-to-today))))

一个思路:

看到: (org-refile nil nil (list "Tasks" today-file nil pos))

这个地方是把整个 “Tasks” 下的所有子标题及内容转移。一个办法是遍历“Tasks” 下的子标题,当下面两个条件都满足的时候,进行 refile 。

  1. (org-find-property "STYLE") 的返回值真假
  2. (or (equal org-state “DONE”) (equal org-state “CANCELLED”)
1 个赞
;; Copy Done To-Dos to Today
(defun my/org-roam-copy-todo-to-today ()
  (interactive)
  (let ((org-refile-keep t) ;; Set this to nil to delete the original!
        (org-roam-dailies-capture-templates
          '(("t" "tasks" entry "%?"
             :if-new (file+head+olp "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n#+ARCHIVE: journal.org::\n" ("%<%Y-%m-%d>" "Tasks")))))
        (org-after-refile-insert-hook #'save-buffer)
        today-file
        pos)
    (save-window-excursion
      (org-roam-dailies--capture (current-time) t)
      (setq today-file (buffer-file-name))
      (setq pos (point)))

    ;; Only refile if the target file is different than the current file
    (unless (equal (file-truename today-file)
                   (file-truename (buffer-file-name)))
      (org-refile nil nil (list "Tasks" today-file nil pos)))))

(add-to-list 'org-after-todo-state-change-hook
             (lambda ()
               ;; DONE 和 CANCELLED 的 To-Dos 自动复制到今日
               ;; 同时过滤掉 habit 的 To-Dos
               (when (and (or (equal org-state "DONE") (equal org-state "CANCELLED")) (not (org-find-property "STYLE")))
                 (my/org-roam-copy-todo-to-today))))