logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: How to reload a buffer: msg#00038

Subject: Re: How to reload a buffer
On 19.04.07, Olesen, Mark wrote:
> On 18.04.07, Jörg Sommer wrote:
 
> > is there a way in (plain) Jed I can reload the contents of the buffer
> > if the file changed on disk? I search something like reload_buffer
> > from bufutils (jed-modes).

AFAIK, there is not. This is why reload_buffer is in bufutils.sl.

Is there something you want to change in the code or do you just want to
skip the dependency on bufutils.


> This is what I use, and find quite helpful:

> % reload if the disk file is newer as buffer
> define reload ()
> {
>     variable file, dir, flags;
>     (file,dir,,flags) = getbuf_info();
>     file = dircat (dir, file);
>     if (flags & 4) {
>       buffer_keystring ("yes\r");     % yes = reload
>       () = find_file (file);
>     }
> }
> setkey("reload",      "^X^R");

> Doing it without simulating keystrokes would be nicer.

you could try 

>     if (flags & 4) {
-       buffer_keystring ("yes\r");     % yes = reload
+       % reset the changed-on-disk flag to prevent asking
+       setbuf_info(file, dir, name, flags & ~0x004);
>       () = find_file (file);
>     }

but maybe this will not load the new version any more :-(
(BTW, the version in http://jedmodes.sf.net/mode/bufutils/ works without
simulating keystrokes.)

Guenter




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>