Suggestion for "File not found" dialog

Tim Hubberstey myredirector at gmail.com
Mon Jan 7 21:14:52 CET 2008


On 2008-01-07 08:28, Paterline, David L. wrote:
> Hello all -
> 
> I find this to be a minor irritant which could probably be made better -
> when editing a file which has been deleted from disk externally, NEdit
> pops up the "File not found" dialog, which provides the user options to
> "Re-Save", "Save As", or "Cancel". 
> 
> If you are no longer interested in the file, it would be nice to have an
> option in this dialog to "Close" the file. As it is, you have to select
> "Cancel", and then close the file, whereupon you are prompted to "Save
> ... before closing?". Of course, then you select "No", and the file is
> closed.
> 
> It would be nice if the "File not found" dialog would allow an option to
> "Close" the file immediately.
> 
> Thanks all.

Since I can't imagine that this is a common problem for very many users, 
the obvious solution is to create a macro something like:

------
define save_if_exists {
   if ( $modified )
   {
     # No "File Status" macro command so use the (Bourne) shell to test
     #   if file still exists using "[ -e filename ]"
     shell_command( "[", " -e "$file_path$file_name" ]" )

     if ( $shell_cmd_status == 1 )
     {
       # file no longer exists

       ...ask_what_to_do...

       ...and_then_do_it(probably_one_of)...
       # close( "nosave" )
       # save()
       # save_as( filename )
       # save_as_dialog()
     }
     else
     {
       # Save the current changes to the file
       save()
     }
   }
------

You can fill in the details of what actions you want to take if the file 
doesn't exist. Note that this is UNTESTED so I don't guarantee anything!

If you want to make this transparent, un-bind the Ctrl+S key using your 
.Xdefaults (or whatever it's called on your system) and then bind this 
macro to Ctrl+S.

PS: As a side note to the developers, a macro command to "stat" a file 
would be nice since the shell_command method is slow and not very portable.


More information about the Discuss mailing list