tools/lookup: remove duplicate code & minor fixes
- Removes vestigial definition of +lookup/in-docsets, which would throw an error. - Fixes the universal argument for this function. - Fix multiple set-docsets! calls prepending rather than setting dash-docs-docsets. - Logs search attempts for debugging purposes.
This commit is contained in:
parent
fbf58aac8c
commit
6973a8926d
2 changed files with 7 additions and 29 deletions
|
@ -29,7 +29,7 @@ Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
|||
(let ((action (if (keywordp (car docsets)) (pop docsets))))
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(let ((hook (intern (format "%s-hook" mode)))
|
||||
(fn (make-symbol (format "+lookup|init--%s-%s" (or action "set") mode))))
|
||||
(fn (intern (format "+lookup|init--%s-%s" (or action "set") mode))))
|
||||
(if (null docsets)
|
||||
(remove-hook hook fn)
|
||||
(fset fn
|
||||
|
@ -84,9 +84,13 @@ If prefix ARG is supplied, search all installed installed docsets. They can be
|
|||
installed with `dash-docs-install-docset'."
|
||||
(interactive "P")
|
||||
(require 'dash-docs)
|
||||
(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)))
|
||||
(let ((dash-docs-common-docsets)
|
||||
(dash-docs-docsets
|
||||
(if arg
|
||||
(dash-docs-installed-docsets)
|
||||
(cl-remove-if-not #'dash-docs-docset-path (or docsets dash-docs-docsets))))
|
||||
(query (or query (+lookup-symbol-or-region) "")))
|
||||
(doom-log "Searching docsets %s" dash-docs-docsets)
|
||||
(cond ((featurep! :completion helm)
|
||||
(helm-dash query))
|
||||
((featurep! :completion ivy)
|
||||
|
|
|
@ -316,29 +316,3 @@ Otherwise, falls back on `find-file-at-point'."
|
|||
(run-hooks 'projectile-find-file-hook))))))
|
||||
(#'doom-project-browse))))
|
||||
(find-file-at-point path))))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Source-specific commands
|
||||
|
||||
(defvar counsel-dash-docsets)
|
||||
(defvar helm-dash-docsets)
|
||||
;;;###autoload
|
||||
(defun +lookup/in-docsets (&optional query docsets)
|
||||
"Looks up QUERY (a string) in available Dash docsets for the current buffer.
|
||||
|
||||
DOCSETS is a list of docset strings. Docsets can be installed with
|
||||
`+lookup/install-docset'."
|
||||
(interactive)
|
||||
(let* ((counsel-dash-docsets
|
||||
(unless (eq docsets 'blank)
|
||||
(or docsets
|
||||
(or (bound-and-true-p counsel-dash-docsets)
|
||||
(bound-and-true-p helm-dash-docsets)))))
|
||||
(helm-dash-docsets counsel-dash-docsets)
|
||||
(query (or query (+lookup-symbol-or-region) "")))
|
||||
(cond ((featurep! :completion helm)
|
||||
(helm-dash query))
|
||||
((featurep! :completion ivy)
|
||||
(counsel-dash query))
|
||||
((user-error "No dash backend is installed, enable ivy or helm.")))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue