reddit / emacs

How to search/grep with context based on indentation level?

jMilton13 · 2022-09-30 18:43
I’ve been a Dynalist user for years, as my notes tend to follow a hierarchy, but I’m wanting to transition to org-mode for obvious reasons. When you search a page in Dynalist, you get search results in the context of each parent line ("parent" as determined by indentation level). The same goal is accomplished in [ogrep](https://github.com/kriomant/ogrep). Is this type of search possible in emacs? In org-mode, I know there is `sparse-tree`, but it is not as "sparse" as ogrep or Dynalist, giving much more context than I sometimes need. This feature is so valuable to me that I'll have to craft a solution with your suggestions if one doesn’t yet exist.
rswgnu · 2022-10-06 03:18
The HyRolo subsystem in the Hyperbole package can be pointed at any set of org files and will perform searches that return matches within their existing hierarchies. You can then press {o} to see just the headlines at all levels of the hierarchies for the matches. Press {q} and you are back where you started before the search.
jMilton13 · 2022-10-11 21:58
Thank you so much for this!!!