Re: Have all the tags of a heading, with a tag hierarchy
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 a écrit : > Cletip Cletip 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 >
Re: Have all the tags of a heading, with a tag hierarchy
Cletip Cletip 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
Re: Have all the tags of a heading, with a tag hierarchy
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 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 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 a >> écrit : >> >>> Cletip Cletip 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 >>> >>
Re: Have all the tags of a heading, with a tag hierarchy
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 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 a > écrit : > >> Cletip Cletip 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 >> >
Re: Have all the tags of a heading, with a tag hierarchy
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 a écrit : > Cletip Cletip 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 >
Re: Have all the tags of a heading, with a tag hierarchy
Cletip Cletip 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
Re: Have all the tags of a heading, with a tag hierarchy
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 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 >
Re: Have all the tags of a heading, with a tag hierarchy
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
Re: Have all the tags of a heading, with a tag hierarchy
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 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 > >
Re: Have all the tags of a heading, with a tag hierarchy
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
Have all the tags of a heading, with a tag hierarchy
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.