From: Kevin Foley <firstname.lastname@example.org> To: Org Mode List <email@example.com> Subject: [PATCH] Org Capture Add Tags with org-toggle-tag Date: Wed, 02 Feb 2022 19:57:38 -0500 [thread overview] Message-ID: <firstname.lastname@example.org> (raw) [-- Attachment #1: Type: text/plain, Size: 865 bytes --] I have a capture template which utilizes %^g to prompt me for a tag to add to a headline which already has a tag. An example to demonstrate is: * TODO %? %^g :foo: If I call this template and give it "bar" when prompted for a tag, it results in (where | is the cursor position): * TODO | :bar: :foo: And bar is recognized as a tag. I've been able to resolve this with the attached patch. However, looking at the git history of that code it seems the intent might have been to prevent some recursive resolution so I'm not sure if this breaks that. I've realized I could also attach the %^g to :foo: tag in the template and things work as expected but if that's the expectation then I think it's worth mentioning in the docstring for org-capture-templates. Thanks, Kevin [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: org-capture.el.diff --] [-- Type: text/x-diff, Size: 590 bytes --] diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 5195b785e..b27de40fe 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1753,9 +1753,7 @@ (defun org-capture-fill-template (&optional template initial annotation) 'org-tags-history)) ":"))) (when (org-string-nw-p ins) - (unless (eq (char-before) ?:) (insert ":")) - (insert ins) - (unless (eq (char-after) ?:) (insert ":")) + (org-toggle-tag ins 'on) (when (org-at-heading-p) (org-align-tags))))) ((or "C" "L") (let ((insert-fun (if (equal key "C") #'insert
reply other threads:[~2022-02-03 1:02 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: [PATCH] Org Capture Add Tags with org-toggle-tag' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).