org - 议程前缀格式%?不行 [英] org--agenda-prefix-format %? does not work

查看:210
本文介绍了org - 议程前缀格式%?不行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,由于



组织布局:





但是,您可以对于任务A,即使项目中没有任何内容,它仍然显示在列表中。



描述变量 for org-agenda-prefix-format 说:

 如果'%'后面的第一个字符是一个问号,整个字段
只会如果相应的值适用于当前的
条目,则将被包括在内。这对于当
存在时应该具有固定宽度的字段是有用的,但不存在时为零。

所以我觉得通过使用%? [] 不应该在任务A,但它仍然显示。

解决方案

问题是字段永远不会为空:它至少包含左和右方括号加上白色空格将其带到12的宽度。



解决方案是编写一个函数,返回一个空字符串或括号中的项目,并使用以下格式: / p>

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

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


Currently, I have my global TODO list shown as follows thanks to erikstokes:

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

which outputs:

for org layout:

However, as you can see, for Task A, even though there is nothing in the project, it still shows up on the list.

describe-variable for org-agenda-prefix-format says :

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. 

So I feel like by using %?, [ ] shouldn't be there for Task A, yet it still shows up.

解决方案

The problem is that the field is never empty: it will always contain at least the left and right square brackets plus the white space to bring it to a width of 12.

The solution is to write a function that returns either an empty string or the bracketed project and use that in the format:

  (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) "

这篇关于org - 议程前缀格式%?不行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆