0

Problem: lets say I want to search for all meetings I attended last March.

I can search for date ranges in my archive file using a sparse-tree search (M-x org-sparse-tree D) but I can't figure out how to refine this search to add the word "meeting". Nothing in the advanced searching section of manual looked relevant.

I'm guessing this is done using a regex search but I can't figure it out.

edit: In the example I gave meeting would be a string. I probably used a poor example, as tagging all meetings would certainly work. I'd might be looking to search the content of the headline (for example for the name of the individual I met with, or the activity engaged in).

5
  • Within Agenda View you can use regex with org-agenda-filter, associated with / key.
    – crocefisso
    Commented Sep 19 at 17:06
  • Is meeting a tag or just a string? If it's a string, does it occur in the title of the headline or in the body of the headline?
    – NickD
    Commented Sep 19 at 17:46
  • It could also be a state (I use the MEETING state for meetings).
    – crocefisso
    Commented Sep 19 at 17:53
  • 1
    Yes, each of those possibilities would require slightly different syntax, so it is important to specify it precisely.
    – NickD
    Commented Sep 19 at 18:08
  • The above was unclear as both crocefisso and NickD accurately pointed out. Edited for clarity.
    – cochrane12
    Commented Sep 20 at 12:09

1 Answer 1

3

You can probably use an m search. See Matching Tags and Properties in the manual. It's available in the Org agenda dispatcher as well as in the sparse-tree dispatcher (C-c /).

For example, you can use

TIMESTAMP>="<2024-03-01>"&TIMESTAMP<="<2024-03-31>"+meeting

if meeting is a tag.

Or you can use

TIMESTAMP>="<2024-03-01>"&TIMESTAMP<="<2024-03-31>"+TODO="MEETING"

if MEETING is a TODO state.

Or you can use

TIMESTAMP>="<2024-03-01>"&TIMESTAMP<="<2024-03-31>"+ITEM={meeting}

if the headline title is to match the regexp "meeting".

The doc page I linked above has lots of examples, but the best thing to do is experiment: the syntax is a bit finicky, so reading the page closely will pay dividends (I have to reread it every time I want to use it...).

Two pieces of advice:

  • don't give in to the temptation to introduce blanks (e.g. around the relational or logical operators) to make the expression more readable: if you type the expression in and you type a space where it is not expected, you get some notification (perhaps Not a match), but if you paste in a string with spaces, you might get an error or, worse, you might get spurious matches.

  • watch the quotes.

1
  • 1
    I'd completely missed that I could use the same syntax in the org-sparse-tree match query as I do for the agenda. Thanks!
    – cochrane12
    Commented Sep 23 at 11:53

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.