← Back to context

Comment by eviks

3 years ago

I wonder why a huge disadvantage of all these markup-in-plaintext formats if almost never mentioned: it breaks (the easiness of) search. So you can't simply type `simply type` in your search box to find your phrase because the markup interferes

(What's the best way to deal with it? Are there plugins for the org/markdown etc. format that allow you to search the "invisible" markup-stripped text?)

I mostly use fuzzy searching, not exact matching, it's so convenient.

From Emacs, I just don't search in org-mode, I search into typically my entire user directory, in both .txt files, source code files, .org files, etc. using "counsel-rg" (just a wrapper around ripgrep).

It's super quick. I enter, say, at the Emacs rg prompt:

    gmp lib

So that's "gmp<space>lib" and it'll find every line, in any single file, no matter it's format, where, on the same line, there's "gmp" followed by, anywhere else later on the line, "lib", no matter the capitalization.

The wrapper around rg takes care of calling it with the correct magic invocation.

Say I type: "pi rypi" then Emacs/counsel shall spawn a call to rg looking like this (it's configurable):

    /usr/bin/rg --max-columns 240 --with-filename --no-heading --line-number --color never -i "(pi).*?(rypi)"

And, well, I much prefer to enter simply "pi rypi" and have "(pi).*?(rypi)" generated for me.

I've got the call to "counsel-rg" assigned to a shortcut.

I use it all the time.

P.S: ripgrep is an amazing tool written an HN'er, burntsushi. It's really fast and, by default, won't search into many files you don't care about anyway. It is so fast that on my relatively modern machine (AMD 3700X / NVME M.2 PCIe 3.0x4 SSD) I don't bother and typically search from the root of my home directory.

Oh yes. There are many ways to search in Org mode. I typically only need tagging but you can use the agenda for searching as well.

https://orgmode.org/worg/org-tutorials/advanced-searching.ht...

  • No mention in that document how to:

      1. Search link text only.  
      2. Search link URL only.  
      3. Search headings only.  
      4. Search under the current heading only.

    • I don't know about the first two because those aren't a use case for me, but for 3, you want helm-org-rifle-agenda-files, and for 4, I don't know about something org-specific, but you can use emacs' search commands after narrowing the focus to the current subtree (by default bound to C-x n s, I use this so often that I have it bound to H-f, and I revert focus with s-f, so that I am not distracted while working on an entry).

      The first two are interesting use cases though, I'll reply again if I find something that works.

I think the technical solution to this is to simply index the documents in their rendered (or plain text) format and search against that. Unfortunately that would require an additional tool or plugin.

For org, you want this: https://orgmode.org/manual/Search-view.html If you want to search only on headings, helm-org-rifle-agenda-files is what you need.

  • this doesn't work

    1. only show the list of headings, not highlight the actual text (and I don't need a new pane for such a simple search, my regular search happens right in the text area)

    2. doesn't ignore markup, so `/simply/ search` with one word italicized can't be found with `simply search`

Org-mode has many backends for exporting, including plain text and html, so if you open the exported document in a browser you can Ctrl+F to search and the browser at least ignores most markup. But I agree, this is an inconvenience common to all markup systems.

In practice, I find org-mode to be much less "noisy" than latex or html for example, and about the same as markdown, so it's still a net win for me.

  • That's what I sometimes resort to, though copy&paste the text back to the editor as search in a browser is much worse

How often do you have markup in the middle of a phrase you're searching for? It seems to me like if that's really important to you, then just don't use a lot of markup?

  • What's your universal eternally valid rule on judging the importance of a phrase I could use to decide that bold/italic is too much?

Orgmode does let you search invisible text, it even expands/collapses headlines/lists etc... automatically as you search.

  • That's my imprecise phrasing, by invisible I meant plain text without any markup like bold asterisks (but without having to explicitly build it to make it visible to not introduce any extra inconvenience)