I use org mode's capture functionality to make all my todo's. It is clean and practical and let me add a consistent content to all my todo's, including a prompt for heading, a prompt for tags and an automatic insertion of created date. Here is my code:
(setq org-capture-templates '((
"t" ; key
"Todo" ; description
entry ; type
(file+headline "C:/.../org/notes.org" "tasks") ; target
"* TODO [#B] %^{Todo} :%^{Tags}: \n:PROPERTIES:\n:Created: %U\n:END:\n\n%?" ; template
:prepend t ; properties
:empty-lines 1 ; properties
:created t ; properties
)))
However, my prompt for tags forces me to enter tags from memory. How could I add tags from the tags list set by the following code:
(setq org-tag-alist `(
("OFFICE" . ?o)
("HOME" . ?h)
("ERRAND" . ?e) ))
When my point is in the heading of an already created task, this list pops up when I hit C-c C-c and let me chose the tags by their short cut single letters "o", "h" or "e".
So my question is: is it possible to include this pop-up list of tags inside the code for my capture?
The built in solution is to use %^g
. From the help for org-capture-templates
:
%^g Prompt for tags, with completion on tags in target file.
%^G Prompt for tags, with completion on all tags in all agenda files.
You can also do this "by hand" by calling some function that adds the tags. Adding tags is generally done with org-set-tags
(this is what C-c C-c
is doing). So, all we have to do is call that in our template with the %(func)
syntax:
(setq org-capture-templates '((
"t" ; key
"Todo" ; description
entry ; type
(file+headline "C:/.../org/notes.org" "tasks") ; target
"* TODO [#B] %^{Todo} %(org-set-tags) \n:PROPERTIES:\n:Created: %U\n:END:\n\n%?" ; template
:prepend t ; properties
:empty-lines 1 ; properties
:created t ; properties
)))
If you have a specific list of tags you want to select from (say org-tag-alist
) you can use completing-read
to select from it:
(completing-read "Tag: " (mapcar #'first org-tag-persistent-alist) nil t)