Fundamental mode and undo-tree-mode

Frank Fischer frank-fischer at shadow-soft.de
Sat Jan 4 09:40:16 CET 2014


Am 04.01.2014 02:13, schrieb Linus Arver:
> On Mon, Dec 30, 2013 at 04:01:45PM -0500, Barry OReilly wrote:
>>    I have this after loading Evil at init.el top level:
>>
>>    (require 'undo-tree)
>>    (global-undo-tree-mode 1)
>>
>>    Evil makes the same call if undo-tree is available on the load-path, so
>>    it's not necessary.
> 
> I'm sorry, I don't quite understand what you're trying to say. I don't
> have those lines in my .emacs, ...

That's exactly what Barry wanted to say, you don't need these lines
because Evil executes them anyway.

> My problem is that undo-tree is loaded, but disabled when I open a file
> with an unrecognized extension (e.g., a file named "foo",
> but not "foo.txt").
> 
> Again, the strange thing is that undo-tree is enabled on the *Messages*
> buffer, but disabled (turned off) in the "foo" buffer.

This is expected. Undo-tree (like Evil) is a minor-mode that is
automatically enabled in each buffer if the corresponding "globalized
minor mode" (namely global-undo-tree-mode) is enabled. This is realised
by some special change-major-mode-hook and  after-change-major-mode-hook
hooks. However, if a new buffer is started in fundamental-mode these
hooks are not run (in contrast to any other major-mode), that's why the
local undo-tree-mode never gets a chance to be activated. The same is
true for Evil.

However, unlike undo-tree Evil adds a few additional hacks to overcome
this problem. That's why Evil gets activated in fundamental-mode buffers
and undo-tree does not.

So if you want undo-tree to be enabled in all buffers in which Evil is
enabled, the simplest solution is probably to do so directly:

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

Best regards,
Frank





More information about the implementations-list mailing list