jed-users mailing list

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

Re: Read only files.


Thanks for the reply Joerg,

On 31 ao{t 05, at 21:09, Joerg Sommer wrote:

Hello Misha,

Misha Gorodnitzky <misaka@xxxxxxxxx> wrote:

Hello all,

Apologies if this is covered already somewhere, I was unable to find
it if so.

I noticed that when editing a file owned by root that has read-only
permissions only, mode 0444, jed doesn't seem to emit a warning or
any kind of signal to indicate this. Is there a way to get jed to
signal when I'm editing a file like this?

If not, I propose that this would be useful addition.


You can use the _jed_save_buffer_before_hooks to raise a question if
saving the file should really take place.

#v+
define ask_before_save(file)
{
    variable stat = stat_file( file );
    if ( andelse {stat != NULL} {stat.st_mode & 0222 == 0}
           {system("test $(id --user) -eq 0") == 0} )
       error("You try to save a readonly file as root");
}
#v-

I couldn't quite get this to work.

I'm a s-lang neophyte, but I did manage to get this function attached to _jed_save_buffer_before_hooks using append_to_hook, as evidenced by some flush() calls I inserted for testing. However the error never gets displayed and, after further testing, it looks like the statement "stat.st_mode & 0222 == 0" never evaluates to true, although I haven't really been able to look at it in detail. Any thoughts? Were you able to make this work for yourself?

Also, I thought it might be useful to emit a warning on loading a file that is read-only, what is the hook for that? It might even be good to force the file to be uneditable inside of jed, if that's possible.


--M





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


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