1

All information over the internet about searching tags in the org-mode says about C-c a m Match a TAGS/PROP/TODO query in org-agenda

I have many org files which are not in the agenda file (not in org-agenda-files).

I just wonder (at least) if it shows only headlines having a specific tag in a buffer or files without the help of agenda.

1
  • How is the search supposed to figure out what files you want to include in the search? The standard easy choices are the current file and the (current) set of agenda files. Do you really want to search for .org files throughout all your file systems? If not, how do you want to limit the set?
    – NickD
    Commented Sep 13, 2022 at 18:01

1 Answer 1

0

Assuming that you want to search for tags in the current buffer only, you can do C-c \ (bound to org-match-sparse-tree) with a match expression as argument, as defined in Matching tags and properties in the manual. For example, to search for items with tag foo, you say: C-c \ +foo; if you want to find items with tags foo and bar, you say: C-c \ +foo+bar; if you want to find items with tag foo but not with tag bar, you say C-c \ +foo-bar - and so on... All of these will give you a sparse-tree view of the hits.

You can also, of course, just use standard emacs text searches, e.g. C-s :foo: (assuming that there is no text :foo: in your Org mode file that is not a tag - otherwise, you'll get a false positive). After all, Org mode files are just text files.

If you want to search through multiple files, there are many ways (e.g. multi-occur or multi-occur-matching-buffers, dired and relatives, etc), all of which involve some way of selecting the files/buffers of interest and then applying a (fixed or user-provided) function to each one. It's impossible to suggest a "solution" without specifying the problem much more precisely than you have.

1
  • Thank you! That works for me. Commented Sep 13, 2022 at 23:11

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.