Simplify set-docset! & add unset capability
Removed :add and :remove capabilities. Now appends the provided docset to the mode's list of docsets, if one exists.
This commit is contained in:
parent
ad2de8e2e5
commit
dbc7b667cf
1 changed files with 13 additions and 30 deletions
|
@ -12,39 +12,22 @@
|
||||||
"Registers a list of DOCSETS (strings) for MODES (either one major mode
|
"Registers a list of DOCSETS (strings) for MODES (either one major mode
|
||||||
symbol or a list of them).
|
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'."
|
Used by `+lookup/in-docsets' and `+lookup/documentation'."
|
||||||
(dolist (mode (doom-enlist modes))
|
(dolist (mode (doom-enlist modes))
|
||||||
(let ((hook-sym
|
(let ((fn (intern (format "+lookup|init-docsets--%s" mode)))
|
||||||
(intern (format "+lookup|%s-docsets--%s"
|
(hook (intern (format "%s-hook" mode))))
|
||||||
(pcase (car docsets)
|
(cond ((null (car-safe docsets))
|
||||||
(:add 'add)
|
(remove-hook hook fn)
|
||||||
(:remove 'remove)
|
(unintern fn))
|
||||||
(_ 'set))
|
((fset fn
|
||||||
mode))))
|
|
||||||
(fset hook-sym
|
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let (var-sym)
|
(let ((var-sym (if (featurep! :completion ivy)
|
||||||
(cond ((featurep! :completion ivy)
|
'counsel-dash-docsets
|
||||||
(setq var-sym 'counsel-dash-docsets))
|
'helm-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
|
(set var-sym
|
||||||
(cl-loop with to-delete = (cdr docsets)
|
(append (symbol-value var-sym)
|
||||||
for docset in val
|
docsets)))))
|
||||||
unless (member docset to-delete)
|
(add-hook hook fn))))))
|
||||||
collect docset)))
|
|
||||||
(_ (set var-sym (cdr docsets)))))))))
|
|
||||||
(add-hook (intern (format "%s-hook" mode)) hook-sym))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(def-setting! :docset (modes &rest docsets)
|
(def-setting! :docset (modes &rest docsets)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue