git-gutter
git-gutter copied to clipboard
not always refreshing when commiting outside of emacs?
I'm not using (yet?) magit for committing, but rather commiting in a terminal outside of emacs. As a result, git-gutter still reflects the status of before the commit, does not pick up the change.
I have added this to my emacs config and was sure it would help, but it does not: (require 'git-gutter) (add-to-list 'git-gutter:update-hooks 'focus-in-hook)
Also when git-gutter is displaying obsolete information, running "git-gutter:update-all-windows" still does not get rid of the obsolete information.
I'm pretty sure I misconfigured something... I'm using spacemacs otherwise, and I put the focus-in-hook thing in the:
(defun dotspacemacs/config () "Configuration function. This function is called at the very end of Spacemacs initialization after layers configuration."
Would you tell me your Emacs version and OS ?
focus-in-hook
was introduced at Emacs 24.4. And it works only on GUI Emacs.
I know focus hooks works on Linux however I don't know whether it works on other platforms(MacOSX, Windows etc).
I have GNU Emacs 24.4.1, linux (fedora). I only use emacs in the GUI. As I said I use it through the spacemacs bundle though.
On Mon, Apr 6, 2015 at 3:13 PM, Syohei YOSHIDA [email protected] wrote:
Would you tell me your Emacs version and OS ? focus-in-hook was introduced at Emacs 24.4. And it works only on GUI Emacs.
I know focus hooks works on Linux however I don't know whether it works on other platforms(MacOSX, Windows etc).
— Reply to this email directly or view it on GitHub https://github.com/syohex/emacs-git-gutter/issues/86#issuecomment-90059399 .
I've added this to my init function:
(add-hook 'focus-in-hook (lambda () (message "hello")))
and hello is displayed on focus. So I think that's not the problem.
Thanks for information. Would you tell me how to reproduce this issue ? Which git command did you use ?
It's a simple of having a clean repo, modifying the file, comitting outside of emacs, and the status doesn't update in emacs. In fact I even tried to call manually git-gutter:update-all-windows (M-x git-gutter:update-all-windows ENTER) but also that did not help. The status in git-gutter remained obsolete.
I tried to reproduce it with a sample project but this time it works. All I can say is that in some cases it doesn't...
Maybe you can tell me what to try doing the next time I hit the issue so that I try to narrow the source of the problem?
Maybe you can tell me what to try doing the next time I hit the issue so that I try to narrow the source of the problem?
I have no idea now.
I cannot reproduce this issue.
Can I get such a repository which makes this issue ?
It's not with the repository, restarting emacs solves the problem. It's also not everytime.
I'll probably add debug messages and look at them when i reproduce..
On 7 Apr 2015 16:53, "Syohei YOSHIDA" [email protected] wrote:
Maybe you can tell me what to try doing the next time I hit the issue so that I try to narrow the source of the problem?
I have no idea now.
I cannot reproduce this issue.
Can I get such a repository which makes this issue ?
— Reply to this email directly or view it on GitHub.
I just reproduced the issue just putting videos in case it helps somehow. As i said, manually calling the function to update the status does not help. Killing emacs and restarting it does help. I wonder if there's maybe a connection with the fact that I use emacs-client.
Anyway, videos: https://dl.dropboxusercontent.com/u/22600720/gitgutter1.webm https://dl.dropboxusercontent.com/u/22600720/gitgutter2.webm
PS: I'm not trying to reproduce the problem, just using git-gutter while working on other projects for now. If still no solution arise I'll guess I'll start looking at the git-gutter source but I didn't come around to doing that yet.
it's possible that i have this problem only when using emacs-client. not sure yet, just a theory.
it's possible that i have this problem only when using emacs-client.
Thanks for information.
Same here. Reproducible almost on every commit. Running M-x git-gutter refreshes the buffer correctly.
I am using linum-mode, actually linum-relative along with git-gutter-fringe. The update-interval seems to have no effect:
(global-git-gutter-mode t) (custom-set-variables '(git-gutter:update-interval 2))
Please, if you need further information, just ask.
just FYI I was using emacs-git-gutter
because it's the default one in spacemacs
. Now spacemacs swtiched to diff-hl
and there the feature works as expected for me.
partial solution for current version of magit: http://stackoverflow.com/a/32296023/321365
Edited: Fixed it with the code below in my init file: Notice: It may have side effects.
Solution1:
;; Update all window when Emacs focus in.
;; This fixes git gutter cannot update the file status after committing outside of Emacs.
(add-hook 'focus-in-hook 'git-gutter:update-all-windows)
Solution2:
;; Revert buffer without confirm when buffer focus in.
;; This fixes git gutter cannot update the file status after committing outside of Emacs.
(add-hook 'focus-in-hook 'revert-buffer-no-confirm)
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive) (revert-buffer t t))
Confirmed on MacOS 11.0 Beta (20A4300b)

The correct status is showed after running M-x revert-buffer