簡體   English   中英

org--agenda-prefix-format %? 不起作用

[英]org--agenda-prefix-format %? does not work

目前,由於erikstokes ,我的全局 TODO 列表如下所示:

(org-agenda-prefix-format " %i %?-12(concat \\"[ \\"(org-format-outline-path (list (nth 1 (org-get-outline-path)))) \\" ]\\") ")))

輸出:

在此處輸入圖片說明

對於組織布局:

在此處輸入圖片說明

但是,如您所見,對於任務 A,即使項目中沒有任何內容,它仍然顯示在列表中。

org-agenda-prefix-format describe-variable說:

If the first character after `%' is a question mark, the entire field
will only be included if the corresponding value applies to the current
entry.  This is useful for fields which should have fixed width when
present, but zero width when absent. 

所以我覺得通過使用%? , [ ]不應該出現在任務 A 中,但它仍然出現。

問題是該字段永遠不會為空:它總是至少包含左右方括號加上空格,使其寬度為 12。

解決方案是編寫一個函數,該函數返回一個空字符串或括號內的項目,並以以下格式使用它:

  (defun foo ()
     (let ((x (nth 1 (org-get-outline-path))))
       (if x
           (concat "[ " (org-format-outline-path (list x)) " ]")
         "")))

  (setq org-agenda-prefix-format " %i %?-12(foo) "

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM