Open karlicoss opened 5 years ago
Hi,
Thanks for the feedback.
jumping to occurence in the buffer as you move through helm list (e.g. see gif). Is it possible in rifle? Perhaps I missed some setting to turn it on, but didn't manage to find.
That should be covered by helm-follow-mode
, which is a built-in feature of Helm that generally requires no special support by Helm sources. Try pressing C-c C-f
after candidates are displayed.
if you've got, say, two occurences of the search term on different lines under the same heading, swoop would show it twice on separate lines (as grep would), and I would be able to navigate with C-j/C-k between them. In contrast, org-rifle would only show you single line separated by the ellipsis. I've got something closer to what I want with (setq helm-org-rifle-ellipsis-string "\n"), but it still navigates between headings only. Would it be hard to implement, or it goes against the idea of what org-rifle is meant to do somehow?
That basically is contrary to the design of org-rifle. Results are intended to be presented similar to a Web search engine, with the heading being like a Web page title and showing matching context strings below. The jump-to commands jump to entry headings, not to matching terms within an entry.
Doing it the way you explained would be an interesting feature. If you're interested in working on that feature, I'd be willing to consider patches. The code isn't particularly elegant, and it would require some refactoring here and there to support both modes. I've learned a lot since I made org-rifle, so if I were doing it over again (see below), I'd probably do it in a more flexible, functional way.
somewhat minor, but I also use swoop to search in non-org mode files (e.g. older notes from my pre-orgmode era, huge org-mode files which I open in fundamental mode, some random text files, etc). How hard do you think it would be to support fallback to swoop-like (grep-like) behaviour for non-org mode buffers?
Given the rather inelegant and inflexible state of the code, it would require changes and refactoring in several places. It would probably be pretty messy. I don't think I'd want to do that, because the purpose of the package is searching Org files, and that would add complexity that doesn't serve that purpose.
However, I don't think you need to modify this package to achieve that, because you should be able to do something like that by combining Helm sources in a single helm
invocation. For example, in your command, take the list of files, map helm-org-rifle-get-source-for-file
for each Org file, and helm-c-source-multi-swoop
for non-Org files (see e.g. helm-multi-swoop--exec
).
For example, using my helm-swish package (faster but less featureful than helm-swoop), I came up with this, which seems to work:
(defun kc/org-rifle-swish (files)
"Search FILES with `helm-org-rifle' and `helm-swish'."
(interactive)
(let ((sources (--map (pcase it
((rx ".org" eos) (helm-org-rifle-get-source-for-file it))
(_ (let ((buffer (or (find-buffer-visiting it)
(find-file-noselect it))))
(helm-make-source
(buffer-name buffer) 'helm-source-swish
:action (helm-make-actions
"Go to line" #'helm-swish-goto-line)
:get-line #'helm-swish-get-line))))
files)))
(helm :sources sources)))
Used like this, it searches these two files, one of which is an Org file:
(kc/org-rifle-swish '("~/org/main.org" "~/src/emacs/org-ql/org-ql.el"))
By the way, as I said, I've learned a lot since I made org-rifle, and in the process I've made org-ql
, which has a helm-org-ql
command. Its design is cleaner and more flexible, and it's much faster as well. By default, it doesn't show match context at all, but I'm experimenting with that in a branch. It would be much easier to implement your context-lines idea with org-ql
, because it would basically be a matter of adjusting the action function called at each match.
Eventually, org-rifle
will probably either be obsoleted by org-ql
or be rewritten to use org-ql
as a backend, so if you're interested in building some custom tools, I'd recommend basing them on org-ql
.
Thanks for a very comprehensive answer!
Follow mode works, I'll also take a look at multi source helm suggestion, that makes a lot of sense.
Hi there! Finally got time to check out org-rifle, got a minor issue, but otherwise I really like that it displays the outline header in search result, great job!
I've been using helm-swoop for a while to search through my plaintext notes.
There are few things I would miss from helm-swoop (I was testing on
helm-org-rifle
command):(setq helm-org-rifle-ellipsis-string "\n")
, but it still navigates between headings only. Would it be hard to implement, or it goes against the idea of what org-rifle is meant to do somehow?Thanks!