[英]Org mode agenda: Reuse code in block agenda
我有一個像這樣的 org-agenda-custom-commands:
("u" "Unscheduled TODO"
todo ""
((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
我想在其他塊議程視圖中重用此議程視圖的待辦事項部分。 因此,例如定義一個未unscheduled-todo
列表以供重用(偽代碼,不起作用):
(setq unscheduled-todo '((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
(setq org-agenda-custom-commands
'(("u" "Unscheduled TODO"
(todo "" unscheduled-todo))
("c" "Complete View"
((agenda "")
(todo "" unscheduled-todo))))
如何使上述代碼工作? 我認為我對代碼和列表的評估方式和時間存在根本性的誤解。 我在setq
和org-agenda-custom-commands
中嘗試了許多 ' 和 () 配置,以及append
來創建列表,但我也想了解這里發生了什么。
這是我評論中的一個實現(盡管我認為您在這里真的不需要宏: function 也一樣好或更好):
(defun unscheduled-todo ()
'((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
(setq org-agenda-custom-commands
; N.B. the character following this comment is a *backquote*
; (the key to the left of the 1 key on a standard US keyboard);
; it is *NOT* a quote (the key to the left of the ENTER key
; on a standard US keyboard).
`(("u" "Unscheduled TODO"
todo "" ,(unscheduled-todo))
("c" "Complete View"
((agenda "")
(todo "" ,(unscheduled-todo))))))
我希望它現在是正確的(我必須修復幾個錯誤),但它只是經過輕微測試。
請注意,這使用反引號機制來引用org-agenda-custom-commands
的setq
中的大部分值,同時允許使用逗號機制評估對宏的調用。
編輯:正如@Rorschach 在(現已刪除)評論中指出的那樣,我把事情復雜化了。 你仍然需要反引號和逗號,但你可以使用你定義的變量:
(setq unscheduled-todo
'((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
(setq org-agenda-custom-commands
; N.B. the character following this comment is a *backquote*
; (the key to the left of the 1 key on a standard US keyboard);
; it is *NOT* a quote (the key to the left of the ENTER key
; on a standard US keyboard).
`(("u" "Unscheduled TODO"
todo "" ,unscheduled-todo)
("c" "Complete View"
((agenda "")
(todo "" ,unscheduled-todo)))))
反引號/逗號機制允許評估拼接變量,就像它允許評估拼接 function 調用一樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.