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))) (+lookup--jump-to :documentation identifier)))
((and (featurep! :feature lookup +docsets) ((and (featurep! :feature lookup +docsets)
(cl-find-if #'helm-dash-docset-installed-p (or (require 'counsel-dash nil t)
(require 'helm-dash nil t))
(or (bound-and-true-p counsel-dash-docsets) (or (bound-and-true-p counsel-dash-docsets)
(bound-and-true-p helm-dash-docsets)))) (bound-and-true-p helm-dash-docsets))
(helm-dash-installed-docsets))
(+lookup/in-docsets identifier)) (+lookup/in-docsets identifier))
((featurep! :feature lookup +devdocs) ((featurep! :feature lookup +devdocs)

View file

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