From a64928c017683d96eff3c2529a05b022c8ee89d7 Mon Sep 17 00:00:00 2001 From: Frank Fischer Date: Sun, 5 Jan 2014 09:52:53 +0100 Subject: enable `undo-tree-mode` when evil is activated `undo-tree-mode` does not get activated automatically in fundamental-mode buffers. But because it is required for Evil to work properly, we use a hook to guarantee that `undo-tree-mode` is activated as soon as Evil is activated, but only if `global-undo-tree-mode` is activated as well. --- evil-common.el | 4 ---- evil-integration.el | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/evil-common.el b/evil-common.el index e90e5ea..2536afe 100644 --- a/evil-common.el +++ b/evil-common.el @@ -44,10 +44,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 5ad156d..4585fae 100644 --- a/evil-integration.el +++ b/evil-integration.el @@ -210,7 +210,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." -- cgit v1.0