2

I can use (org-entry-get (point) "myproperty") to get the value of the myproperty property for the current org-mode entry.

What about tags? Since a tag is either present or not, I was expecting some org API function such as org-entry-has-tag but there doesn't seem to be such a function. Am I missing something? If not, what's a good way to write such a function?

2
  • Do any of these help? org-get-buffer-tags, org-get-local-tags, org-get-local-tags-at, org-get-tag-face, org-get-tags, org-get-tags-at , org-get-tags-string, org-global-tags-completion-table, org-list-get-tag. If not, try apropos.
    – Drew
    Feb 5, 2021 at 21:19
  • I used apropos and I don't have any of the "get tags" commands. I have a recent version of org, so I'm not sure why those aren't available.
    – Dan Drake
    Feb 5, 2021 at 23:03

2 Answers 2

4

There is a special property called TAGS, so you can look up the tags of any entry the same way that you look up any other property:

(org-entry-get (point) "TAGS")

And of course if there are no tags, that returns nil, so you can check for the existence of tags by using it in a conditional form, e.g. (if (org-entry-get (point) "TAGS") ...).

1

Somehow I didn't find org-get-tags -- I tried apropos, but it only showed me interactive functions, and org-get-tags isn't interactive. Thanks Drew.

For the exact question I have here, you just use member and org-get-tags:

(defun org-has-tag (tag)
  (member tag (org-get-tags)))
2
  • C-h f org-*-tags TAB will give you a completion buffer with all functions (not just interactive one) that match the pattern.
    – NickD
    Feb 6, 2021 at 17:29
  • 1
    From C-h f apropos: "With C-u prefix, or if apropos-do-all is non-nil, consider all symbols (if they match 1PATTERN1)." So try C-u M-x apropos.
    – Drew
    Feb 6, 2021 at 19:04

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.