I would like to have different fast tag selections depending on the capture template used.

  • Personal template - org-tag-alist = gym, family, friends, chores
  • Work template - org-tag-alist = mettings, docs, seminar

I run the org-set-tags-command at the end but the selection doesn't show up. The functions are being called cause I can see the org-tag-alist changed in describe-variable.

It's prompting me for tags 0 Tags [add more using TAB] instead of the quick entry when I run org-set-tags-command. If I set org-tag-alist outside of the function it works but then I don't have different tags on a per template.

(defvar org-capture-templates nil)

(defun my/work-tags ()
  "Set work tags."
  (setq org-tag-alist '(("meetings" . ?m) ("docs" . ?d) ("seminar" . ?s)))
 (= 1 2) ; Need to return string or nil.

(defun my/personal-tags ()
  "Set personal tags."
  (setq org-tag-alist '(("gym" . ?g) ("family" . ?f) ("friends" . ?F)("chores" . ?c)))
 (= 1 2) ; Need to return string or nil.

(add-to-list 'org-capture-templates
                 '("W"          ; key
                   "Work"    ; name
                   entry        ; type
                   (file (lambda () (concat user-emacs-directory "todos.org" ))) ; target
                   "* %(my/work-tags) %^{Task}%^{DESCRIPTION}p" :prepend t))

(add-to-list 'org-capture-templates
                 '("P"          ; key
                   "Personal"    ; name
                   entry        ; type
                   (file (lambda () (concat user-emacs-directory "todos.org" ))) ; target
                   "* %(my/personal-tags) %^{Task}%^{DESCRIPTION}p" :prepend t))

I use vanilla emacs, but tried it on doom to make sure it wasn't my configuration.

  • First thing: you have the same accelerator key, "f", assigned to two tags, "fmaily" and "friends", within your personal set. Aug 18, 2022 at 15:03
  • Next thing: why do you want to go to the trouble of doing this? The built-in facilities already provide what you are looking for, I think. You will need to read the manual starting at the section on "Setting Tags" and its following section on tag hierarchies. (info "(org) Setting Tags"). Aug 18, 2022 at 15:08
  • @PhilHudson Thanks for pointing that out. I still get the same outcome when I change it to an "F". Without different org-tag-alist how would I use the same keys ? "c" for "config" in Emacs category would conflict with "c" for "chores" in Personal. I would have to use different names or capital letters.
    – ritchie
    Aug 18, 2022 at 15:22


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.