Fix +lookup/in-docsets & docsets lookup backend

They were throwing 'cannot find docset' errors.

- Adds new +lookup/in-all-docsets command.
- If a prefix arg is passed to +lookup/in-docsets, it will search all
  docsets in dash-docs-common-docsets.
This commit is contained in:
Henrik Lissner 2019-05-17 20:43:36 -04:00
parent 507fb50ff2
commit 571e7bd527
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 17 additions and 9 deletions

View file

@ -533,7 +533,8 @@
:desc "Jump to symbol across buffers" "I" #'imenu-anywhere :desc "Jump to symbol across buffers" "I" #'imenu-anywhere
:desc "Jump to link" "l" #'ace-link :desc "Jump to link" "l" #'ace-link
:desc "Look up online" "o" #'+lookup/online-select :desc "Look up online" "o" #'+lookup/online-select
:desc "Look up in docsets" "k" #'+lookup/in-docsets :desc "Look up in local docsets" "k" #'+lookup/in-docsets
:desc "Look up in all docsets" "K" #'+lookup/in-all-docsets
:desc "Search project" "p" #'+default/search-project) :desc "Search project" "p" #'+default/search-project)
;;; <leader> TAB --- workspace ;;; <leader> TAB --- workspace

View file

@ -65,29 +65,36 @@ Docsets must be installed with one of the following commands:
+ `dash-docs-async-install-docset-from-file' + `dash-docs-async-install-docset-from-file'
Docsets can be searched directly via `+lookup/in-docsets'." Docsets can be searched directly via `+lookup/in-docsets'."
(let ((docsets (dash-docs-buffer-local-docsets))) (when-let* ((docsets (cl-remove-if-not #'dash-docs-docset-path (dash-docs-buffer-local-docsets))))
(when (cl-some #'dash-docs-docset-path docsets) (+lookup/in-docsets nil identifier docsets)
(+lookup/in-docsets identifier docsets) 'deferred))
'deferred)))
;; ;;
;;; Commands ;;; Commands
;;;###autoload ;;;###autoload
(defun +lookup/in-docsets (&optional query docsets) (defun +lookup/in-docsets (arg &optional query docsets)
"Lookup QUERY in dash DOCSETS. "Lookup QUERY in dash DOCSETS.
QUERY is a string and docsets in an array of strings, each a name of a Dash QUERY is a string and docsets in an array of strings, each a name of a Dash
docset. Requires either helm or ivy. docset. Requires either helm or ivy.
Use `dash-docs-install-docset' to install docsets." If prefix ARG is supplied, search all installed installed docsets. They can be
(interactive) installed with `dash-docs-install-docset'."
(interactive "P")
(require 'dash-docs) (require 'dash-docs)
(let ((dash-docs-docsets (or docsets (dash-docs-buffer-local-docsets))) (let ((dash-docs-common-docsets (if arg dash-docs-common-docsets))
(dash-docs-docsets (cl-remove-if-not #'dash-docs-docset-path (or docsets dash-docs-docsets)))
(query (or query (+lookup-symbol-or-region) ""))) (query (or query (+lookup-symbol-or-region) "")))
(cond ((featurep! :completion helm) (cond ((featurep! :completion helm)
(helm-dash query)) (helm-dash query))
((featurep! :completion ivy) ((featurep! :completion ivy)
(counsel-dash query)) (counsel-dash query))
((user-error "No dash backend is installed, enable ivy or helm."))))) ((user-error "No dash backend is installed, enable ivy or helm.")))))
;;;###autoload
(defun +lookup/in-all-docsets (&optional query)
"TODO"
(interactive)
(+lookup/in-docsets t query))