unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r116230: Fix bug #16558 with	w32-shell-execute on remote file names.
Date: Mon, 03 Feb 2014 09:06:33 -0500	[thread overview]
Message-ID: <jwvwqhcqp8o.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <83txcg3fle.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 03 Feb 2014 07:55:25 +0200")

>> I'm having trouble understanding the above: can you give an example of
>> a file which is neither absolute nor relative to the directory passed
>> to the system API?
> I think it happened to me with shr.el, since it doesn't set the
> current directory of the buffer where it renders an HTML document.

Sounds like a bug in the code that extracts the name from the buffer and
passes it to w32-shell-execute, or in the code that (fails to) set the
buffer's default-directory.
IOW the same would happen under GNU/Linux passing that file to call-process.

Or is there something different going on?

> In any case, this is not worse than what happened before the change
> that introduced the call to expand-file-name: then, the ShellExecute
> API was always called with a file name as passed to w32-shell-execute.

I guess the question for me now is "why call Fexpand_file_name"?
I see it was introduced in:

  timestamp: Tue 2013-12-24 19:21:06 +0200
  message:
    Minor fixes in w32-shell-execute.
  
     src/w32fns.c (Fw32_shell_execute): Ensure DOCUMENT is an absolute
     file name when it is submitted to ShellExecute.  Simplify code.
     Don't test DOCUMENT for being a string, as that is enforced by
     CHECK_STRING.  Doc fix.

But I don't know which problem it was trying to solve.

>> Maybe instead of Ffile_exists_p a better option is to use a w32 system
>> call along the lines of faccess or stat (after all, this presumed file
>> name will be passed to the OS rather than to Emacs functions, so it
>> shouldn't pay attention to file-name-handlers and things like that,
>> right?).

> That's exactly what the current code does:

>   handler = Ffind_file_name_handler (absdoc, Qfile_exists_p);
>   if (NILP (handler))
>     {
>       Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc);

>       if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0)
> 	document = absdoc_encoded;
>       else
> 	document = ENCODE_FILE (document);
>     }
>   else
>     document = ENCODE_FILE (document);

Not "exactly"; my suggestion was to use only:

      Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc);
      if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0)
	document = absdoc_encoded;
      else
	document = ENCODE_FILE (document);

Another potential tweak: we could check file-name-absolute-p before
going through the trouble of trying to figure out whether to pass the
file name to expand-file-name and/or file-exists-p (that would
also have solved the url-handler-mode issue of the OP).

>> And to deal with "not yet created files" we shouldn't check the file
>> itself but its directory.
> Its directory is just the default-directory of the current buffer,

No, the directory of "toto/titi/bar" is not default-directory.


        Stefan



  reply	other threads:[~2014-02-03 14:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1W9Wnn-0004N6-IY@vcs.savannah.gnu.org>
2014-02-01 19:26 ` [Emacs-diffs] trunk r116230: Fix bug #16558 with w32-shell-execute on remote file names Stefan Monnier
2014-02-01 19:58   ` Eli Zaretskii
2014-02-02  0:44     ` Stefan Monnier
2014-02-02  3:43       ` Eli Zaretskii
2014-02-02 15:06         ` Stefan Monnier
2014-02-02 15:54           ` Eli Zaretskii
2014-02-03  2:33             ` Stefan Monnier
2014-02-03  4:12               ` David Kastrup
2014-02-03  5:57                 ` Eli Zaretskii
2014-02-03  5:55               ` Eli Zaretskii
2014-02-03 14:06                 ` Stefan Monnier [this message]
2014-02-03 16:17                   ` Eli Zaretskii
2014-02-04  3:39                     ` Stefan Monnier
2014-02-04 16:31                       ` Eli Zaretskii
2014-02-04 20:35                         ` Stefan Monnier
2014-02-04 21:01                           ` Eli Zaretskii
2014-02-05  2:38                             ` Stefan Monnier
2014-02-05  3:56                               ` Eli Zaretskii
2014-02-05 14:10                                 ` Stefan Monnier
2014-02-05 16:07                                   ` Eli Zaretskii
2014-02-05 19:09                                     ` Stefan Monnier
2014-02-05 19:56                                       ` Eli Zaretskii
2014-02-05 21:53                                         ` Stefan Monnier
2014-02-06 11:47                                           ` Eli Zaretskii
2014-02-02  7:45       ` Stefan-W. Hahn
2014-02-05 17:21 grischka
2014-02-05 17:29 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvwqhcqp8o.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=eliz@gnu.org \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).