6

I would like to quickly use one of the already used tags when taking notes quickly using org-capture.

There is one inbuilt way of using M-TAB after : but there are 2 issues with that:

  • It does not work in the narrowed down Capture buffer.. I need to widen it first.
  • I would like to have a "list" completion interface so that I can pick one of the existing tags from the minibuffer.. think of imenu/ido/ivy.

Here is a typical use case (using my bindings for the example workflow):

  1. C-c c j to make a quick org-capture entry in my journal.org
  2. Type heading
  3. Hit C-c C-q to enter a tag
  4. Start typing the tag (and at this point I would like the minibuffer to show a list of tags that match with what I already typed in the minibuffer).
    • Pick one from the list by hitting RET if I want to reuse a tag, OR
    • If that exact tag doesn't already exist, create it when I hit RET

Currently, in step 4, if I want to use one of the already used tags, there is no way for me to ensure if I am doing so or creating a new tag with slight variation of that old tag.

For example: I might already have had a heading with a tag PRJ_v1 in the past and I intend to make a new heading with the same tag. But by mistake I end up creating a new tag called PRJ_r1 (because I did not remember if the original tag was PRJ_v1 or PRJ_r1). I would like to prevent such tag duplication.

2 Answers 2

2

Would it work to use the %^g element in your template to prompt for a tag at a specific position within the template? In one of mine, I use:

(add-to-list 'org-capture-templates
         `("j" "Journal" entry
           (file+datetree "journal.org" "Journal")
           "* %^{Plan} %^g\n%?\n"
           :kill-buffer t))

which prompts for a tag after prompting for a headline, then lets me type in the rest of the entry in the capture buffer. As far as I can tell, it picks up the tags from the journal.org file appropriately for completion.

The doc in http://orgmode.org/manual/Template-expansion.html describes %^g as "Prompt for tags, with completion on tags in target file." There is also %^G to prompt for tags from all agenda files.

1
  • Thanks for sharing that. I was not aware of the %^g and %^G fields earlier. Commented Nov 3, 2015 at 19:16
2

Since I posted that question, I have switched to using the ivy/counsel family of packages for this purpose (instead of ido).

After installing the counsel package from Melpa, and below piece of code in my emacs init, auto-completing org tags has become a breeze all-over org: In the Capture buffer, in regular org buffers and even in org-agenda.

(require 'counsel)
(with-eval-after-load 'org
  (define-key org-mode-map (kbd "C-c C-q") #'counsel-org-tag))
(with-eval-after-load 'org-agenda
  (define-key org-agenda-mode-map (kbd "C-c C-q") #'counsel-org-tag-agenda))

Here is what I get in my tag completion after hitting C-c C-q in the Capture buffer and then searching for tags beginning with the letter b (^b):

enter image description here


counsel basically uses the ivy package for backend (which is like ido-vertical-mode broadly speaking). You can learn more about Counsel completion from the package author's blog post.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.