From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier 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 09:06:33 -0500 Message-ID: References: <83ob2q4nbv.fsf@gnu.org> <83k3de41sc.fsf@gnu.org> <83iosx4iid.fsf@gnu.org> <83txcg3fle.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1391436413 26335 80.91.229.3 (3 Feb 2014 14:06:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Feb 2014 14:06:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 03 15:07:00 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 1WAKAu-0008Pn-0j for ged-emacs-devel@m.gmane.org; Mon, 03 Feb 2014 15:07:00 +0100 Original-Received: from localhost ([::1]:47316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAKAt-00042x-Gg for ged-emacs-devel@m.gmane.org; Mon, 03 Feb 2014 09:06:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAKAj-00041n-GW for emacs-devel@gnu.org; Mon, 03 Feb 2014 09:06:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAKAc-0007IH-7P for emacs-devel@gnu.org; Mon, 03 Feb 2014 09:06:49 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:61291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAKAU-0007GN-E1; Mon, 03 Feb 2014 09:06:34 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpYzZ/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IPAS-Result: Av8EABK/CFFFpYzZ/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="46657634" Original-Received: from 69-165-140-217.dsl.teksavvy.com (HELO pastel.home) ([69.165.140.217]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 03 Feb 2014 09:06:33 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 152C060556; Mon, 3 Feb 2014 09:06:33 -0500 (EST) In-Reply-To: <83txcg3fle.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 03 Feb 2014 07:55:25 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:169365 Archived-At: >> 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