Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u and C-r doesn't work in new buffer with undo-tree as evil-undo-system #1382

Closed
tttuuu888 opened this issue Nov 15, 2020 · 3 comments
Closed

Comments

@tttuuu888
Copy link
Contributor

Issue type

  • Bug report

Environment

Emacs version: GNU Emacs 27.1
Operating System: Arch linux
Evil version: Evil version 1.14.0
Evil installation type: MELPA
Graphical/Terminal: Both
Tested in a make emacs session (see CONTRIBUTING.md): No

Reproduction steps

  • Start Emacs
$ emacs -Q
;;; *scratch* buffer
(package-initialize)
(custom-set-variables '(evil-undo-system 'undo-tree))
(evil-mode)
(global-undo-tree-mode)

2-1.
u and C-r works fine in scratch buffer
2-2.
Open any file
u and C-r works fine.
2-3.
Open new buffer by C-x b test-buffer
u and C-r doesn't work with message "user-error: Enable ‘global-undo-tree-mode’ to use undo-tree commands."

Expected behavior

u and C-r should work in new buffer too.

Actual behavior

u and C-r doesn't work with message "user-error: Enable ‘global-undo-tree-mode’ to use undo-tree commands."

Further notes

This seems happening only when using undo-tree as evil-undo-system. (undo-tree version : 0.7.5)
This wasn't reproduced when tested in make emacs session.
This is happening only in new buffer.

Since this isn't reproduced in make emacs session, I looked into this quite for a while but couldn't figure it out.
I apologize in advance if it's a configuration issue, not a bug.

Thanks.

@tttuuu888
Copy link
Contributor Author

Additionally, this happens simply because undo-tree-mode becomes nil with above reproduction steps.
And undo-tree-mode didn't become nil in same condition without turning evil-mode on.

@wasamasa
Copy link
Member

wasamasa commented Jan 15, 2021

The PR that introduced this change removed this integration code:

(when (and (require 'undo-tree nil t)
           (fboundp 'global-undo-tree-mode))
  (global-undo-tree-mode 1))

(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)))

Could you please test whether adding that code to your repro resolves the issue? Alternatively this simplified version:

(global-undo-tree-mode)
(add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode)

@tttuuu888
Copy link
Contributor Author

@wasamasa Thank you for your opinion.

I tested both code and both fixed the issue. Actually I've been temporarily using the second code for this issue in my configuration. I thought it's temporal solution because now evil-mode use 'evil-undo-system' and this direct setting could be object to new 'evil-undo-system'.

Anyway both version fix my issue. I hope this result could be helpful. Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants