From a5ccfdca4a92a887bcad336dcb65c98b56892a2a Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 13 Aug 2015 00:49:31 -0700 Subject: [PATCH] Refactor js2-mode-hooks into one function --- dotfiles/emacs.d/init.el | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index adc87e8e..d1aa941d 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -1734,28 +1734,29 @@ window is active in the perspective." (uuid (imalison:uuid))) (insert (format "console.log('%s//////////%s//////////');" identifier-string uuid)) (setq imalison:identifier-count (+ imalison:identifier-count 1)))) - (setq js2-bounce-indent-p nil + (defun imalison:js2-mode-hook () + ;; Sensible defaults + (setq js2-bounce-indent-p nil js2-basic-offset 4 js2-indent-level 4 js2-basic-offset 4 js2-highlight-level 3 js2-include-node-externs t js2-mode-show-parse-errors nil - js2-mode-show-strict-warnings nil) - ;; jshint-configuration-path "~/Uber/dispatch" - (add-hook 'js-mode-hook 'js2-minor-mode) - (add-hook 'js2-mode-hook (lambda () (tern-mode t))) - (add-hook 'js2-mode-hook 'skewer-mode) - (add-hook 'js2-mode-hook (lambda () (setq js-indent-level 4 - indent-tabs-mode nil - js2-indent-level 4 - js2-basic-offset 4 - js2-indent-switch-body t))) - (add-hook 'js2-mode-hook (lambda () - (setq imenu-create-index-function - (lambda () - (imalison:flatten-imenu-index - (js2-mode-create-imenu-index)))))) + js2-mode-show-strict-warnings nil + indent-tabs-mode nil + js2-indent-level 4 + js2-basic-offset 4 + js2-indent-switch-body t) + (edconf-find-file-hook) ;; Make sure that editorconfig takes precedence + (tern-mode t) + (when nil (skewer-mode)) ;; TODO: reenable + (setq imenu-create-index-function + (lambda () + (imalison:flatten-imenu-index + (js2-mode-create-imenu-index))))) + + (add-hook 'js2-mode-hook 'imalison:js2-mode-hook) (add-hook 'js2-mode-hook 'js2-imenu-extras-mode))) (use-package js2-refactor