feature/lookup: fix docset lookup & setting; add doom-etc-dir/docsets to default paths

This commit is contained in:
Henrik Lissner 2018-03-14 18:47:28 -04:00
parent de730535a4
commit e728e8d04f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 29 additions and 26 deletions

View file

@ -145,9 +145,11 @@ Goes down a list of possible backends:
(+lookup--jump-to :documentation identifier)))
((and (featurep! :feature lookup +docsets)
(cl-find-if #'helm-dash-docset-installed-p
(or (bound-and-true-p counsel-dash-docsets)
(bound-and-true-p helm-dash-docsets))))
(or (require 'counsel-dash nil t)
(require 'helm-dash nil t))
(or (bound-and-true-p counsel-dash-docsets)
(bound-and-true-p helm-dash-docsets))
(helm-dash-installed-docsets))
(+lookup/in-docsets identifier))
((featurep! :feature lookup +devdocs)

View file

@ -138,34 +138,35 @@ 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'."
(cl-loop with ivy-p = (featurep! :completion ivy)
for mode in (doom-enlist (doom-unquote modes))
for hook-sym = (intern (format "+docs|init-for-%s" mode))
for var-sym = (if ivy-p 'counsel-dash-docsets 'helm-dash-docsets)
collect hook-sym into hooks
collect
`(defun ,hook-sym ()
(make-variable-buffer-local ',var-sym)
(cond ((eq ',(car docsets) :add)
`(setq ,var-sym (append ,var-sym (list ,@(cdr docsets)))))
((eq ',(car docsets) :remove)
`(setq ,var-sym
(cl-loop with to-delete = (list ,@(cdr docsets))
for docset in ,var-sym
unless (member docset to-delete)
collect docset)))
(`(setq ,var-sym (list ,@docsets)))))
into forms
finally return `(progn ,@forms (add-hook! ,modes ',hooks))))
(let* ((modes (doom-unquote modes))
(ivy-p (featurep! :completion ivy))
(hook-sym (intern (format "+lookup|%s-docsets--%s"
(cond ((eq ',(car docsets) :add) 'add)
((eq ',(car docsets) :remove) 'remove)
('set))
(string-join docsets "-"))))
(var-sym (if ivy-p 'counsel-dash-docsets 'helm-dash-docsets)))
`(progn
(defun ,hook-sym ()
(make-variable-buffer-local ',var-sym)
,(cond ((eq ',(car docsets) :add)
`(setq ,var-sym (append ,var-sym (list ,@(cdr docsets)))))
((eq ',(car docsets) :remove)
`(setq ,var-sym
(cl-loop with to-delete = (list ,@(cdr docsets))
for docset in ,var-sym
unless (member docset to-delete)
collect docset)))
(`(setq ,var-sym (list ,@docsets)))))
(add-hook! ,modes #',hook-sym))))
;; Both packages depend on helm-dash
(def-package! helm-dash
:commands (helm-dash helm-dash-install-docset helm-dash-at-point
helm-dash-docset-installed-p)
helm-dash-docset-installed-p helm-dash-installed-docsets)
:config
;; Obey XDG conventions
(when-let* ((xdg-data-home (getenv "XDG_DATA_HOME")))
(setq helm-dash-docsets-path (expand-file-name "docsets" xdg-data-home)))
(unless (file-directory-p helm-dash-docsets-path)
(setq helm-dash-docsets-path (concat doom-etc-dir "docsets/")))
(unless (file-directory-p helm-dash-docsets-path)
(make-directory helm-dash-docsets-path t))
(setq helm-dash-enable-debugging doom-debug-mode))