From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r116230: Fix bug #16558 with w32-shell-execute on remote file names. Date: Mon, 03 Feb 2014 07:55:25 +0200 Message-ID: <83txcg3fle.fsf@gnu.org> References: <83ob2q4nbv.fsf@gnu.org> <83k3de41sc.fsf@gnu.org> <83iosx4iid.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1391406948 20997 80.91.229.3 (3 Feb 2014 05:55:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Feb 2014 05:55:48 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 03 06:55:55 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WACVe-0004i0-AR for ged-emacs-devel@m.gmane.org; Mon, 03 Feb 2014 06:55:54 +0100 Original-Received: from localhost ([::1]:44100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WACVe-0006z1-0S for ged-emacs-devel@m.gmane.org; Mon, 03 Feb 2014 00:55:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WACVW-0006yZ-SM for emacs-devel@gnu.org; Mon, 03 Feb 2014 00:55:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WACVP-00079e-GK for emacs-devel@gnu.org; Mon, 03 Feb 2014 00:55:46 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:34804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WACVP-00078n-7R for emacs-devel@gnu.org; Mon, 03 Feb 2014 00:55:39 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0N0E00G00OBPBU00@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Mon, 03 Feb 2014 07:55:37 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N0E00GOQOGO6490@a-mtaout23.012.net.il>; Mon, 03 Feb 2014 07:55:37 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.175 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169358 Archived-At: > From: Stefan Monnier > Cc: emacs-devel@gnu.org > Date: Sun, 02 Feb 2014 21:33:18 -0500 > > > Btw, find-file-name-handler returns nil for file-exists-p when the > > file name specifies a compressed file, so I'm not sure what bothered > > you in the first place. > > Ha! Indeed, I had never noticed that `operations' property! I'm not sure this is an accident. IMO, any file handler that works with local files should do the same. > Then I guess the current code is OK (tho it's still kind of a hack). I prefer "clever engineering solution". > >> And the reason we do that is because some file names are "normal" and > >> others refer to non-files according to some w32 feature which can map > >> them to some other tools. > > The reason is described in the comment: if the file name is not > > absolute and its name is not relative to the directory passed to the > > system API, the API will fail. > > 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. > >> I don't know that w32 feature at all, so it's hard for me to figure out > >> what should be done, but it seems like file-exists-p is not the right > >> thing to do anyway since the file name might be "normal" but refer to > >> a file that doesn't exist yet. > > Yes, that might happen, but then the file will be created in a > > directory other than what the user expects it to, perhaps. > > So it would be a problem, right? Yes; see the comments in the code. But I don't see any good solution to this problem; do you? 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. > 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); > 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, so I think we are covered: Lisp_Object current_dir = BVAR (current_buffer, directory);; > >> So, how does w32 decide whether a file name is "normal" or not? > > We cannot know: it's up to the application that is associated with > > DOCUMENT and OPERATION. > > So we don't actually know if the string we have is really a file name, > and Ffile_exists_p is used to try and guess whether that's the case > (because we need to adjust it somehow if that's the case)? Indeed.