alphapapa / org-ql

A searching tool for Org-mode, including custom query languages, commands, saved searches and agenda-like views, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#+FILETAGS are ignored by tags-inherited

mskorzhinskiy opened this issue · comments

I've tried several styles to specify filetags, unfortunately none of them are working. Example file:

#+FILETAGS: :Peter:Boss:Secret:
#+FILETAGS: :Boss:
#+FILETAGS: Secret

* Meeting with the French group      :work:
** Summary by Frank                  :boss:notes:
*** TODO Prepare slides for him      :action:

Inheritance from headline works OK:

(org-ql-search "~/testfile.org"
  '(tags "work")) => 3 items

And none of the filetags are matched:

(org-ql-search "~/testfile.org"
  '(tags "Peter")) => 0 items
(org-ql-search "~/testfile.org"
  '(tags "Boss")) => 0 items
(org-ql-search "~/testfile.org"
  '(tags "Secret")) => 0 items

Thanks for reporting this. When I wrote the new tags code, I neglected to consider file tags (I hardly use them myself). It shouldn't take too much work to support them.

Honestly I am using them very rarely too, I have only one file with only one file tag, so it took some time before I noticed something strange.

I think I just need to find a proper regexp string for filetags and add them to tags-inhereted, and that is all. There is also caching system, I am not sure is there are anything I should about it?

Anyway, if you don't mind, I can prepare a patch for this. It is a nice opportunity for me to learn a bit more about emacs lisp. :-) But I can't promise any ETA.

I would start with this:

org-file-tags is a variable defined in ‘org.el’.
Its value is nil
Local in buffer cpb.org; global value is the same.

Documentation:
List of tags that can be inherited by all entries in the file.
The tags will be inherited if the variable ‘org-use-tag-inheritance’
says they should be.
This variable is populated from #+FILETAGS lines.

@mskorzhinskiy Please test this commit and ensure it fixes the problem for you: 1330fff. The tests seem to indicate that it does, but I'd like confirmation from you to be sure. When you confirm, I'll merge to master.

As you can see, I used a different approach in the code: simply, when at a top-level heading, return org-file-tags as the inherited tags, which then cascade down to child headings.

Most of the changes in the branch are to the test infrastructure to allow testing of file tags without invalidating existing tests or including file tags in their results.

Thanks for your help with this issue.

I've tried to run it on my data set and I didn't see any regressions.
Although, I didn't run these tests as I did have some troubles with running them. Will figure them out next time I'll show up with a patch. Sorry about that.
Thank you for your time and passion working on this package.

Don't worry about running the test suite. I'd just like to confirm that file tags are correctly inherited for you now. Can you test that manually?

Can you test that manually?

Eh, sorry. What I really meant by saying I didn't see any regressions is that I just tried to run it manually on my data set and with your patch everything works as I would expect.
The change was tested and I think ready to be merged.

Great, thank you.