0

A few months ago I noticed undo-tree was not working properly for me, though it had never been a problem in the past. Whenever I opened an existing file on my computer and edited it, trying to undo would give me a message saying "Undo-tree mode not enabled in buffer." If I manually enabled undo-tree mode per buffer everything would work fine, however that had never been the case before. It simply worked with my config.

Strangely it seems to be a key binding causing the problem. I'm using general.el to do my keybinds. Here is a minimal config that reproduces the issue:

(require 'package)

(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(require 'use-package)
(setq use-package-always-ensure t)

(use-package evil
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil)
  (setq evil-want-C-u-scroll t)
  (setq evil-want-C-i-jump nil)
  (setq evil-ex-search-vim-style-regexp t)
  (setq evil-respect-visual-line-mode t)
;  (defvar my/cur-window nil)
  :config
  (evil-mode 1)
  (setq evil-vsplit-window-right t)
  (setq evil-split-window-below t)
  (setq evil-want-fine-undo t))

(use-package evil-collection
  :after evil
  :config
  (evil-collection-init))

 (use-package general
   :ensure t
   :config (general-evil-setup t))

(use-package undo-tree
  :ensure t
  :config
  (evil-set-undo-system 'undo-tree)
  (global-undo-tree-mode 1))

 (nvmap :keymaps 'override
   "/"  'swiper
  "C-/" 'counsel-rg)

If you remove the very last line (the counsel-rg binding) things seem to work as they should. I don't understand what's causing this issue, and how to fix it.

1 Answer 1

0

In undo-tree.el there is a turn-on-undo-tree-mode function. One of the things it does before turning on undo-tree-mode is checking if the default undo/redo keybindings have been overridden. It does this using a function called (undo-tree-overridden-undo-bindings-p). I forced that to always return nil, which seems to have solved the problem:

  (advice-add 'undo-tree-overridden-undo-bindings-p
              :override
              (lambda () nil))

Whether or not this will have any unintended consequences, I'm not sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.