2018-05-25 00:46:11 +02:00
|
|
|
;;; feature/lookup/autoload/docsets.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###if (featurep! +docsets)
|
|
|
|
|
2018-06-15 21:37:36 +02:00
|
|
|
(defvar-local helm-dash-docsets nil
|
|
|
|
"Docsets to use for this buffer.")
|
|
|
|
|
|
|
|
(defvar-local counsel-dash-docsets nil
|
|
|
|
"Docsets to use for this buffer.")
|
|
|
|
|
2018-06-15 13:31:34 +02:00
|
|
|
;;;###autodef
|
|
|
|
(defun set-docset! (modes &rest docsets)
|
|
|
|
"Registers a list of DOCSETS (strings) for MODES (either one major mode
|
|
|
|
symbol or a list of them).
|
|
|
|
|
|
|
|
If MODES is a minor mode, you can use :add or :remove as the first element of
|
|
|
|
DOCSETS, to instruct it to append (or remove) those from the docsets already set
|
|
|
|
by a major-mode, if any.
|
|
|
|
|
|
|
|
Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
|
|
|
(dolist (mode (doom-enlist modes))
|
|
|
|
(let ((hook-sym
|
|
|
|
(intern (format "+lookup|%s-docsets--%s"
|
|
|
|
(pcase (car docsets)
|
|
|
|
(:add 'add)
|
|
|
|
(:remove 'remove)
|
|
|
|
(_ 'set))
|
|
|
|
mode))))
|
|
|
|
(fset hook-sym
|
|
|
|
(lambda ()
|
|
|
|
(let (var-sym)
|
|
|
|
(cond ((featurep! :completion ivy)
|
|
|
|
(setq var-sym 'counsel-dash-docsets))
|
|
|
|
((featurep! :completion helm)
|
|
|
|
(setq var-sym 'helm-dash-docsets)))
|
|
|
|
(when var-sym
|
|
|
|
(let ((val (symbol-value var-sym)))
|
|
|
|
(pcase (car docsets)
|
|
|
|
(:add
|
|
|
|
(set var-sym (append val (cdr docsets))))
|
|
|
|
(:remove
|
|
|
|
(set var-sym
|
|
|
|
(cl-loop with to-delete = (cdr docsets)
|
|
|
|
for docset in val
|
|
|
|
unless (member docset to-delete)
|
|
|
|
collect docset)))
|
|
|
|
(_ (set var-sym (cdr docsets)))))))))
|
|
|
|
(add-hook (intern (format "%s-hook" mode)) hook-sym))))
|
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
;;;###autoload
|
|
|
|
(def-setting! :docset (modes &rest docsets)
|
|
|
|
"Registers a list of DOCSETS (strings) for MODES (either one major mode
|
|
|
|
symbol or a list of them).
|
|
|
|
|
|
|
|
If MODES is a minor mode, you can use :add or :remove as the first element of
|
|
|
|
DOCSETS, to instruct it to append (or remove) those from the docsets already set
|
|
|
|
by a major-mode, if any.
|
|
|
|
|
|
|
|
Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
2018-06-15 13:31:34 +02:00
|
|
|
:obsolete set-docset!
|
|
|
|
`(set-docset! ,modes ,@docsets))
|
2018-05-25 00:46:11 +02:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(autoload 'helm-dash-installed-docsets "helm-dash")
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(autoload 'helm-dash-docset-installed-p "helm-dash")
|