2

I use org-mode to write a huge research diary with thousands of entries. I'm trying to organize them by tags. I make only the relevant entries appear via org-sparse-tree and that works perfectly. Now, I would like to use the Emacs search only among them. Is this possible?

Alternatively, is it possible to export a org-sparse-tree to another buffer and search there?

2

Dunno anything about Org or org-sparse-tree. But if it makes only some text visible by making the rest of the text invisible, then Isearch should automatically do the right thing: search only the visible text.

However, you might need to set (or bind, in, e.g., a command you write), option search-invisible to nil. The default value is open, which means that certain invisible text can be matched (opened) by Isearch. C-h v search-invisible tells you:

search-invisible is a variable defined in isearch.el.

Its value is open

Documentation:

If t incremental search/query-replace can match hidden text.

A nil value means don't match invisible text.

When the value is open, if the text matched is made invisible by an overlay having an invisible property and that overlay has a property isearch-open-invisible, then incremental search will show the contents. (This applies when using outline.el and hideshow.el.)

To temporarily change the value for an active incremental search, use M-s i.

See also the related option isearch-hide-immediately.

See also reveal-mode if you want overlays to automatically be opened whenever point is in one of them.

You can customize this variable.

As that doc also says, you can use M-s i to toggle the value temporarily.

But of course, this variable has an effect only on overlays with property invisible and property isearch-open-invisible.

  • Awesome, I didn't know about that! It works perfectly! – Zuza Nov 11 '17 at 19:04
1

Drew answers the first section.

Alternatively, is it possible to export a org-sparse-tree to another buffer and search there?

It's in the docs. (info "(org) Sparse trees")

Or you can use C-c C-e C-v to export only the visible part of the document and print the resulting file.

You could choose the option O O for exporting into an org mode buffer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.