我们有例子:
(setq org-agenda-custom-commands
'(("c" "Desk Work" tags-todo "computer" ;; (1) (2) (3) (4)
((org-agenda-files '("~/org/widgets.org" "~/org/clients.org")) ;; (5)
(org-agenda-sorting-strategy '(priority-up effort-down))) ;; (5) cont.
("~/computer.html")) ;; (6)
;; ...other commands here
))
如果用户发送 C-a c ,则此示例为
问题: 我需要让这个代码可以使用几个字符。例如,我可以获得 C-a c 或 C-a 3 ,同时执行相同的代码。 C-a c = C-a 3
我需要在议程缓冲区中看到:
"c" or "3" "Desk Work"
答案 0 :(得分:0)
如果我正确理解你,你想用相同的议程命令定义两个键。我会将议程命令的相关部分放在一个变量中,如下所示:
(defvar my/org-agenda-desk-work
'(tags-todo "computer"
((org-agenda-files '("~/org/widgets.org" "~/org/clients.org"))
(org-agenda-sorting-strategy '(priority-up effort-down)))
("~/computer.html"))
"Custom agenda command for desk work.
The value (a list form) is the correct format to be the tail of
an entry in `org-agenda-custom-commands', lacking only the key
used to trigger the agenda and a name.")
如果键之间的命令略有不同,您可以根据需要使用函数进行参数化:
(defun my/org-agenda-desk-work-tagged (tag)
"Return desk work agenda command for TAG.
The return value (a list form) is the correct format to be the
tail of an entry in `org-agenda-custom-commands', lacking only
the key used to trigger the agenda and a name"
`("Desk Work" tags-todo ,tag
((org-agenda-files '("~/org/widgets.org" "~/org/clients.org"))
(org-agenda-sorting-strategy '(priority-up effort-down)))
("~/computer.html")))
要使用这些,你可以这样做:
(setq org-agenda-custom-commands
`(("c" "Desk Work" ,@my/org-agenda-desk-work)
("3" "Desk Work" ,@my/org-agenda-desk-work)
("f" "Desk Work Foo" ,@(my/org-agenda-desk-work-tagged "foo"))
;; ...other commands here
))