Giter Club home page Giter Club logo

Comments (2)

alphapapa avatar alphapapa commented on July 28, 2024 2

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.

from org-rifle.

karlicoss avatar karlicoss commented on July 28, 2024

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.

from org-rifle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.