summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilij Schneidermann <mail@vasilij.de>2020-10-01 21:09:01 +0200
committerVasilij Schneidermann <mail@vasilij.de>2020-10-01 21:26:09 +0200
commit4a336e9c0e0940ad21716260be9bb393c89f6553 (patch)
tree9ddbdef0179193b4b75541309682a052312ad8d7
parent60ec41f73fb5a4c21bebf29eab1f6ef1bf1bbda9 (diff)
Make undo-tree an optional dependency
Closes #1074
-rw-r--r--Cask1
-rw-r--r--README.md6
-rw-r--r--doc/build/texinfo/evil.texi2
-rw-r--r--doc/source/overview.rst4
-rw-r--r--evil-commands.el11
-rw-r--r--evil-integration.el11
-rw-r--r--evil-maps.el6
-rw-r--r--evil-pkg.el1
-rw-r--r--evil-test-helpers.el1
-rw-r--r--evil-vars.el40
-rw-r--r--evil.el7
11 files changed, 64 insertions, 26 deletions
diff --git a/Cask b/Cask
index a13cfa2..c466b0b 100644
--- a/Cask
+++ b/Cask
@@ -3,4 +3,3 @@
(files "*.el")
;; (depends-on "goto-chg" "0.6.3")
-;; (depends-on "undo-tree" "1.6")
diff --git a/README.md b/README.md
index 16d1cc7..7c76da4 100644
--- a/README.md
+++ b/README.md
@@ -41,8 +41,10 @@ file.
* Evil requires Emacs 24.1 or later.
-* Evil requires [undo-tree.el](http://www.emacswiki.org/emacs/UndoTree) in the
-`load-path` for linear undo and undo branches.
+* Evil requires any of the following for `C-r`:
+** `undo-redo` from Emacs 28
+** The [undo-tree](http://www.emacswiki.org/emacs/UndoTree) package
+** The [undo-fu](https://gitlab.com/ideasman42/emacs-undo-fu) package
* For the motions `g;` `g,` and for the last-change-register `.`, Evil requires the
[goto-chg.el](https://github.com/emacs-evil/goto-chg) package,
diff --git a/doc/build/texinfo/evil.texi b/doc/build/texinfo/evil.texi
index ac3385b..067c057 100644
--- a/doc/build/texinfo/evil.texi
+++ b/doc/build/texinfo/evil.texi
@@ -162,7 +162,7 @@ Finally, add the following lines to your Emacs init file:
@section Manual installation
-First, install @cite{undo-tree}, @cite{goto-chg} and @cite{cl-lib}. If you have an
+First, install @cite{goto-chg} and @cite{cl-lib}. If you have an
Emacs version of 24.3 or newer, you should already have @cite{cl-lib}.
Evil lives in a git repository. To download Evil, do:
diff --git a/doc/source/overview.rst b/doc/source/overview.rst
index 0bb1a7e..467c9ef 100644
--- a/doc/source/overview.rst
+++ b/doc/source/overview.rst
@@ -32,8 +32,8 @@ Finally, add the following lines to your Emacs init file:
Manual installation
-------------------
-First, install `undo-tree`, `goto-chg` and `cl-lib`. If you have an
-Emacs version of 24.3 or newer, you should already have `cl-lib`.
+First, install `goto-chg` and `cl-lib`. If you have an Emacs version
+of 24.3 or newer, you should already have `cl-lib`.
Evil lives in a git repository. To download Evil, do::
diff --git a/evil-commands.el b/evil-commands.el
index 5e5d150..6b14236 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -31,6 +31,7 @@
(require 'evil-types)
(require 'evil-command-window)
(require 'evil-jumps)
+(require 'evil-vars)
(require 'flyspell)
(require 'cl-lib)
(require 'reveal)
@@ -1620,6 +1621,16 @@ of the block."
(when (evil-visual-state-p)
(move-marker evil-visual-point (point)))))
+(evil-define-command evil-undo (count)
+ "Undo COUNT changes in buffer using `evil-undo-function'."
+ (interactive "<c>")
+ (funcall evil-undo-function count))
+
+(evil-define-command evil-redo (count)
+ "Undo COUNT changes in buffer using `evil-redo-function'."
+ (interactive "<c>")
+ (funcall evil-redo-function count))
+
(evil-define-operator evil-substitute (beg end type register)
"Change a character."
:motion evil-forward-char
diff --git a/evil-integration.el b/evil-integration.el
index 9fd8d68..2fd05f5 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -145,17 +145,6 @@
(eval-after-load 'undo-tree
'(with-no-warnings
- (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)
- global-undo-tree-mode)
- (turn-on-undo-tree-mode)))
-
- (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."
(when evil-local-mode
diff --git a/evil-maps.el b/evil-maps.el
index 079b9f6..91ed47e 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -111,8 +111,8 @@
(define-key evil-normal-state-map "g," 'goto-last-change-reverse)
;; undo
-(define-key evil-normal-state-map "u" 'undo)
-(define-key evil-normal-state-map "\C-r" 'redo)
+(define-key evil-normal-state-map "u" 'evil-undo)
+(define-key evil-normal-state-map "\C-r" 'evil-redo)
;; window commands
(define-prefix-command 'evil-window-map)
@@ -517,6 +517,8 @@ included in `evil-insert-state-bindings' by default."
(evil-ex-define-cmd "show-digraphs" 'evil-ex-show-digraphs)
(evil-ex-define-cmd "sor[t]" 'evil-ex-sort)
(evil-ex-define-cmd "res[ize]" 'evil-ex-resize)
+(evil-ex-define-cmd "u[ndo]" 'evil-undo)
+(evil-ex-define-cmd "red[o]" 'evil-redo)
(when (featurep 'tab-bar)
(evil-ex-define-cmd "tabnew" 'tab-bar-new-tab)
diff --git a/evil-pkg.el b/evil-pkg.el
index 558d3c8..f299a42 100644
--- a/evil-pkg.el
+++ b/evil-pkg.el
@@ -3,6 +3,5 @@
"1.14.0"
"Extensible Vi layer for Emacs."
'((emacs "24.1")
- (undo-tree "0.7.4")
(goto-chg "1.6")
(cl-lib "0.5")))
diff --git a/evil-test-helpers.el b/evil-test-helpers.el
index 397b5a6..696d899 100644
--- a/evil-test-helpers.el
+++ b/evil-test-helpers.el
@@ -140,7 +140,6 @@ raised. Remaining forms are evaluated as-is.
;; necessary for keyboard macros to work
(switch-to-buffer-other-window (current-buffer))
(buffer-enable-undo)
- (undo-tree-mode 1)
;; parse remaining forms
,@(mapcar
#'(lambda (form)
diff --git a/evil-vars.el b/evil-vars.el
index 07f478b..1fdf763 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -1971,6 +1971,46 @@ This variable must be set before evil is loaded."
(add-hook 'minibuffer-setup-hook 'evil-initialize)
(remove-hook 'minibuffer-setup-hook 'evil-initialize))))
+(defun evil--redo-placeholder (_count)
+ (user-error "Customize `evil-undo-system' for redo functionality."))
+
+(defvar evil-undo-function 'undo
+ "Function to be used by `evil-undo'.
+Customized via `evil-undo-system'.")
+
+(defvar evil-redo-function 'evil--redo-placeholder
+ "Function to be used by 'evil-redo'.
+Customized via `evil-undo-system'.")
+
+(defun evil-set-undo-system (system)
+ "Set `evil-undo-function' and `evil-redo-function` by SYSTEM."
+ (cond
+ ((not system)
+ (setq evil-undo-function 'undo
+ evil-redo-function 'evil--redo-placeholder))
+ ((eq system 'undo-redo)
+ (setq evil-undo-function 'undo-only
+ evil-redo-function 'undo-redo))
+ ((eq system 'undo-tree)
+ (setq evil-undo-function 'undo-tree-undo
+ evil-redo-function 'undo-tree-redo))
+ ((eq system 'undo-fu)
+ (setq evil-undo-function 'undo-fu-only-undo
+ evil-redo-function 'undo-fu-only-redo))
+ (t
+ (error "Unknown undo system %s" system))))
+
+(defcustom evil-undo-system nil
+ "Undo system Evil should use."
+ :type '(choice (const :tag "Vanilla undo" nil)
+ (const undo-redo)
+ (const undo-tree)
+ (const undo-foo))
+ :group 'evil
+ :set #'(lambda (sym value)
+ (set-default sym value)
+ (evil-set-undo-system value)))
+
(defun evil-version ()
(interactive)
(message "Evil version %s" evil-version))
diff --git a/evil.el b/evil.el
index 14d2b81..e584b31 100644
--- a/evil.el
+++ b/evil.el
@@ -107,11 +107,8 @@
;; (require 'evil)
;; (evil-mode 1)
;;
-;; Evil requires undo-tree.el for linear undo and undo branches:
-;;
-;; http://www.emacswiki.org/emacs/UndoTree
-;;
-;; Otherwise, Evil uses regular Emacs undo.
+;; Evil requires undo-redo (Emacs 28), undo-fu or undo-tree for redo
+;; functionality. Otherwise, Evil uses regular Emacs undo.
;;
;; Evil requires `goto-last-change' and `goto-last-change-reverse'
;; function for the corresponding motions g; g, as well as the