summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
authorAlan Pearce2014-08-21 18:26:27 +0100
committerAlan Pearce2014-08-21 18:26:27 +0100
commit3b5ad129172cff59234c4d0d75606142d29cf3b4 (patch)
treefd2ba0470a0e5b969a69cf6a3c1221d0d1a7b6bc /tag-emacs
parent127518ed0855ee81de67f6f3c03bff7e1958d82e (diff)
downloaddotfiles-3b5ad129172cff59234c4d0d75606142d29cf3b4.tar.lz
dotfiles-3b5ad129172cff59234c4d0d75606142d29cf3b4.tar.zst
dotfiles-3b5ad129172cff59234c4d0d75606142d29cf3b4.zip
Emacs: Fix dash hook creation
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)