From 447371cee92ddc6bd349022a9184d06c92746f60 Mon Sep 17 00:00:00 2001 From: Eivind Fonn Date: Thu, 3 Dec 2015 16:33:03 +0100 Subject: [PATCH] Fix smartparens workaround in auto-completion --- layers/auto-completion/packages.el | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/layers/auto-completion/packages.el b/layers/auto-completion/packages.el index c1473003fba7..f61f87738fce 100644 --- a/layers/auto-completion/packages.el +++ b/layers/auto-completion/packages.el @@ -21,6 +21,7 @@ hippie-exp yasnippet auto-yasnippet + smartparens )) ;; company-quickhelp from MELPA is not compatible with 24.3 anymore @@ -263,18 +264,6 @@ eshell-mode-hook))) :config (progn - ;; We need to know whether the smartparens was enabled, see - ;; `yas-before-expand-snippet-hook' below. - (defvar smartparens-enabled-initially t - "Stored whether smartparens is originally enabled or not.") - - (add-hook 'yas-before-expand-snippet-hook (lambda () - ;; If enabled, smartparens will mess snippets expanded by `hippie-expand` - (setq smartparens-enabled-initially smartparens-mode) - (smartparens-mode -1))) - (add-hook 'yas-after-exit-snippet-hook (lambda () - (when smartparens-enabled-initially - (smartparens-mode 1)))) (spacemacs|diminish yas-minor-mode " ⓨ" " y")))) (defun auto-completion/init-auto-yasnippet () @@ -295,3 +284,19 @@ "iSc" 'aya-create "iSe" 'spacemacs/auto-yasnippet-expand "iSw" 'aya-persist-snippet)))) + +(defun auto-completion/post-init-smartparens () + (with-eval-after-load 'smartparens + ;; We need to know whether the smartparens was enabled, see + ;; `yas-before-expand-snippet-hook' below. + (defvar smartparens-enabled-initially t + "Stored whether smartparens is originally enabled or not.") + (add-hook 'yas-before-expand-snippet-hook + (lambda () + ;; If enabled, smartparens will mess snippets expanded by `hippie-expand` + (setq smartparens-enabled-initially smartparens-mode) + (smartparens-mode -1))) + (add-hook 'yas-after-exit-snippet-hook + (lambda () + (when smartparens-enabled-initially + (smartparens-mode 1))))))