Open zbelial opened 4 years ago
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)))
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.
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?
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.
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.
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.