summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.el28
1 files changed, 18 insertions, 10 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el
index c01d8c0..3f1860e 100644
--- a/tag-emacs/emacs.d/init.el
+++ b/tag-emacs/emacs.d/init.el
@@ -330,16 +330,24 @@
 (req-package helm-dash
   :defer t
   :init (progn
-          (defun ap/create-helm-dash-hook (docsets)
-            (lambda ()
-              (when (require 'helm-dash nil :noerror)
-                (setq-local helm-dash-docsets docsets))))
-          (add-hook 'nginx-mode-hook (ap/create-helm-dash-hook '("Nginx")))
-          (add-hook 'ansible-mode-hook (ap/create-helm-dash-hook '("Ansible")))
-          (add-hook 'php-mode-hook (ap/create-helm-dash-hook '("PHP" "Symfony")))
-          (add-hook 'twig-mode-hook (ap/create-helm-dash-hook '("Twig")))
-          (add-hook 'markdown-mode-hook (ap/create-helm-dash-hook '("Markdown")))
-          (add-hook 'saltstack-mode-hook (ap/create-helm-dash-hook '("SaltStack")))))
+          (defmacro ap/create-helm-dash-hook (mode docsets)
+            (let* ((mode-s (symbol-name mode))
+                   (fun (intern (concat "helm-dash-hook-" mode-s)))
+                   (hook (intern (concat mode-s "-mode-hook"))))
+              `(progn
+                 (defun ,fun ()
+                   (when (require 'helm-dash nil :noerror)
+                     (-each (-difference ',docsets
+                                         (helm-dash-installed-docsets))
+                       #'helm-dash-install-docset)
+                     (setq-local helm-dash-docsets ',docsets)))
+                 (add-hook (quote ,hook) (function ,fun)))))
+          (ap/create-helm-dash-hook nginx ("Nginx"))
+          (ap/create-helm-dash-hook ansible ("Ansible"))
+          (ap/create-helm-dash-hook php ("PHP" "Symfony"))
+          (ap/create-helm-dash-hook twig ("Twig"))
+          (ap/create-helm-dash-hook markdown ("Markdown"))
+          (ap/create-helm-dash-hook saltstack ("SaltStack"))))
 
 (req-package which-func
   :init (which-function-mode)