all repos — nixfiles @ 3b5ad129172cff59234c4d0d75606142d29cf3b4

System and user configuration, managed by nix and home-manager

Emacs: Fix dash hook creation

Alan Pearce
commit

3b5ad129172cff59234c4d0d75606142d29cf3b4

parent

127518ed0855ee81de67f6f3c03bff7e1958d82e

1 file changed, 18 insertions(+), 10 deletions(-)

jump to
M tag-emacs/emacs.d/init.eltag-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)