aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--evil-common.el4
-rw-r--r--evil-integration.el17
2 files changed, 16 insertions, 5 deletions
diff --git a/evil-common.el b/evil-common.el
index 12468c4..9f3b9ae 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -47,10 +47,6 @@
window commands not available.")
nil))
-(when (and (require 'undo-tree nil t)
- (fboundp 'global-undo-tree-mode))
- (global-undo-tree-mode 1))
-
;;; Compatibility with different Emacs versions
(defmacro evil-called-interactively-p ()
diff --git a/evil-integration.el b/evil-integration.el
index 12540a0..5491960 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -206,7 +206,22 @@
"k" 'evil-previous-line
"RET" 'ibuffer-visit-buffer)))
-;;; Undo tree visualizer
+;;; Undo tree
+(when (and (require 'undo-tree nil t)
+ (fboundp 'global-undo-tree-mode))
+ (global-undo-tree-mode 1))
+
+(defun evil-turn-on-undo-tree-mode ()
+ "Enable `undo-tree-mode' if evil is enabled.
+This function enables `undo-tree-mode' when Evil is activated in
+some buffer, but only if `global-undo-tree-mode' is also
+activated."
+ (when (and (boundp 'global-undo-tree-mode)
+ (fboundp 'undo-tree-mode)
+ global-undo-tree-mode)
+ (undo-tree-mode 1)))
+
+(add-hook 'evil-local-mode-hook #'evil-turn-on-undo-tree-mode)
(defadvice undo-tree-visualize (after evil activate)
"Initialize Evil in the visualization buffer."