Toggling evil-local-mode off when updating buffers with magit
Hi! Magit-refresh does the following: Refresh current buffer to match repository state. Also revert every unmodified buffer visiting files in the corresponding directory. When I run this command after some changes have actually been made to files that a buffer is visiting, those buffers are reverted. When this happens, it seems that evil-local-mode becomes disabled: Toggling evil-local-mode off; better pass an explicit argument. What’s going on? This is at master.
This seems to happen when calling revert-buffer interactively as well. On Wed, Nov 2, 2011 at 18:11, Nikolai Weibull <[email protected]> wrote:
Hi!
Magit-refresh does the following:
Refresh current buffer to match repository state. Also revert every unmodified buffer visiting files in the corresponding directory.
When I run this command after some changes have actually been made to files that a buffer is visiting, those buffers are reverted. When this happens, it seems that evil-local-mode becomes disabled:
Toggling evil-local-mode off; better pass an explicit argument.
What’s going on?
This is at master.
On Wed, Nov 02, 2011 at 06:14:40PM +0100, Nikolai Weibull wrote:
This seems to happen when calling revert-buffer interactively as well.
You mean calling revert-buffer in an arbitrary buffer (that has nothing to do with magit)? In that case I can't reproduce the error. Frank
On Wed, Nov 2, 2011 at 18:11, Nikolai Weibull <[email protected]> wrote:
Hi!
Magit-refresh does the following:
Refresh current buffer to match repository state. Also revert every unmodified buffer visiting files in the corresponding directory.
When I run this command after some changes have actually been made to files that a buffer is visiting, those buffers are reverted. When this happens, it seems that evil-local-mode becomes disabled:
Toggling evil-local-mode off; better pass an explicit argument.
What’s going on?
This is at master.
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
On Thu, Nov 3, 2011 at 08:34, Frank Fischer <[email protected]> wrote:
On Wed, Nov 02, 2011 at 06:14:40PM +0100, Nikolai Weibull wrote:
This seems to happen when calling revert-buffer interactively as well.
You mean calling revert-buffer in an arbitrary buffer (that has nothing to do with magit)? In that case I can't reproduce the error.
Hm, well, it’s a buffer visiting a file under version control, so I guess magit might have done something to it. I’ll try to narrow it down if no one else can reproduce this.
On Thu, Nov 3, 2011 at 10:29, Nikolai Weibull <[email protected]> wrote:
On Thu, Nov 3, 2011 at 08:34, Frank Fischer <[email protected]> wrote:
On Wed, Nov 02, 2011 at 06:14:40PM +0100, Nikolai Weibull wrote:
This seems to happen when calling revert-buffer interactively as well.
You mean calling revert-buffer in an arbitrary buffer (that has nothing to do with magit)? In that case I can't reproduce the error.
Hm, well, it’s a buffer visiting a file under version control, so I guess magit might have done something to it. I’ll try to narrow it down if no one else can reproduce this.
I narrowed it down. Magit-revert-buffers calls revert-buffer as (revert-buffer t t nil), that is, it doesn’t preserve modes. Still, if I understand things correctly, calling revert-buffer interactively would result in modes not being preserved. Either way, it seems that this disables evil-local-mode.
On Fri, Nov 4, 2011 at 11:48, Nikolai Weibull <[email protected]> wrote:
On Thu, Nov 3, 2011 at 10:29, Nikolai Weibull <[email protected]> wrote:
On Thu, Nov 3, 2011 at 08:34, Frank Fischer <[email protected]> wrote:
On Wed, Nov 02, 2011 at 06:14:40PM +0100, Nikolai Weibull wrote:
This seems to happen when calling revert-buffer interactively as well.
You mean calling revert-buffer in an arbitrary buffer (that has nothing to do with magit)? In that case I can't reproduce the error.
Hm, well, it’s a buffer visiting a file under version control, so I guess magit might have done something to it. I’ll try to narrow it down if no one else can reproduce this.
I narrowed it down. Magit-revert-buffers calls revert-buffer as (revert-buffer t t nil), that is, it doesn’t preserve modes. Still, if I understand things correctly, calling revert-buffer interactively would result in modes not being preserved. Either way, it seems that this disables evil-local-mode.
Am I the only one experiencing this? (Am I the only one using both Magit and Evil?)
On Wed, Nov 16, 2011 at 04:49:22PM +0100, Nikolai Weibull wrote:
On Fri, Nov 4, 2011 at 11:48, Nikolai Weibull <[email protected]> wrote:
On Thu, Nov 3, 2011 at 10:29, Nikolai Weibull <[email protected]> wrote:
On Thu, Nov 3, 2011 at 08:34, Frank Fischer <[email protected]> wrote:
On Wed, Nov 02, 2011 at 06:14:40PM +0100, Nikolai Weibull wrote:
This seems to happen when calling revert-buffer interactively as well.
You mean calling revert-buffer in an arbitrary buffer (that has nothing to do with magit)? In that case I can't reproduce the error.
Hm, well, it’s a buffer visiting a file under version control, so I guess magit might have done something to it. I’ll try to narrow it down if no one else can reproduce this.
I narrowed it down. Magit-revert-buffers calls revert-buffer as (revert-buffer t t nil), that is, it doesn’t preserve modes. Still, if I understand things correctly, calling revert-buffer interactively would result in modes not being preserved. Either way, it seems that this disables evil-local-mode.
Am I the only one experiencing this?
(Am I the only one using both Magit and Evil?)
Well, I use neither git nor magit, that's why I hoped someone else with more experience in both may have a look at this issue ;) Frank
Oh, and it is a good idea to use evil's issue tracker at http://bitbucket.org/lyro/evil because otherwise we may easily forget some issue if we can't (or want) to tackle them immediately.
On Thu, Nov 17, 2011 at 10:23, Frank Fischer <[email protected]> wrote:
Oh, and it is a good idea to use evil's issue tracker at
http://bitbucket.org/lyro/evil
because otherwise we may easily forget some issue if we can't (or want) to tackle them immediately.
Sure, but in this case I’m still not clear if this is a problem with Evil or not. The problem is that revert-buffer is told to not restore local modes. The question is thus whether magit is doing things right by not restoring local modes and Evil shouldn’t be using a local mode or if it’s the other way around. If it’s the other way around, I should be posting a bug on the magit tracker instead.
On 17 Nov 2011, Nikolai Weibull wrote:
Sure, but in this case I’m still not clear if this is a problem with Evil or not. The problem is that revert-buffer is told to not restore local modes. The question is thus whether magit is doing things right by not restoring local modes and Evil shouldn’t be using a local mode or if it’s the other way around.
To answer your previous question: I use magit with evil. But with the global mode so I don't run into problems here. I think the "problem" lies with magit but I'm not totally sure if it's a problem or a feature. Either way it better should be configurable or magit should run the right hooks (assuming you use evil-local-mode in a hook or something).
If it’s the other way around, I should be posting a bug on the magit tracker instead.
I think that's better, too. Michael
On Thu, Nov 17, 2011 at 13:48, Michael Markert <[email protected]> wrote:
On 17 Nov 2011, Nikolai Weibull wrote:
Sure, but in this case I’m still not clear if this is a problem with Evil or not. The problem is that revert-buffer is told to not restore local modes. The question is thus whether magit is doing things right by not restoring local modes and Evil shouldn’t be using a local mode or if it’s the other way around.
To answer your previous question: I use magit with evil. But with the global mode so I don't run into problems here.
Ah, might the problem be that I use, for example, (define-key evil-insert-state-local-map "e" 'ruby-electric-end-character) in my ruby-mode-hook? So when magit reverts a ruby buffer, ruby-mode-hook is run, the define-key above is run, but then evil-local-mode is in the wrong state and is turned off instead of on or something?
On Thu, Nov 17, 2011 at 04:16:51PM +0100, Nikolai Weibull wrote:
Ah, might the problem be that I use, for example,
(define-key evil-insert-state-local-map "e" 'ruby-electric-end-character)
in my ruby-mode-hook? So when magit reverts a ruby buffer, ruby-mode-hook is run, the define-key above is run, but then evil-local-mode is in the wrong state and is turned off instead of on or something?
That would be surprising as the state's behavior has nothing to do with the keymaps. The keymaps are just for the user as usual Emacs keymaps are. Frank
On Thu, Nov 17, 2011 at 17:11, Frank Fischer <[email protected]> wrote:
On Thu, Nov 17, 2011 at 04:16:51PM +0100, Nikolai Weibull wrote:
Ah, might the problem be that I use, for example,
(define-key evil-insert-state-local-map "e" 'ruby-electric-end-character)
in my ruby-mode-hook? So when magit reverts a ruby buffer, ruby-mode-hook is run, the define-key above is run, but then evil-local-mode is in the wrong state and is turned off instead of on or something?
That would be surprising as the state's behavior has nothing to do with the keymaps. The keymaps are just for the user as usual Emacs keymaps are.
That’s what I thought. As I’ve understood it, from reading up on evil-local-mode, it can be used when you only want Evil in some buffers. I want Evil everywhere. For me, both evil-mode and evil-local-mode are enabled in all buffers, but is getting disabled by revert-buffer and it being disabled disables Evil in my buffers.
On Thu, Nov 17, 2011 at 10:30:27PM +0100, Nikolai Weibull wrote:
As I’ve understood it, from reading up on evil-local-mode, it can be used when you only want Evil in some buffers. I want Evil everywhere. For me, both evil-mode and evil-local-mode are enabled in all buffers, but is getting disabled by revert-buffer and it being disabled disables Evil in my buffers.
I've just tried to reproduce the error but I had no luck. Whatever I tried, evil remained active. Could you please give a minimal example, ideally starting with a fresh "make emacs" from evil's source, loading magit, a small git repo (may be evil's own), doing some changes and so on that makes that error occur? Frank
On Fri, Nov 18, 2011 at 08:30, Frank Fischer <[email protected]> wrote:
Could you please give a minimal example, ideally starting with a fresh "make emacs" from evil's source
I can’t run ‹make emacs› on my terminal for some reason (PuTTYCyg at work), as Emacs complains that standard input is not a terminal. Running ‹make terminal› works and after saying no to running the tests (running the tests gives the same result) I run the following: C-x C-f evil-ex.el C-m M-: (revert-buffer t t nil) C-m resulting in Toggling evil-local-mode off; better pass an explicit argument. t This was with master at aac1f7831174e743f55b775fbdf87b0877e7be27. My Emacs is at 23.3.1.
On Fri, Nov 18, 2011 at 09:47:35AM +0100, Nikolai Weibull wrote:
Running ‹make terminal› works and after saying no to running the tests (running the tests gives the same result) I run the following:
C-x C-f evil-ex.el C-m M-: (revert-buffer t t nil) C-m
resulting in
Toggling evil-local-mode off; better pass an explicit argument. t
But does it disable evil? Here evil is immediately enabled again (as it should be). Frank
On Fri, Nov 18, 2011 at 11:20, Frank Fischer <[email protected]> wrote:
On Fri, Nov 18, 2011 at 09:47:35AM +0100, Nikolai Weibull wrote:
Running ‹make terminal› works and after saying no to running the tests (running the tests gives the same result) I run the following:
C-x C-f evil-ex.el C-m M-: (revert-buffer t t nil) C-m
resulting in
Toggling evil-local-mode off; better pass an explicit argument. t
But does it disable evil? Here evil is immediately enabled again (as it should be).
Doh. Sorry, that was absolutely stupid of me. I just saw the toggling message and figured that it was off. OK, here’s a way that works: cd evil-git-dir emacs -nw -Q -L . -l evil.el --eval "(evil-mode 1)" C-x C-f a i a <Esc> C-x C-s M-: (revert-buffer t t nil) C-m The buffer a should be in Fundamental mode. You can also use M-x revert-buffer to get the same result. For some reason Evil-Local is restored if you do this for, for example, evil-ex.el, but not for a. I tried the same by creating a buffer called a.rb, which starts in Ruby mode. This gave the same behavior as for evil-ex.el. I’ve had this problem with Ruby files, so it shouldn’t depend on that.
On Fri, Nov 18, 2011 at 12:29:53PM +0100, Nikolai Weibull wrote:
On Fri, Nov 18, 2011 at 11:20, Frank Fischer <[email protected]> wrote:
On Fri, Nov 18, 2011 at 09:47:35AM +0100, Nikolai Weibull wrote:
Running ‹make terminal› works and after saying no to running the tests (running the tests gives the same result) I run the following:
C-x C-f evil-ex.el C-m M-: (revert-buffer t t nil) C-m
resulting in
Toggling evil-local-mode off; better pass an explicit argument. t
But does it disable evil? Here evil is immediately enabled again (as it should be).
Doh. Sorry, that was absolutely stupid of me. I just saw the toggling message and figured that it was off.
OK, here’s a way that works:
cd evil-git-dir emacs -nw -Q -L . -l evil.el --eval "(evil-mode 1)" C-x C-f a i a <Esc> C-x C-s M-: (revert-buffer t t nil) C-m
The buffer a should be in Fundamental mode. You can also use M-x revert-buffer to get the same result.
This explains the problem. Fundamental mode does not run any hooks, therefore evil can't be enabled again. Evil does several tricks in order to ensure that evil is enabled in fundamental-mode buffers when they are created, but functions like revert-buffer are not handled. This is probably not so easy to fix (one could advise revert-buffer, but there may be other functions ...)
For some reason Evil-Local is restored if you do this for, for example, evil-ex.el, but not for a.
I tried the same by creating a buffer called a.rb, which starts in Ruby mode. This gave the same behavior as for evil-ex.el. I’ve had this problem with Ruby files, so it shouldn’t depend on that.
If the buffer is not in fundamental-mode there must be a different problem. Any example for buffers that are not in fundamental-mode? Frank
On Fri, 18 Nov 2011 13:12:47 +0100 Frank Fischer wrote: [...]
This explains the problem. Fundamental mode does not run any hooks, therefore evil can't be enabled again. Evil does several tricks in order to ensure that evil is enabled in fundamental-mode buffers when they are created, but functions like revert-buffer are not handled. This is probably not so easy to fix (one could advise revert-buffer, but there may be other functions ...)
FWIW, I consider this a bug and have reported it some time ago as GNU Emacs bug #9214: http://thread.gmane.org/gmane.emacs.bugs/49753 Maybe if some of you follow up we will at least get a reply from the maintainers. ;-) -- Štěpán
On Fri, Nov 18, 2011 at 13:12, Frank Fischer <[email protected]> wrote:
On Fri, Nov 18, 2011 at 12:29:53PM +0100, Nikolai Weibull wrote:
The buffer a should be in Fundamental mode. You can also use M-x revert-buffer to get the same result.
This explains the problem. Fundamental mode does not run any hooks, therefore evil can't be enabled again. Evil does several tricks in order to ensure that evil is enabled in fundamental-mode buffers when they are created, but functions like revert-buffer are not handled. This is probably not so easy to fix (one could advise revert-buffer, but there may be other functions ...)
I tried the same by creating a buffer called a.rb, which starts in Ruby mode. This gave the same behavior as for evil-ex.el. I’ve had this problem with Ruby files, so it shouldn’t depend on that.
If the buffer is not in fundamental-mode there must be a different problem. Any example for buffers that are not in fundamental-mode?
Not anymore. It seems that it’s now working. I have no explanation other than that I’ve updated Evil since I last tested. Perhaps this resolved itself due to other changes. I’ll report if it happens again.
participants (4)
-
Frank Fischer -
Michael Markert -
Nikolai Weibull -
Štěpán Němec