help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: refreshing files quickly


From: Ed L Cashin
Subject: Re: refreshing files quickly
Date: Sat, 26 Apr 2003 15:01:17 -0400
User-agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386-debian-linux-gnu)

Hi.  This post is in response to an October 1998 post, but since I
found that one in deja-news a few years ago, I figured what the hey.

Jacques Duthen <Jacques.Duthen@aigf.sncf.fr> writes:

> Alex Schroeder wrote:
>> > >>>>> "jim" == 142805  <142805@my-dejanews.com> writes:
>> > jim> Is there a command that's quicker than C-x C-f filename "yes"
>> jim> to refresh a file in Emacs that has changed on disk?  I've
>> jim> searched the documentation, but not found one. If not, is
>> jim> there a quick way to tie this command to a keystroke? Thanks.

There's the "M-x revert-buffer RET yes RET" way, as Eli Zaretskii
pointed out back in the original thread, but Jacques Duthen has a
quicker way ...

> I use M-x revt RET
> (the name "revt" came from the minimum letters I had to type
>  with completion to get revert-buffer: "r e v space t RET")
>
> (defun revt ()
>   "Replace the buffer text with the text of the visited file on disk.
> This undoes all changes since the file was visited or saved."
>   (interactive)
>   (revert-buffer 'nil 't))
>
>> If you know it has changed on disk: C-x C-v RET
>> > This works because the default for find-alternate-file is the very
>> file your are visiting.
>
> But you loose the current point!   :-(
>
> If the file did not change so much or if the changes occur
> after the current point, I would prefer to stay in place.

I found that I was still losing the point sometimes in GNU Emacs
21.2.1 on debian woody, so I changed revt to look like below, and now
it's more stable.

(defun revt ()
  "Replace the buffer text with the text of the visited file on disk.
This undoes all changes since the file was visited or saved."
  (interactive)
  (save-excursion
    (revert-buffer 'nil 't)))


-- 
--Ed L Cashin     PGP public key: http://noserose.net/e/pgp/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]