all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Auto revert mode but only for git projects
@ 2010-06-06 15:52 Andrea Crotti
  2010-06-07 20:27 ` Andrea Crotti
  0 siblings, 1 reply; 2+ messages in thread
From: Andrea Crotti @ 2010-06-06 15:52 UTC (permalink / raw)
  To: help-gnu-emacs

When using branches with emacs reverting the buffers can be quite
tedious.

But also activating auto-revert-mode everywhere is not such a good idea.

So I thought that I could automatically activate auto-revert-mode BUT
only when
1. I'm in a git repo
2. I have at least 2 branches

What could be the cleaner way to do it?
Textmate.el has already something to look if it's a git repo, then I can
check for more branches with
--8<---------------cut here---------------start------------->8---
git branch | wc -l
--8<---------------cut here---------------end--------------->8---
for example and maybe add a hook in find-file-hooks?

Could that work?




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Auto revert mode but only for git projects
  2010-06-06 15:52 Auto revert mode but only for git projects Andrea Crotti
@ 2010-06-07 20:27 ` Andrea Crotti
  0 siblings, 0 replies; 2+ messages in thread
From: Andrea Crotti @ 2010-06-07 20:27 UTC (permalink / raw)
  To: help-gnu-emacs

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

[...]


I solved with something like this:
--8<---------------cut here---------------start------------->8---
(defun is-git-file ()
    "Return nil unless the file is in the git files"
    (if
        (member (file-name-nondirectory buffer-file-name)
                (split-string  (shell-command-to-string "git ls-files")))
        (auto-revert-mode t)))
  
  (add-hook 'find-file-hook 'is-git-file)
--8<---------------cut here---------------end--------------->8---

It doesn't really make sense to look at branches since for every pull we
could have to revert...
Apparently it's working, if you have some hints/complaints/suggestions
don't hesitate




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-07 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-06 15:52 Auto revert mode but only for git projects Andrea Crotti
2010-06-07 20:27 ` Andrea Crotti

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.