emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Have all the tags of a heading, with a tag hierarchy
@ 2022-08-28 15:37 Cletip Cletip
  2022-08-28 16:21 ` Juan Manuel Macías
  0 siblings, 1 reply; 11+ messages in thread
From: Cletip Cletip @ 2022-08-28 15:37 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Hello everyone !

After multiple searches on the internet, I did not find the answer to my
question (which is the subject of this mail): when calling the
"org-get-tags" function, only the tags put on the heading, and not the
inherited tags, are retrieved. How can I get the inherited tags as well?
Does such a function already exist? Did I miss an essential variable?


Thanks in advance for your future answer.

[-- Attachment #2: Type: text/html, Size: 481 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-28 15:37 Have all the tags of a heading, with a tag hierarchy Cletip Cletip
@ 2022-08-28 16:21 ` Juan Manuel Macías
  2022-08-28 16:34   ` Cletip Cletip
  0 siblings, 1 reply; 11+ messages in thread
From: Juan Manuel Macías @ 2022-08-28 16:21 UTC (permalink / raw)
  To: Cletip Cletip; +Cc: orgmode

Cletip Cletip writes:

> After multiple searches on the internet, I did not find the answer to
> my question (which is the subject of this mail): when calling the
> "org-get-tags" function, only the tags put on the heading, and not the
> inherited tags, are retrieved. How can I get the inherited tags as
> well? Does such a function already exist? Did I miss an essential
> variable?

In my case, I do manage to get the iherited tags. Do you have
`org-use-tag-inheritance' set to non-nil?

According to the `org-get-tags' docstring:

> According to ‘org-use-tag-inheritance’, tags may be inherited from
> parent headlines, and from the whole document, through
> ‘org-file-tags’. In this case, the returned list of tags contains tags
> in this order: file tags, tags inherited from parent headlines, local
> tags. If a tag appears multiple times, only the most local tag is
> returned.

and

> However, when optional argument LOCAL is non-nil, only return tags
> specified at the headline.

Best regards,

Juan Manuel 

-- 
--
------------------------------------------------------
Juan Manuel Macías 

https://juanmanuelmacias.com

https://lunotipia.juanmanuelmacias.com

https://gnutas.juanmanuelmacias.com



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-28 16:21 ` Juan Manuel Macías
@ 2022-08-28 16:34   ` Cletip Cletip
  2022-08-28 19:15     ` Daniel Fleischer
  0 siblings, 1 reply; 11+ messages in thread
From: Cletip Cletip @ 2022-08-28 16:34 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

[-- Attachment #1: Type: text/plain, Size: 2264 bytes --]

Thank you for your answer!

I may not have been specific enough:
I want the tags also inherited with this "method"
https://orgmode.org/manual/Tag-Hierarchy.html.


So imagine this in your configuration file

(setq org-tag-alist '((:startgrouptag)
                      ("GTD")
                      (:grouptags)
                      ("Control")
                      (:Persp)
                      (:endgrouptag)
                      (:startgrouptag)
                      ( Control)
                      (:grouptags)
                      ("Context")
                      (:Task")
                      (:endgrouptag))


So, if I put the "Control" tag, I am also supposed to have the "GTD" tag,
because "Control" is a child of "GTD".

But, with the "org-get-tags" function, I don't have this famous "GTD" tag

Le dim. 28 août 2022 à 18:22, Juan Manuel Macías <maciaschain@posteo.net> a
écrit :

> Cletip Cletip writes:
>
> > After multiple searches on the internet, I did not find the answer to
> > my question (which is the subject of this mail): when calling the
> > "org-get-tags" function, only the tags put on the heading, and not the
> > inherited tags, are retrieved. How can I get the inherited tags as
> > well? Does such a function already exist? Did I miss an essential
> > variable?
>
> In my case, I do manage to get the iherited tags. Do you have
> `org-use-tag-inheritance' set to non-nil?
>
> According to the `org-get-tags' docstring:
>
> > According to ‘org-use-tag-inheritance’, tags may be inherited from
> > parent headlines, and from the whole document, through
> > ‘org-file-tags’. In this case, the returned list of tags contains tags
> > in this order: file tags, tags inherited from parent headlines, local
> > tags. If a tag appears multiple times, only the most local tag is
> > returned.
>
> and
>
> > However, when optional argument LOCAL is non-nil, only return tags
> > specified at the headline.
>
> Best regards,
>
> Juan Manuel
>
> --
> --
> ------------------------------------------------------
> Juan Manuel Macías
>
> https://juanmanuelmacias.com
>
> https://lunotipia.juanmanuelmacias.com
>
> https://gnutas.juanmanuelmacias.com
>
>

[-- Attachment #2: Type: text/html, Size: 3290 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-28 16:34   ` Cletip Cletip
@ 2022-08-28 19:15     ` Daniel Fleischer
  2022-08-29 11:41       ` Cletip Cletip
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Fleischer @ 2022-08-28 19:15 UTC (permalink / raw)
  To: Cletip Cletip; +Cc: Juan Manuel Macías, orgmode

Cletip Cletip [2022-08-28 Sun 18:34] wrote:

> I may not have been specific enough: 
> I want the tags also inherited with this "method" https://orgmode.org/manual/Tag-Hierarchy.html.

I think these are 2 mechanisms that only share the name "hierarchy". One
is headline hierarchy: a headline shares the tags of its ancestors. It's
local information, it's about the categories this headline are part of
because of its location in the document.

The other mechanism is for grouping tags into families and is used in
the agenda; each family has a representative and you can search for it
instead of searching all the individual members.

I think it makes sense, but you might want these to be related.

-- 

Daniel Fleischer


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-28 19:15     ` Daniel Fleischer
@ 2022-08-29 11:41       ` Cletip Cletip
  2022-08-29 11:58         ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Cletip Cletip @ 2022-08-29 11:41 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: Juan Manuel Macías, orgmode

[-- Attachment #1: Type: text/plain, Size: 1304 bytes --]

Thanks you for your answer,

Yes I understand both perfectly. I think some people (like me) would like
to connect them, others would not want to bring them together.
But how to get the hierarchy (or the families) used by org agenda with a
function like "org-get-tags" ?

PS: sorry for the bad vocabulary, I followed the same name as the wiki, I
should have been more careful and given more details. Is my question clear
enough?


Le dim. 28 août 2022 à 21:15, Daniel Fleischer <danflscr@gmail.com> a
écrit :

> Cletip Cletip [2022-08-28 Sun 18:34] wrote:
>
> > I may not have been specific enough:
> > I want the tags also inherited with this "method"
> https://orgmode.org/manual/Tag-Hierarchy.html.
>
> I think these are 2 mechanisms that only share the name "hierarchy". One
> is headline hierarchy: a headline shares the tags of its ancestors. It's
> local information, it's about the categories this headline are part of
> because of its location in the document.
>
> The other mechanism is for grouping tags into families and is used in
> the agenda; each family has a representative and you can search for it
> instead of searching all the individual members.
>
> I think it makes sense, but you might want these to be related.
>
> --
>
> Daniel Fleischer
>

[-- Attachment #2: Type: text/html, Size: 1807 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-29 11:41       ` Cletip Cletip
@ 2022-08-29 11:58         ` Ihor Radchenko
  2022-08-31  9:01           ` Cletip Cletip
  0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-08-29 11:58 UTC (permalink / raw)
  To: Cletip Cletip; +Cc: Daniel Fleischer, Juan Manuel Macías, orgmode

Cletip Cletip <clement020302@gmail.com> writes:

> Yes I understand both perfectly. I think some people (like me) would like
> to connect them, others would not want to bring them together.
> But how to get the hierarchy (or the families) used by org agenda with a
> function like "org-get-tags" ?

You will probably need to combine org-get-tags output with regexp
generated by org-tags-expand. Tag hierarchy in Org is a just a search
wrapper - no real tags are changed in the file; only the matching.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-29 11:58         ` Ihor Radchenko
@ 2022-08-31  9:01           ` Cletip Cletip
  2022-08-31 11:25             ` Cletip Cletip
  0 siblings, 1 reply; 11+ messages in thread
From: Cletip Cletip @ 2022-08-31  9:01 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Daniel Fleischer, Juan Manuel Macías, orgmode

[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]

Thank you for your answer, and sorry for the late reply

Ok I think I understood the mechanism, but I don't understand how to use
this regular expression (the one given by, for example,
(org-tags-expand "GTD")
which gives me the regular expression "with the other tags"
)

I see perfectly the idea : a search is done with org-agenda with this
regular expression. But I can't use it.

The problem is that I don't know how to use this regular expression with a
function that returns the tags. Do you have any clue (piece of code where
it is already used ? A function allowing me to translate this regular
expression into a simple tag? Do I just have to convert this regular
expression into a list of tags? Is it possible? I'm asking myself all these
questions because I just don't know where to go ^^)

Thanks in advance for your future answer.


Le lun. 29 août 2022 à 13:57, Ihor Radchenko <yantar92@gmail.com> a écrit :

> Cletip Cletip <clement020302@gmail.com> writes:
>
> > Yes I understand both perfectly. I think some people (like me) would like
> > to connect them, others would not want to bring them together.
> > But how to get the hierarchy (or the families) used by org agenda with a
> > function like "org-get-tags" ?
>
> You will probably need to combine org-get-tags output with regexp
> generated by org-tags-expand. Tag hierarchy in Org is a just a search
> wrapper - no real tags are changed in the file; only the matching.
>
> --
> Ihor Radchenko,
> Org mode contributor,
> Learn more about Org mode at https://orgmode.org/.
> Support Org development at https://liberapay.com/org-mode,
> or support my work at https://liberapay.com/yantar92
>

[-- Attachment #2: Type: text/html, Size: 2392 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-31  9:01           ` Cletip Cletip
@ 2022-08-31 11:25             ` Cletip Cletip
  2022-08-31 11:31               ` Cletip Cletip
  0 siblings, 1 reply; 11+ messages in thread
From: Cletip Cletip @ 2022-08-31 11:25 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Daniel Fleischer, Juan Manuel Macías, orgmode

[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]

Sorry, I found the solution : i must just give one argument non-nil to the
function "org-tags-expand".
Like this :
(org-tags-expand "GTD" t)

It's perfect, thanks a lot for your help !

Le mer. 31 août 2022 à 11:01, Cletip Cletip <clement020302@gmail.com> a
écrit :

> Thank you for your answer, and sorry for the late reply
>
> Ok I think I understood the mechanism, but I don't understand how to use
> this regular expression (the one given by, for example,
> (org-tags-expand "GTD")
> which gives me the regular expression "with the other tags"
> )
>
> I see perfectly the idea : a search is done with org-agenda with this
> regular expression. But I can't use it.
>
> The problem is that I don't know how to use this regular expression with a
> function that returns the tags. Do you have any clue (piece of code where
> it is already used ? A function allowing me to translate this regular
> expression into a simple tag? Do I just have to convert this regular
> expression into a list of tags? Is it possible? I'm asking myself all these
> questions because I just don't know where to go ^^)
>
> Thanks in advance for your future answer.
>
>
> Le lun. 29 août 2022 à 13:57, Ihor Radchenko <yantar92@gmail.com> a
> écrit :
>
>> Cletip Cletip <clement020302@gmail.com> writes:
>>
>> > Yes I understand both perfectly. I think some people (like me) would
>> like
>> > to connect them, others would not want to bring them together.
>> > But how to get the hierarchy (or the families) used by org agenda with a
>> > function like "org-get-tags" ?
>>
>> You will probably need to combine org-get-tags output with regexp
>> generated by org-tags-expand. Tag hierarchy in Org is a just a search
>> wrapper - no real tags are changed in the file; only the matching.
>>
>> --
>> Ihor Radchenko,
>> Org mode contributor,
>> Learn more about Org mode at https://orgmode.org/.
>> Support Org development at https://liberapay.com/org-mode,
>> or support my work at https://liberapay.com/yantar92
>>
>

[-- Attachment #2: Type: text/html, Size: 3037 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-31 11:25             ` Cletip Cletip
@ 2022-08-31 11:31               ` Cletip Cletip
  2022-09-01  7:04                 ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Cletip Cletip @ 2022-08-31 11:31 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Daniel Fleischer, Juan Manuel Macías, orgmode

[-- Attachment #1: Type: text/plain, Size: 2541 bytes --]

Just one last clarification to be sure: there is no native function in
org-mode to have the list of tags with a hierarchy? I have to write my
function with the two functions
org-get-tags and org-tags-expand
to get the result I want : a list of tags that takes into account the
hierarchy defined by the "org-tag-alist" variable

Le mer. 31 août 2022 à 13:25, Cletip Cletip <clement020302@gmail.com> a
écrit :

> Sorry, I found the solution : i must just give one argument non-nil to the
> function "org-tags-expand".
> Like this :
> (org-tags-expand "GTD" t)
>
> It's perfect, thanks a lot for your help !
>
> Le mer. 31 août 2022 à 11:01, Cletip Cletip <clement020302@gmail.com> a
> écrit :
>
>> Thank you for your answer, and sorry for the late reply
>>
>> Ok I think I understood the mechanism, but I don't understand how to use
>> this regular expression (the one given by, for example,
>> (org-tags-expand "GTD")
>> which gives me the regular expression "with the other tags"
>> )
>>
>> I see perfectly the idea : a search is done with org-agenda with this
>> regular expression. But I can't use it.
>>
>> The problem is that I don't know how to use this regular expression with
>> a function that returns the tags. Do you have any clue (piece of code where
>> it is already used ? A function allowing me to translate this regular
>> expression into a simple tag? Do I just have to convert this regular
>> expression into a list of tags? Is it possible? I'm asking myself all these
>> questions because I just don't know where to go ^^)
>>
>> Thanks in advance for your future answer.
>>
>>
>> Le lun. 29 août 2022 à 13:57, Ihor Radchenko <yantar92@gmail.com> a
>> écrit :
>>
>>> Cletip Cletip <clement020302@gmail.com> writes:
>>>
>>> > Yes I understand both perfectly. I think some people (like me) would
>>> like
>>> > to connect them, others would not want to bring them together.
>>> > But how to get the hierarchy (or the families) used by org agenda with
>>> a
>>> > function like "org-get-tags" ?
>>>
>>> You will probably need to combine org-get-tags output with regexp
>>> generated by org-tags-expand. Tag hierarchy in Org is a just a search
>>> wrapper - no real tags are changed in the file; only the matching.
>>>
>>> --
>>> Ihor Radchenko,
>>> Org mode contributor,
>>> Learn more about Org mode at https://orgmode.org/.
>>> Support Org development at https://liberapay.com/org-mode,
>>> or support my work at https://liberapay.com/yantar92
>>>
>>

[-- Attachment #2: Type: text/html, Size: 3772 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-08-31 11:31               ` Cletip Cletip
@ 2022-09-01  7:04                 ` Ihor Radchenko
  2022-09-02 12:47                   ` Cletip Cletip
  0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-09-01  7:04 UTC (permalink / raw)
  To: Cletip Cletip; +Cc: Daniel Fleischer, Juan Manuel Macías, orgmode

Cletip Cletip <clement020302@gmail.com> writes:

> Just one last clarification to be sure: there is no native function in
> org-mode to have the list of tags with a hierarchy? I have to write my
> function with the two functions
> org-get-tags and org-tags-expand
> to get the result I want : a list of tags that takes into account the
> hierarchy defined by the "org-tag-alist" variable

AFAIK, we have no such function.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Have all the tags of a heading, with a tag hierarchy
  2022-09-01  7:04                 ` Ihor Radchenko
@ 2022-09-02 12:47                   ` Cletip Cletip
  0 siblings, 0 replies; 11+ messages in thread
From: Cletip Cletip @ 2022-09-02 12:47 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Daniel Fleischer, Juan Manuel Macías, orgmode

[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]

Ok thanks a lot for your answers, I made the function, if ever it can
interest someone one day


(defun org-get-tags-with-hierarchy-at-point()
      "Return the list of tag WITH the sub-tags if they exist at point"
      (interactive)
      (let ((tags-heading (org-get-tags))
            (tags-result '()))
        (dolist (tag tags-heading)
          (dolist (tag-to-add (org-tags-expand tag t))
            (push tag-to-add tags-result)
            )
          )
        (delete-dups tags-result)
        )
      )

Do not hesitate to change the "tags-heading" variable to select a different
heading

Thanks again for your answers !

Le jeu. 1 sept. 2022 à 09:03, Ihor Radchenko <yantar92@gmail.com> a écrit :

> Cletip Cletip <clement020302@gmail.com> writes:
>
> > Just one last clarification to be sure: there is no native function in
> > org-mode to have the list of tags with a hierarchy? I have to write my
> > function with the two functions
> > org-get-tags and org-tags-expand
> > to get the result I want : a list of tags that takes into account the
> > hierarchy defined by the "org-tag-alist" variable
>
> AFAIK, we have no such function.
>
> --
> Ihor Radchenko,
> Org mode contributor,
> Learn more about Org mode at https://orgmode.org/.
> Support Org development at https://liberapay.com/org-mode,
> or support my work at https://liberapay.com/yantar92
>

[-- Attachment #2: Type: text/html, Size: 2162 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-02 12:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-28 15:37 Have all the tags of a heading, with a tag hierarchy Cletip Cletip
2022-08-28 16:21 ` Juan Manuel Macías
2022-08-28 16:34   ` Cletip Cletip
2022-08-28 19:15     ` Daniel Fleischer
2022-08-29 11:41       ` Cletip Cletip
2022-08-29 11:58         ` Ihor Radchenko
2022-08-31  9:01           ` Cletip Cletip
2022-08-31 11:25             ` Cletip Cletip
2022-08-31 11:31               ` Cletip Cletip
2022-09-01  7:04                 ` Ihor Radchenko
2022-09-02 12:47                   ` Cletip Cletip

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).