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

Narrowing down to one specific docset does not work? #192

Open
zbelial opened this issue Feb 5, 2020 · 5 comments
Open

Narrowing down to one specific docset does not work? #192

zbelial opened this issue Feb 5, 2020 · 5 comments

Comments

@zbelial
Copy link

zbelial commented Feb 5, 2020

Thanks firstly. This package is great and makes looking for document convenient.

But narrowing down to a specific docset does not work for me.
I have the same questions as in #180 . It seems that helm-dash filters docsets too early.

I installed helm-dash(version 20190527.1118) from melpa and I'm using emacs 27 compiled from source.

@zbelial
Copy link
Author

zbelial commented Feb 5, 2020

I modified helm-dash--build-source as follows, and now I can use :rust Option to search Option only in Rust docset.

(defun helm-dash--build-source (docset)
              "Build a Helm source for DOCSET."
              (lexical-let ((docset docset))
                (helm-build-sync-source (car docset)
                  :action-transformer #'helm-dash-actions
                  :candidates (lambda ()
                                (when (and (> (length helm-pattern) 0) (equal (substring helm-pattern 0 1) ":"))
                                  (when (string-prefix-p
                                         (concat (downcase (car docset)) " ")
                                         (downcase (substring helm-pattern 1)))
                                    (setq helm-pattern (string-join (cdr (split-string helm-pattern " " t)) " "))
                                    ))
                                (cl-loop for row in (helm-dash--run-query docset helm-pattern)
                                         collect (helm-dash--candidate docset row))
                                )
                  :volatile t
                  :persistent-help "View doc"
                  :requires-pattern helm-dash-min-length)))

@kidd
Copy link
Member

kidd commented Feb 5, 2020

Thanks for the report!

Just tried it and indeed it looks we're filtering too early.

No time now to dig deeper when we got this regression, but it is a valid bug.

I like the :bla prefix. I think we could merge a PR for this once we understand if it fails only on helm or ivy also fails.

@zbelial
Copy link
Author

zbelial commented Feb 7, 2020

Narrowing down in counsel-dash does not work too here. IMO The problem is in the following funtion:

(defun dash-docs-search (pattern)
  "Given a string PATTERN, query docsets and retrieve result."
  (when (>= (length pattern) dash-docs-min-length)
    (cl-loop for docset in (dash-docs-maybe-narrow-docsets pattern)
             appending (dash-docs-search-docset docset pattern))))   ;; PROBLEM

the problem is it does not delete the docset name from the pattern in the line marked with "PROBLEM" , right?

@gilbertw1
Copy link
Member

Hi, sorry I'm just looking at this issue.

I think what is happening here is the filtering does technically work, but only within the context of the docsets contained in the counsel-dash-docsets variable. So, for instance I have a hook that sets my docsets available when working in scala:

(add-hook 'scala-mode-hook (lambda () (setq-local counsel-dash-docsets '("Scala" "Akka" "Play_Scala" "Java"))))

In this case I can type 'Akka ' and it'll correctly limit the search results to akka specific entries. However, if I were to prefix the search with 'Rust ' I would not be able to search within the rust docset since I've not configured that docset for my current buffer.

I personally don't think this behavior should change, but instead perhaps having an alternative doc search function that ignores the counsel-dash-docsets variable and prompts you to select an installed docset to search from would be a good solution.

Also, please let me know if I'm not understanding your problem correctly.

@zbelial
Copy link
Author

zbelial commented Feb 26, 2020

Yes, you're right. Filtering in counsel-dash works. I have no idea why it didn't work when I tested it last time.

So sorry for the incorrect report and thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants