From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 21 11:47:59 2014 Received: (at submit) by debbugs.gnu.org; 21 Nov 2014 16:47:59 +0000 Received: from localhost ([127.0.0.1]:41074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrrNG-0007xg-NY for submit@debbugs.gnu.org; Fri, 21 Nov 2014 11:47:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45487) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XrmQ9-0007QV-Em for submit@debbugs.gnu.org; Fri, 21 Nov 2014 06:30:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrmQ1-0002r4-06 for submit@debbugs.gnu.org; Fri, 21 Nov 2014 06:30:37 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=AC_HTML_NONSENSE_TAGS, BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrmQ0-0002qx-L3 for submit@debbugs.gnu.org; Fri, 21 Nov 2014 06:30:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrmPt-0001l7-DC for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 06:30:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrmPm-0002h5-LE for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 06:30:21 -0500 Received: from mailout01.t-online.de ([194.25.134.80]:39198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrmPm-0002gj-BY for bug-gnu-emacs@gnu.org; Fri, 21 Nov 2014 06:30:14 -0500 Received: from fwd05.aul.t-online.de (fwd05.aul.t-online.de [172.20.27.149]) by mailout01.t-online.de (Postfix) with SMTP id E2EE315F9E1 for ; Fri, 21 Nov 2014 12:30:12 +0100 (CET) Received: from linux-4qrv.site (SmVEc6ZZghgrKh4kGeU25SZj8vn278nS+ZduRDpYxnhozRya2hWBfqgZ2fRLjYRwlz@[87.171.254.16]) by fwd05.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1XrmPj-4GLDvc0; Fri, 21 Nov 2014 12:30:11 +0100 From: AW To: bug-gnu-emacs@gnu.org Subject: Emacs 24.4: ShellExecute fails in one case under Windows 7 Date: Fri, 21 Nov 2014 12:30:10 +0100 Message-ID: <11076914.28ELNyjCxI@linux-4qrv.site> User-Agent: KMail/4.14.2 (Linux/3.17.3-1.g76fe48f-desktop; KDE/4.14.2; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-ID: SmVEc6ZZghgrKh4kGeU25SZj8vn278nS+ZduRDpYxnhozRya2hWBfqgZ2fRLjYRwlz X-TOI-MSGID: f44ba689-869c-40ba-b755-064169229982 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 21 Nov 2014 11:47:57 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Windows 7, Emacs 24.4 from GNU, cmd.exe, `emacs -Q` I opened this file in Emacs from a local HDD "shell-bug.org": ============================ #+LINK: foo //SBS2011/Emacs/%s #+LINK: fuu C:/texlive/%s #+LINK: faa u:/Emacs/%s * A Heading This is an orgmode file. Such files can contain links. We have to make a difference between links to files, which can be opened by Emacs and files, which have to be opened with a browser or a pdf viewer. What works: [[fuu:baz.pdf]] - a link to a local file, which has to be opened in a pdf viewer, using an abbrevation for the path. [[faa:baz.pdf]] -- a link to a file on the server (SBS 2011), using an abbrevation for the path. [[file://SBS2011/Emacs/baz.tex]] -- a link to a file on the server, using a share name, but no abbrevation for the path. [[foo:baz.tex]] -- a link to a file on the server, using an abbrevation for the share name and the path, but the file will be opened in Emacs. WHAT DOESN'T WORK: [[foo:baz.pdf]] -- a link to a file on the server, using an abbrevation for the share name and the path, but the file will be opened in a PDF viewer. [[foo:baz.html]] -- same case, but html file, which should be opened with firefox. =========================== If I put the cursor on one of the links below the line "WHAT DOESN'T WORK" and try to open it (C-c C-l), I expect that Emacs opens the file with -- depending on the file type -- a pdf viewer or a browser. But I get an error message, see below ("ShellExecute failed:...") => file can not be found. This used to work with Emacs 24.3. The share //SBS2011/Emacs and U:/Emacs are the same folder on the server. tl;dr: ShellExecute fails, if 1. the path uses an abbrevation for the file name + 2. the abbrevation contains a share name + 3. the file has to be opened with an external software This used to work under Emacs 24.3 In GNU Emacs 24.4.1 (i686-pc-mingw32) of 2014-10-24 on LEG570 Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --prefix=/c/usr' Important settings: value of $LANG: de_DE locale-coding-system: cp1252 Major mode: Org Minor modes in effect: tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-x C-f D : d a t e n t e m p 1 4 1 1 2 1 C-c C-o M-x r e p o r t - e m Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. eval: ShellExecute failed: Das System kann die angegebene Datei nicht finden. Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils thingatpt org-element org-rmail org-mhe org-irc org-info org-gnus gnus-util org-docview doc-view jka-compr image-mode dired cl-loaddefs cl-lib org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote org-pcomplete pcomplete org-list org-faces org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint comint ansi-color ring ob-core ob-eval org-compat org-macs org-loaddefs format-spec find-func cal-menu easymenu calendar cal-loaddefs time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process w32notify w32 multi-tty emacs) Memory information: ((conses 8 135446 6349) (symbols 32 24687 0) (miscs 32 63 142) (strings 16 35100 4842) (string-bytes 1 1048213) (vectors 8 16852) (vector-slots 4 461363 5804) (floats 8 99 340) (intervals 28 302 37) (buffers 508 12)) From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 25 12:12:16 2014 Received: (at 19141-done) by debbugs.gnu.org; 25 Nov 2014 17:12:17 +0000 Received: from localhost ([127.0.0.1]:45177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtJey-0000xZ-8s for submit@debbugs.gnu.org; Tue, 25 Nov 2014 12:12:16 -0500 Received: from mtaout28.012.net.il ([80.179.55.184]:43829) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtJev-0000xP-Lq for 19141-done@debbugs.gnu.org; Tue, 25 Nov 2014 12:12:14 -0500 Received: from conversion-daemon.mtaout28.012.net.il by mtaout28.012.net.il (HyperSendmail v2007.08) id <0NFL00300UAN8O00@mtaout28.012.net.il> for 19141-done@debbugs.gnu.org; Tue, 25 Nov 2014 19:09:41 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout28.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NFL00KBOUC5EV70@mtaout28.012.net.il>; Tue, 25 Nov 2014 19:09:41 +0200 (IST) Date: Tue, 25 Nov 2014 19:12:25 +0200 From: Eli Zaretskii Subject: Re: bug#19141: Emacs 24.4: ShellExecute fails in one case under Windows 7 In-reply-to: <11076914.28ELNyjCxI@linux-4qrv.site> X-012-Sender: halo1@inter.net.il To: AW , Bastien Guerry Message-id: <83h9xnp5l2.fsf@gnu.org> References: <11076914.28ELNyjCxI@linux-4qrv.site> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 19141-done Cc: 19141-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Adding Bastien to the addressees, as this is at least somewhat related to Org and its maintenance procedures. > From: AW > Date: Fri, 21 Nov 2014 12:30:10 +0100 > > What works: > > [[fuu:baz.pdf]] - a link to a local file, which has to be opened in a pdf > viewer, using an abbrevation for the path. > > [[faa:baz.pdf]] -- a link to a file on the server (SBS 2011), using an > abbrevation for the path. > > [[file://SBS2011/Emacs/baz.tex]] -- a link to a file on the server, using > a share name, but no abbrevation for the path. > > [[foo:baz.tex]] -- a link to a file on the server, using an abbrevation > for the share name and the path, but the file will be opened in Emacs. > > > WHAT DOESN'T WORK: > > [[foo:baz.pdf]] -- a link to a file on the server, using an abbrevation > for the share name and the path, but the file will be opened in a PDF > viewer. > > [[foo:baz.html]] -- same case, but html file, which should be opened with > firefox. Actually, in my testing "file://SBS2011/Emacs/baz.tex" didn't work, either. (I tried with a .html file, perhaps that made the difference for some reason. E.g., perhaps *.tex files are served by Emacs in your setup, or anyway by some program whose invocation doesn't go through w32-shell-execute.) > If I put the cursor on one of the links below the line "WHAT DOESN'T > WORK" and try to open it (C-c C-l), I expect that Emacs opens the file > with -- depending on the file type -- a pdf viewer or a browser. > > But I get an error message, see below ("ShellExecute failed:...") => file > can not be found. > > This used to work with Emacs 24.3. The share //SBS2011/Emacs and > U:/Emacs are the same folder on the server. > > tl;dr: ShellExecute fails, if > > 1. the path uses an abbrevation for the file name + > 2. the abbrevation contains a share name + > 3. the file has to be opened with an external software > > This used to work under Emacs 24.3 The real reason is much simpler: ShellExecute fails if the file name it receives is in UNC form and uses forward slashes, as in //SBS2011/Emacs (as opposed to \\SBS2011\Emacs). This fundamental problem is not new, it existed also in Emacs 24.3. I see in Org's git repository and emacs-orgmode mailing list that this problem was discovered and reported 6.5 years ago, see http://lists.gnu.org/archive/html/emacs-orgmode/2008-05/msg00168.html Unfortunately, instead of filing a bug against Emacs about this problem, the Org maintainer preferred to paper over it, by running the link's file name through convert-standard-filename, which on Windows just _happens_ to mirror all forward slashes to backslashes. But that is NEVER the right solution, because every Emacs primitive that deals with file names will generally call expand-file-name internally, which will convert backslashes back to forward slashes. It just _happened_ that w32-shell-execute didn't do that, until Emacs 24.4 (where a call to expand-file-name was introduced to solve an unrelated problem with ShellExecute). So this problem lay dormant for more than 6 years, until now, because application code relied on internal implementation details of a certain Emacs primitive. Please don't do that! I think it's a no-brainer that problems in Emacs primitives should be reported and solved in Emacs, not worked around in application code. In addition, almost any use of convert-standard-filename is wrong, with a single exception: when a file name defined by Emacs sources might be invalid on some filesystem. This is what "standard" in the function's name means. Any other use of this function should immediately cause alarms to go off, as it usually means some real underlying problem is being papered over. Anyway, I fixed this problem in 73cad91 on the emacs-24 branch. If the OP can rebuild Emacs, the patch is below. Please remove the calls to convert-standard-filename from org.el:org-open-file, as it should no longer be needed with the real problem fixed. (Btw, the Org ChangeLog does not mention the addition of calls to convert-standard-filename, for some reason, and neither does the Org's Git commit log for the corresponding commit.) I'm closing this bug. Thanks for reporting it, and for the easy to follow reproduction recipe. --- src/w32fns.c~0 2014-11-19 07:33:11 +0200 +++ src/w32fns.c 2014-11-25 17:38:23 +0200 @@ -7019,7 +7019,14 @@ a ShowWindow flag: Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc); if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0) - document = absdoc_encoded; + { + /* ShellExecute fails if DOCUMENT is a UNC with forward + slashes (expand-file-name above converts all backslashes + to forward slashes). Now that we know DOCUMENT is a + file, we can mirror all forward slashes into backslashes. */ + unixtodos_filename (SSDATA (absdoc_encoded)); + document = absdoc_encoded; + } else document = ENCODE_FILE (document); } From unknown Sat Aug 09 01:26:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 24 Dec 2014 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator