Back to dash-at-point! (and zeal-at-point)

This commit is contained in:
Henrik Lissner 2016-05-26 18:43:22 -04:00
parent 7963c48600
commit 9e7749cf1d
28 changed files with 58 additions and 120 deletions

View file

@ -1,66 +0,0 @@
;;; defuns-dash.el --- helm-dash integration
;;;###autoload
(defun doom/dash-at-pt ()
(interactive)
(let (helm-dash-common-docsets)
(call-interactively 'helm-dash-at-point)))
;;;###autoload
(defun doom/dash-open (url)
"Open url in an *eww* popup."
(interactive)
(save-window-excursion (eww url))
(doom/popup-buffer "*eww*"))
;;;###autoload (autoload 'doom:dash "defuns-dash" nil t)
(evil-define-command doom:dash (&optional bang input)
""
(interactive "<!><a>")
(let ((helm-dash-common-docsets (when bang (helm-dash-installed-docsets))))
(helm-dash-initialize-debugging-buffer)
(helm-dash-create-common-connections)
(helm-dash-create-buffer-connections)
(helm :sources (helm-dash-sources--narrowed-docsets)
:buffer "*helm-dash*"
:prompt "Doc for: "
:history 'helm-dash-history-input
:input (or input "")
:helm-candidate-number-limit 500)))
(defvar doom--dash-docsets nil)
(defvar doom--dash-user-docsets nil)
;;;###autoload (autoload 'doom:dash-install "defuns-dash" nil t)
(evil-define-command doom:dash-install (&optional docset)
"Async docset install."
(interactive "<a>")
(let ((docsets (or doom--dash-docsets
(setq doom--dash-docsets (helm-dash-available-docsets))))
(user-docsets (or doom--dash-user-docsets
(setq doom--dash-user-docsets (helm-dash-search-all-user-docsets)))))
(unless docset
(setq docset (helm-dash-read-docset
"Install docset"
(append docsets (mapcar 'car user-docsets)))))
(message "Installing ...")
(async-start `(lambda ()
,(async-inject-variables "\\`\\(load-path\\|helm-dash-*\\)$")
(require 'f)
(require 'helm)
(require 'helm-dash)
(cond ((member ,docset ',docsets)
(helm-dash-install-docset ,docset)
,docset)
((assoc ,docset ',user-docsets)
(helm-dash-install-user-docset ,docset)
(f-no-ext (f-base (car-safe (cdr-safe (assoc ,docset ',user-docsets))))))))
(lambda (doc)
(unless doc
(error "Invalid docset id" doc))
(message "Installing docset %s ..." doc)
(helm-dash-activate-docset doc)
(setq helm-dash-common-docsets nil)
(message "Docset %s installed" doc)))))
(provide 'defuns-dash)
;;; defuns-dash.el ends here

View file

@ -0,0 +1,17 @@
;;; defuns-docs.el
;;;###autoload (autoload 'doom:docs-lookup "defuns-docs" nil t)
(evil-define-command doom:docs-lookup (&optional bang input)
"Look up INPUT (otherwise the current selection) in Dash or Zeal."
(interactive "<!><a>")
(let ((docset (unless bang (dash-at-point-guess-docset)))
(query input))
(when (evil-visual-state-p)
(setq query (concat (buffer-substring-no-properties (region-beginning) (region-end))
" " query)))
(when (or (not query) (zerop (length query)))
(setq query (thing-at-point 'symbol)))
(doom-docs-lookup query docset)))
(provide 'defuns-docs)
;;; defuns-docs.el ends here

View file

@ -1,8 +0,0 @@
;;; macros-dash.el
;;;###autoload
(defmacro def-docset! (mode docsets)
`(add-hook! ,mode (setq-local helm-dash-docsets ',docsets)))
(provide 'macros-dash)
;;; macros-dash.el ends here