From 3b5ad129172cff59234c4d0d75606142d29cf3b4 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 21 Aug 2014 18:26:27 +0100 Subject: Emacs: Fix dash hook creation --- tag-emacs/emacs.d/init.el | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'tag-emacs') 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) -- cgit 1.4.1