-
Notifications
You must be signed in to change notification settings - Fork 34
Info-like continuous search [feature request] #4
Comments
The easiest way of implementing full-text search would be by using |
That would work too; I might give a try implementing this using |
OK, I got it to jump to the HTML source using this: (defun counsel-rg-nov (&optional initial-input)
"Search for a pattern in current ebook using rg.
INITIAL-INPUT can be given as the initial minibuffer input.
The ebook is assumed to be opened by the `nov' package and so
`nov-temp-dir' variable should be set automatically."
(interactive)
(if (file-exists-p nov-temp-dir)
(counsel-rg initial-input nov-temp-dir " -g '*.*html'" (format "Search %s" (buffer-name)))
(user-error (format "%S does not exist" nov-temp-dir)))) Now I need help so that that jump happens to the corresponding location in the rendered page instead of to the html. |
Hi @wasamasa, I would like to take a stab at implementing the |
Navigating point to each match is going to be a challenge. I suspect the better solution is to avoid the mismatch between going from rendered document -> source document -> rendered document by performing the search inside the current rendered document, then jumping to the next document if necessary and repeating until hitting a match or the end of the document (after that a wraparound could be performed, much like in info's outright magic incremental search). There is one prerequisite before attempting this, nov.el keeps only the current document in the buffer and re-renders it whenever needed. This may take enough time to make incremental search unusable. So some sort of caching solution would need to be implemented first, along with a strategy when exactly to load something into the cache:
Since this is caching, some strategy to invalidate the cache needs to be implemented as well. For example the |
You could use
Although I don't know how accurate the PS. This method wouldn't be too friendly to |
Thanks for your ideas on that one. I'm aware of |
Regarding mapping DOM nodes to source locations, it seems I'm not the first to think of it: https://lists.gnu.org/archive/html/emacs-devel/2020-02/msg00096.html |
Searching through
It would be cool to have occur-like functionality to find all matches in the whole epub file. The code from this one could be reused for that functionality. I said dom-texts method wouldn't be too occur-friendly because it would be faster to run if all the pages were cached right from the start. If the caching was asynchronous, it wouldn't appear to be slow. Maybe it's the way to go. |
I have my doubts. There's three ways of achieving async behavior:
Processes are useful if your communication is limited to strings, however we're dealing with fontified buffers here. One-shot timers are a poor way of faking threads, provided whatever you do doesn't take too long. |
In Info-mode, you can
C-s
and search for anything through the whole document. What I mean is that you do not have to be present in an Info node containing the string you are searching for.. If Info does not find your search string in the current node, it will try searching in the next node, and so on.Can something like that be done for searching in epubs? I can be in the TOC buffer of an ebook and starting searching with
C-s
..nov.el
should then try to find that term successively in the whole ebook.Thanks!
The text was updated successfully, but these errors were encountered: