From c080ae8c9f09e2be10a133c246d0aeba2d431694 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 30 Sep 2019 14:58:06 -0400 Subject: [PATCH] Only disable smartparens in replace mode if it is enabled Prevents an issue where smartparens would re-enable itself, even when it has been disabled by the user. --- core/core-editor.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/core-editor.el b/core/core-editor.el index f65b4b14c..41d64ffe6 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -394,8 +394,17 @@ files, so we replace calls to `pp' with the much faster `prin1'." (sp-local-pair 'minibuffer-inactive-mode "`" nil :actions nil) ;; Smartparens breaks evil-mode's replace state - (add-hook 'evil-replace-state-entry-hook #'turn-off-smartparens-mode) - (add-hook 'evil-replace-state-exit-hook #'turn-on-smartparens-mode) + (defvar doom-buffer-smartparens-mode nil) + (add-hook! 'evil-replace-state-exit-hook + (defun doom-enable-smartparens-mode-maybe-h () + (when doom-buffer-smartparens-mode + (turn-on-smartparens-mode) + (kill-local-variable 'doom-buffer-smartparens-mode)))) + (add-hook! 'evil-replace-state-entry-hook + (defun doom-disable-smartparens-mode-maybe-h () + (when smartparens-mode + (setq-local doom-buffer-smartparens-mode t) + (turn-off-smartparens-mode)))) (smartparens-global-mode +1))