emacs-devel
[Top][All Lists]
Advanced

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

Re: Shell commands in deleted directories


From: Stefan Monnier
Subject: Re: Shell commands in deleted directories
Date: Mon, 14 Feb 2011 13:30:07 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>      if (NILP (Ffile_accessible_directory_p (current_dir)))
> -      report_file_error ("Setting current directory",
> -                      Fcons (current_buffer->directory, Qnil));
> +      {
> +     /* If current_dir is unreachable (typically, does not exist), use
> +        ~/ as default */
> +     current_dir = build_string ("~/");
> +     current_dir = expand_and_dir_to_file (current_dir, Qnil);
> +     current_dir = Ffile_name_as_directory (current_dir);
> +     if (NILP (Ffile_accessible_directory_p (current_dir)))
> +       {
> +         report_file_error ("Setting current directory to ~/", Qnil);
> +       }
> +      }
 
This is a recurrent problem and the above patch is very tempting, but
it's sadly wrong when the command uses relative file names.  So, the
problem has to be fixed on a case by case basis.  In the case of M-!
there's no way for Emacs to know whether the command will use relative
file names, so signalling an error is the best it can do.

OTOH if ERC runs commands internally, ERC presumably knows whether those
commands care about default-directory, and if they don't, then it can
use ~/ instead.

We should maybe provide some canonical way to fix this problem, tho.
E.g. a new macro `with-existing-default-directory' to wrap the relevant
call(s) to start|call-process.


        Stefan



reply via email to

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