tags:

views:

258

answers:

1

I have written a small function in Emacs that does a

git stash
git stash apply

in the Git repository of the file I visit, and I have added this function in after-save-hook so it runs every time I save the file. The problem is that when I save the file, the git commands above run and change the timestamp, so Emacs thinks that the file has been modified outside Emacs itself. Naturally, when I try to edit the file again (without closing and re-opening) Emacs asks if I want to really edit the buffer which is quite annoying.

Any ideas on how to make Emacs not think that the file has been changed as a result of the above git commands?

EDIT: Thanks jvasak. Adding (revert-buffer nil t t) at the end of my function did the trick.

+3  A: 

I don't know for sure that this would work, but you could add revert-buffer to your after-save-hook which should reload the file from disk. Combined with the revert-without-query trick from the GNU Emacs Manual, this may provide the desired behavior.

jvasak