jed-users mailing list

[2007 Date Index] [2007 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

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

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2007 date index] [2007 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]