aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEivind Fonn <evfonn@gmail.com>2019-12-20 13:48:58 +0100
committerEivind Fonn <evfonn@gmail.com>2019-12-21 10:09:42 +0100
commit183bae9e64da2f0389aaa07dfbfd6cfe4620372c (patch)
tree911beb1ecc4e1f508ca45d5b0f5721074d815618
parentc95049a2ca471fc7bdc0cb14f11b482f3e20e834 (diff)
Expand abbrevs after insert state only if abbrev-mode is enabled
-rw-r--r--evil-integration.el9
-rw-r--r--evil-tests.el20
-rw-r--r--evil-vars.el4
3 files changed, 23 insertions, 10 deletions
diff --git a/evil-integration.el b/evil-integration.el
index 33abb5f..284f9d4 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -516,9 +516,12 @@ Based on `evil-enclose-ace-jump-for-motion'."
"V" 'evil-visual-screen-line))
;;; abbrev.el
-(when evil-want-abbrev-expand-on-insert-exit
- (eval-after-load 'abbrev
- '(add-hook 'evil-insert-state-exit-hook 'expand-abbrev)))
+(defun evil-maybe-expand-abbrev ()
+ (when (and abbrev-mode evil-want-abbrev-expand-on-insert-exit)
+ (expand-abbrev)))
+
+(eval-after-load 'abbrev
+ '(add-hook 'evil-insert-state-exit-hook 'evil-maybe-expand-abbrev))
;;; ElDoc
(eval-after-load 'eldoc
diff --git a/evil-tests.el b/evil-tests.el
index 503f12e..f69f82c 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -8262,20 +8262,30 @@ maybe we need one line more with some text\n")
:tags '(evil abbrev)
(ert-info ("Test abbrev expansion on insert state exit")
(define-abbrev-table 'global-abbrev-table
- '(("undef" "undefined"))) ;; add global abbrev
+ '(("undef" "undefined"))) ; add global abbrev
(evil-test-buffer
"foo unde[f] bar"
+ (abbrev-mode)
("a" [escape])
- "foo undefine[d] bar") ;; 'undef' should be expanded
+ "foo undefine[d] bar") ; 'undef' should be expanded
+ (evil-test-buffer
+ "foo unde[f] bar"
+ ("a" [escape])
+ "foo unde[f] bar") ; 'undef' shouldn't be expanded,
+ ; abbrev-mode is not enabled
(evil-test-buffer
"fo[o] undef bar"
+ (abbrev-mode)
("a" [escape])
- "fo[o] undef bar") ;; 'foo' shouldn't be expanded, it's not an abbrev
- (kill-all-abbrevs) ;; remove abbrevs
+ "fo[o] undef bar") ; 'foo' shouldn't be expanded,
+ ; it's not an abbrev
+ (kill-all-abbrevs) ; remove all abbrevs
(evil-test-buffer
"foo unde[f] bar"
+ (abbrev-mode)
("a" [escape])
- "foo unde[f] bar") ;; 'undef' is not an abbrev, shouldn't be expanded
+ "foo unde[f] bar") ; 'undef' shouldn't be expanded,
+ ; it's not an abbrev
(setq abbrevs-changed nil)))
(ert-deftest evil-test-text-object-macro ()
diff --git a/evil-vars.el b/evil-vars.el
index 0fa7ac1..2264ba8 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -1232,8 +1232,8 @@ command is non-zero."
:group 'evil)
(defcustom evil-want-abbrev-expand-on-insert-exit t
- "If non-nil abbrevs will be expanded when leaving Insert state
-like in Vim. This variable is read only on load."
+ "If non-nil abbrevs will be expanded when leaving insert state
+like in Vim, if `abbrev-mode' is on."
:type 'boolean
:group 'evil)