Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm-org-ql option to remove filename from query results #62

Open
matthuszagh opened this issue Dec 2, 2019 · 3 comments
Open

helm-org-ql option to remove filename from query results #62

matthuszagh opened this issue Dec 2, 2019 · 3 comments

Comments

@matthuszagh
Copy link

Would it be feasible to add an option to suppress the filename from query results? I imagine the current behavior is best for most use cases. However, I do almost all of my queries in a single file and so, for me, the filename simply takes up horizontal real estate.

In case it's unclear what I'm asking, take the following example.
file:

* a
** b

current query:

Query (boolean AND): a
helm-org-ql
tmp.org:a\

proposed query:

Query (boolean AND): a
helm-org-ql
a\
@alphapapa
Copy link
Owner

That would be fairly easy. The filename prefix is done here: https://github.com/alphapapa/org-ql/blob/master/helm-org-ql.el#L229 So you could easily redefine that function, or replace it with advice, in your config.

After having added so many configuration options in helm-org-rifle, I'd like to reduce the number of them used in this package, if possible. Speed is important for searching, and adding more branches in the results functions doesn't help (although I haven't measured it in this case, so maybe it wouldn't matter for speed). It also, eventually, makes for a bewildering number of options, which makes the code implementing them complicated.

So, generally, I'd like to do such customization in more flexible ways in this package. I'm not sure yet what those ways would be. Obviously, a user-defined function is one way, but requiring users to write Lisp code to do something like this is also not desirable. A format-spec formatter might be an option as well.

Anyway, for your own needs, adjusting that function should do it.

@matthuszagh
Copy link
Author

Here's the code to do that if anyone else wants this:

(defun mh//helm-org-ql--heading (window-width)
      "Return string for Helm for heading at point.
WINDOW-WIDTH should be the width of the Helm window."
      (font-lock-ensure (point-at-bol) (point-at-eol))
      (let* ((width window-width)
             (path (-> (org-get-outline-path)
                       (org-format-outline-path width nil "")
                       (org-split-string "")))
             (heading (org-get-heading t))
             (path (if helm-org-ql-reverse-paths
                       (concat heading "\\" (s-join "\\" (nreverse path)))
                     (concat (s-join "/" path) "/" heading))))
        (cons path (point-marker))))
    (advice-add 'helm-org-ql--heading :override #'mh//helm-org-ql--heading)

This does make me a little nervous, since I need to keep track of changes to the helm-org-ql--heading function. However, I do hear your desire not to want to support a million different configuration options.

@alphapapa
Copy link
Owner

Don't worry, the only thing that matters is that the function returns a cons with the display string in the CAR and the marker in the CDR. That's not going to be changing anytime soon--probably never.

@alphapapa alphapapa added this to the 0.5 milestone Jan 3, 2020
@alphapapa alphapapa modified the milestones: 0.5, 0.6 Nov 20, 2020
@alphapapa alphapapa modified the milestones: 0.6, Future Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants