all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Antoine Levitt <antoine.levitt@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Shell commands in deleted directories
Date: Mon, 14 Feb 2011 13:30:07 -0500	[thread overview]
Message-ID: <jwvzkpylbjd.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87d3mvir6d.fsf@gmail.com> (Antoine Levitt's message of "Sun, 13 Feb 2011 22:02:34 +0100")

>      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



      parent reply	other threads:[~2011-02-14 18:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-13 21:02 Shell commands in deleted directories Antoine Levitt
2011-02-13 21:07 ` Paul Eggert
2011-02-13 21:21   ` Antoine Levitt
2011-02-13 21:34     ` Ted Zlatanov
2011-02-13 22:05       ` Antoine Levitt
2011-02-14 15:00         ` Ted Zlatanov
2011-02-13 21:13 ` Eli Zaretskii
2011-02-13 21:16   ` Antoine Levitt
2011-02-14 18:30 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzkpylbjd.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=antoine.levitt@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.