all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* reload modified files in buffer
@ 2010-12-14  6:55 Rajinder Yadav
  2010-12-14  7:57 ` suvayu ali
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Rajinder Yadav @ 2010-12-14  6:55 UTC (permalink / raw
  To: emacs-help

How can I get emacs to automatically reload files in its buffer that 
have been modified externally?

When editing a rails app, if I run a rails generate command, I don't 
want to have to reload a file manually. Sometimes I start to edit a file 
that is out of sync in the buffer and then get into a mess. I would like 
this to happen transparently.

-- 
Kind Regards,
Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-23-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.3



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

* Re: reload modified files in buffer
       [not found] <mailman.1.1292309755.5276.help-gnu-emacs@gnu.org>
@ 2010-12-14  7:12 ` Sven Joachim
  2010-12-15 15:42   ` Peter Dyballa
       [not found]   ` <mailman.9.1292427789.4561.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 16+ messages in thread
From: Sven Joachim @ 2010-12-14  7:12 UTC (permalink / raw
  To: help-gnu-emacs

On 2010-12-14 07:55 +0100, Rajinder Yadav wrote:

> How can I get emacs to automatically reload files in its buffer that
> have been modified externally?

Use global-auto-revert-mode.

> When editing a rails app, if I run a rails generate command, I don't
> want to have to reload a file manually. Sometimes I start to edit a
> file that is out of sync in the buffer and then get into a mess.

Doesn't Emacs warn you when you do this?

Sven 


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

* Re: reload modified files in buffer
  2010-12-14  6:55 reload modified files in buffer Rajinder Yadav
@ 2010-12-14  7:57 ` suvayu ali
  2010-12-14  9:28 ` Deniz Dogan
  2010-12-14 15:19 ` Andrea Crotti
  2 siblings, 0 replies; 16+ messages in thread
From: suvayu ali @ 2010-12-14  7:57 UTC (permalink / raw
  To: Rajinder Yadav; +Cc: emacs-help

On Tue, Dec 14, 2010 at 7:55 AM, Rajinder Yadav <devguy.ca@gmail.com> wrote:
> How can I get emacs to automatically reload files in its buffer that have
> been modified externally?
>
> When editing a rails app, if I run a rails generate command, I don't want to
> have to reload a file manually. Sometimes I start to edit a file that is out
> of sync in the buffer and then get into a mess. I would like this to happen
> transparently.
>

`M-x auto-revert-mode'

-- 
Suvayu

Open source is the future. It sets us free.



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

* Re: reload modified files in buffer
  2010-12-14  6:55 reload modified files in buffer Rajinder Yadav
  2010-12-14  7:57 ` suvayu ali
@ 2010-12-14  9:28 ` Deniz Dogan
  2010-12-14 15:19 ` Andrea Crotti
  2 siblings, 0 replies; 16+ messages in thread
From: Deniz Dogan @ 2010-12-14  9:28 UTC (permalink / raw
  To: Rajinder Yadav; +Cc: emacs-help

2010/12/14 Rajinder Yadav <devguy.ca@gmail.com>:
> How can I get emacs to automatically reload files in its buffer that have
> been modified externally?
>
> When editing a rails app, if I run a rails generate command, I don't want to
> have to reload a file manually. Sometimes I start to edit a file that is out
> of sync in the buffer and then get into a mess. I would like this to happen
> transparently.
>

If the buffer file has been modified, Emacs should warn you about
modifying it before it lets you. What version of Emacs are you using?

-- 
Deniz Dogan



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

* Re: reload modified files in buffer
  2010-12-14  6:55 reload modified files in buffer Rajinder Yadav
  2010-12-14  7:57 ` suvayu ali
  2010-12-14  9:28 ` Deniz Dogan
@ 2010-12-14 15:19 ` Andrea Crotti
  2010-12-15 15:43   ` suvayu ali
  2 siblings, 1 reply; 16+ messages in thread
From: Andrea Crotti @ 2010-12-14 15:19 UTC (permalink / raw
  To: help-gnu-emacs

Rajinder Yadav <devguy.ca@gmail.com> writes:

> How can I get emacs to automatically reload files in its buffer that
> have been modified externally?
>
> When editing a rails app, if I run a rails generate command, I don't
> want to have to reload a file manually. Sometimes I start to edit a
> file that is out of sync in the buffer and then get into a mess. I
> would like this to happen transparently.

I use 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---

to set files in auto-revert mode if they're part of a git repository.
Maybe you can adapt something like this to your needs.
Having everything in auto-revert mode might slow down too much...




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

* Re: reload modified files in buffer
  2010-12-14  7:12 ` Sven Joachim
@ 2010-12-15 15:42   ` Peter Dyballa
  2010-12-15 19:14     ` Andrea Crotti
       [not found]   ` <mailman.9.1292427789.4561.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 16+ messages in thread
From: Peter Dyballa @ 2010-12-15 15:42 UTC (permalink / raw
  To: Sven Joachim; +Cc: help-gnu-emacs


Am 14.12.2010 um 08:12 schrieb Sven Joachim:

>> When editing a rails app, if I run a rails generate command, I don't
>> want to have to reload a file manually. Sometimes I start to edit a
>> file that is out of sync in the buffer and then get into a mess.
>
> Doesn't Emacs warn you when you do this?


It does! But wouldn't it be better GNU Emacs would reload the file  
instead of warning/asking things?

--
Mit friedvollen Grüßen

   Pete

Es macht schon Spaß, Leute zu hassen: Nie gehen die Ideen aus!




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

* Re: reload modified files in buffer
  2010-12-14 15:19 ` Andrea Crotti
@ 2010-12-15 15:43   ` suvayu ali
  2010-12-15 16:58     ` Andrea Crotti
  0 siblings, 1 reply; 16+ messages in thread
From: suvayu ali @ 2010-12-15 15:43 UTC (permalink / raw
  To: Andrea Crotti; +Cc: help-gnu-emacs

Hi Andrea,

On Tue, Dec 14, 2010 at 7:19 AM, Andrea Crotti
<andrea.crotti.0@gmail.com> wrote:
>
> I use 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---
>
> to set files in auto-revert mode if they're part of a git repository.
> Maybe you can adapt something like this to your needs.
> Having everything in auto-revert mode might slow down too much...

Any particular reason to write your own function? I simply use this,

(lambda ()
	  (if (vc-working-revision (buffer-file-name))
		(auto-revert-mode t)))

--
Suvayu

Open source is the future. It sets us free.



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

* Re: reload modified files in buffer
       [not found]   ` <mailman.9.1292427789.4561.help-gnu-emacs@gnu.org>
@ 2010-12-15 16:04     ` Sven Joachim
  0 siblings, 0 replies; 16+ messages in thread
From: Sven Joachim @ 2010-12-15 16:04 UTC (permalink / raw
  To: help-gnu-emacs

On 2010-12-15 16:42 +0100, Peter Dyballa wrote:

> Am 14.12.2010 um 08:12 schrieb Sven Joachim:
>
>>> When editing a rails app, if I run a rails generate command, I don't
>>> want to have to reload a file manually. Sometimes I start to edit a
>>> file that is out of sync in the buffer and then get into a mess.
>>
>> Doesn't Emacs warn you when you do this?
>
>
> It does! But wouldn't it be better GNU Emacs would reload the file
> instead of warning/asking things?

I would not appreciate if Emacs did that without asking first.  And
reverting the buffer (= reloading the file) is among the offered options
in such a situation.

Cheers,
       Sven


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

* Re: reload modified files in buffer
  2010-12-15 15:43   ` suvayu ali
@ 2010-12-15 16:58     ` Andrea Crotti
  0 siblings, 0 replies; 16+ messages in thread
From: Andrea Crotti @ 2010-12-15 16:58 UTC (permalink / raw
  To: help-gnu-emacs

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> Any particular reason to write your own function? I simply use this,
>
> (lambda ()
> 	  (if (vc-working-revision (buffer-file-name))
> 		(auto-revert-mode t)))
>
> --
> Suvayu
>
> Open source is the future. It sets us free.

One very good reason, I didn't know about it :D
I also looked for something like that but then I gave up, thanks it's
much more general like this...




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

* Re: reload modified files in buffer
  2010-12-15 15:42   ` Peter Dyballa
@ 2010-12-15 19:14     ` Andrea Crotti
  2010-12-15 19:26       ` Peter Dyballa
  2010-12-16  0:39       ` suvayu ali
  0 siblings, 2 replies; 16+ messages in thread
From: Andrea Crotti @ 2010-12-15 19:14 UTC (permalink / raw
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

>
> It does! But wouldn't it be better GNU Emacs would reload the file
> instead of warning/asking things?
>
> --
> Mit friedvollen Grüßen
>
>   Pete
>
> Es macht schon Spaß, Leute zu hassen: Nie gehen die Ideen aus!

not correct, what if you modified that file?
You would lose your modification without even knowing, not a very good idea...




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

* Re: reload modified files in buffer
  2010-12-15 19:14     ` Andrea Crotti
@ 2010-12-15 19:26       ` Peter Dyballa
  2010-12-16  0:39       ` suvayu ali
  1 sibling, 0 replies; 16+ messages in thread
From: Peter Dyballa @ 2010-12-15 19:26 UTC (permalink / raw
  To: Andrea Crotti; +Cc: help-gnu-emacs


Am 15.12.2010 um 20:14 schrieb Andrea Crotti:

> not correct, what if you modified that file?


Then it would ask whether to use diff-mode to see the differences I  
made to the previous version and that to the new version.

--
Greetings

   Pete

Only useless documentation transcends the first two laws.
				– Arnold's Third Law of Documentation




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

* Re: reload modified files in buffer
  2010-12-15 19:14     ` Andrea Crotti
  2010-12-15 19:26       ` Peter Dyballa
@ 2010-12-16  0:39       ` suvayu ali
  2010-12-16 11:42         ` Rajinder Yadav
  1 sibling, 1 reply; 16+ messages in thread
From: suvayu ali @ 2010-12-16  0:39 UTC (permalink / raw
  To: Andrea Crotti; +Cc: help-gnu-emacs

On Wed, Dec 15, 2010 at 11:14 AM, Andrea Crotti
<andrea.crotti.0@gmail.com> wrote:
> Peter Dyballa <Peter_Dyballa@Web.DE> writes:
>
>>
>> It does! But wouldn't it be better GNU Emacs would reload the file
>> instead of warning/asking things?
>>
>
> not correct, what if you modified that file?
> You would lose your modification without even knowing, not a very good idea...
>

I think auto-revert-mode doesn't revert the buffer either if it has
been modified. I think that is a good thing, but then tastes may vary.
:)

-- 
Suvayu

Open source is the future. It sets us free.



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

* Re: reload modified files in buffer
  2010-12-16  0:39       ` suvayu ali
@ 2010-12-16 11:42         ` Rajinder Yadav
  2010-12-16 16:32           ` PJ Weisberg
                             ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Rajinder Yadav @ 2010-12-16 11:42 UTC (permalink / raw
  To: help-gnu-emacs

On 10-12-15 07:39 PM, suvayu ali wrote:
> On Wed, Dec 15, 2010 at 11:14 AM, Andrea Crotti
> <andrea.crotti.0@gmail.com>  wrote:
>> Peter Dyballa<Peter_Dyballa@Web.DE>  writes:
>>
>>>
>>> It does! But wouldn't it be better GNU Emacs would reload the file
>>> instead of warning/asking things?
>>>
>>
>> not correct, what if you modified that file?
>> You would lose your modification without even knowing, not a very good idea...
>>
>
> I think auto-revert-mode doesn't revert the buffer either if it has
> been modified. I think that is a good thing, but then tastes may vary.
> :)
>

it's good to know that auto-revert mode will not revert a modify buffer. 
however afaik Emacs will not let you save a modified buffer if the file 
has changed.

i like Peter's idea of Emacs having the ability to diff-merge a conflict 
when you've modified a buffer and the file has changed.

Emacs should be smart enough to auto-reload a buffer if the file has 
changed and the buffer has not been edited, this would be a welcomed 
enhancement =)

-- 
Kind Regards,
Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-23-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.3



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

* Re: reload modified files in buffer
  2010-12-16 11:42         ` Rajinder Yadav
@ 2010-12-16 16:32           ` PJ Weisberg
  2010-12-16 18:08           ` suvayu ali
  2010-12-17 23:09           ` Andrea Crotti
  2 siblings, 0 replies; 16+ messages in thread
From: PJ Weisberg @ 2010-12-16 16:32 UTC (permalink / raw
  To: help-gnu-emacs

On Thu, Dec 16, 2010 at 3:42 AM, Rajinder Yadav <devguy.ca@gmail.com> wrote:

> Emacs should be smart enough to auto-reload a buffer if the file has changed
> and the buffer has not been edited, this would be a welcomed enhancement =)

This would be annoying (to me) if it weren't off by default.  Of
course, I could turn it off by default in my .emacs.  But my point is,
you can enable this (and have it saved in your .emacs) by doing:

M-x customize-save-variable
global-auto-revert-mode
y

-PJ



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

* Re: reload modified files in buffer
  2010-12-16 11:42         ` Rajinder Yadav
  2010-12-16 16:32           ` PJ Weisberg
@ 2010-12-16 18:08           ` suvayu ali
  2010-12-17 23:09           ` Andrea Crotti
  2 siblings, 0 replies; 16+ messages in thread
From: suvayu ali @ 2010-12-16 18:08 UTC (permalink / raw
  To: Rajinder Yadav; +Cc: help-gnu-emacs

On Thu, Dec 16, 2010 at 3:42 AM, Rajinder Yadav <devguy.ca@gmail.com> wrote:
> Emacs should be smart enough to auto-reload a buffer if the file has changed
> and the buffer has not been edited, this would be a welcomed enhancement =)

It is, that is what auto-revert-mode does. But it is for the user to
turn on. I am a firm believer of each user customising there setup as
per their needs. Features should not be forced on anyone. If you have
a preference then customise. Emacs even has the wonderful "customize"
interface to help you with everything.

-- 
Suvayu

Open source is the future. It sets us free.



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

* Re: reload modified files in buffer
  2010-12-16 11:42         ` Rajinder Yadav
  2010-12-16 16:32           ` PJ Weisberg
  2010-12-16 18:08           ` suvayu ali
@ 2010-12-17 23:09           ` Andrea Crotti
  2 siblings, 0 replies; 16+ messages in thread
From: Andrea Crotti @ 2010-12-17 23:09 UTC (permalink / raw
  To: help-gnu-emacs

Rajinder Yadav <devguy.ca@gmail.com> writes:
>
> it's good to know that auto-revert mode will not revert a modify
> buffer. however afaik Emacs will not let you save a modified buffer if
> the file has changed.
>
> i like Peter's idea of Emacs having the ability to diff-merge a
> conflict when you've modified a buffer and the file has changed.
>
> Emacs should be smart enough to auto-reload a buffer if the file has
> changed and the buffer has not been edited, this would be a welcomed
> enhancement =)

Try to enable globally auto-revert-mode and keep 200 buffers open on a
slow machine, you'll understand why is not a default ;)

I think is a good idea to be off by default, after all why do you need
to revert buffers so often?

For me it only happens when I push/pull with some revision control
systems...




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

end of thread, other threads:[~2010-12-17 23:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14  6:55 reload modified files in buffer Rajinder Yadav
2010-12-14  7:57 ` suvayu ali
2010-12-14  9:28 ` Deniz Dogan
2010-12-14 15:19 ` Andrea Crotti
2010-12-15 15:43   ` suvayu ali
2010-12-15 16:58     ` Andrea Crotti
     [not found] <mailman.1.1292309755.5276.help-gnu-emacs@gnu.org>
2010-12-14  7:12 ` Sven Joachim
2010-12-15 15:42   ` Peter Dyballa
2010-12-15 19:14     ` Andrea Crotti
2010-12-15 19:26       ` Peter Dyballa
2010-12-16  0:39       ` suvayu ali
2010-12-16 11:42         ` Rajinder Yadav
2010-12-16 16:32           ` PJ Weisberg
2010-12-16 18:08           ` suvayu ali
2010-12-17 23:09           ` Andrea Crotti
     [not found]   ` <mailman.9.1292427789.4561.help-gnu-emacs@gnu.org>
2010-12-15 16:04     ` Sven Joachim

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.