emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-orgmode@gnu.org
Subject: Re: add additional tag (using %^G) to existing tag in org capture
Date: Fri, 08 Sep 2017 05:11:15 -0500	[thread overview]
Message-ID: <87wp59biv0.fsf@alphapapa.net> (raw)
In-Reply-To: CAOQHXPrDnQ+X4Y8JJ3d70oBPe0KX+ky=R82U+a8m1XMfdPYBdQ@mail.gmail.com

Xebar Saram <zeltakc@gmail.com> writes:

> the issues is that it dosent seem to add an additional tag to the already defined tag list in the capture (:@work: ) but instead add another :TAG: field
> apart from the already existing tag field. so the final result looks like this:
>
> ** TODO TEST :@work: :TAG:
>
> while i expect the %^G capture to add to the existing tag entry so it looks like this
>
> ** TODO TEST :@work:TAG:

Hey Z,

I understand now.  Yes, that happens because org-capture-fill-template
inserts the tag text manually, like this:

#+BEGIN_SRC elisp
(let* ((org-last-tags-completion-table
        (org-global-tags-completion-table
         (cond ((equal key "G") (org-agenda-files))
               (file (list file))
               (t nil))))
       (org-add-colon-after-tag-completion t)
       (ins (mapconcat
             #'identity
             (org-split-string
              (completing-read
               (if prompt (concat prompt ": ") "Tags: ")
               'org-tags-completion-function nil nil nil
               'org-tags-history)
              "[^[:alnum:]_@#%]+")
             ":")))
  (when (org-string-nw-p ins)
    (unless (eq (char-before) ?:) (insert ":"))
    (insert ins)
    (unless (eq (char-after) ?:) (insert ":"))
    (and (org-at-heading-p)
         (let ((org-ignore-region t))
           (org-set-tags nil 'align)))))
#+END_SRC

It would be simple to have it use org-set-tags-to instead of inserting
them manually.  I guess that would be correct in the vast majority of
cases, however IIUC it would be a change in functionality, as the %^G
could be put anywhere in the template and insert tags there (which seems
like a strange thing to do, but you never know).  On the other hand, it
seems like what you're asking for would be the more expected
functionality, in which case this would be a bug fix.  So maybe the
maintainers would accept a patch for that, or maybe not...  :)

  reply	other threads:[~2017-09-08 10:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 17:31 add additional tag (using %^G) to existing tag in org capture Xebar Saram
2017-09-08  5:04 ` Adam Porter
2017-09-08  5:28   ` Xebar Saram
2017-09-08 10:11     ` Adam Porter [this message]
2017-09-10  7:46       ` Nicolas Goaziou

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 \
    --in-reply-to=87wp59biv0.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=emacs-orgmode@gnu.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).