From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Alekseyev Subject: Re: Handling file links under Windows Date: Sun, 16 Jan 2011 05:41:06 -0500 Message-ID: References: <-463692335126976696@unknownmsgid> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=46055 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PeQ2n-0000We-9P for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 05:41:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PeQ2l-0004za-Q6 for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 05:41:09 -0500 Received: from mail-fx0-f41.google.com ([209.85.161.41]:39122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PeQ2l-0004zM-KW for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 05:41:07 -0500 Received: by fxm12 with SMTP id 12so4653447fxm.0 for ; Sun, 16 Jan 2011 02:41:06 -0800 (PST) In-Reply-To: <-463692335126976696@unknownmsgid> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Matthew Fidler , emacs-orgmode@gnu.org Guided by Matt's suggestion I started digging further. I see the problem, but I don't know how to fix it other than by making crude changes directly to source in org.el. Both the command path and the file link path need to be properly formatted for Windows. In particular, in org-file-apps list, I need something like ("\\.jnt\\'" . (format "%s %%s" (w32-short-file-name "C:\\Program Files\\Windows Journal\\Journal.exe"))). But, this expression doesn't work verbatim. If I evaluate (format....) and paste the result as the cdr of the dotted pair, e.g. ("\\.jnt\\'" . "c:/PROGRA~1/WI0FCF~1/Journal.exe %s"), the command is invoked. So, question 1: How do I eval the (format...) expression automatically?.. A more serious problem is that emacs is failing to correctly convert slashes to backslashes in the file path. My emacs is launched by cygwin, and so apparently it thinks that slashes are OK, but in fact they are not. Here are the explicit modifications to org-find-file in org.el that are needed to get things to work: Original code (doesn't work under Windows): (setq cmd (replace-match (save-match-data (shell-quote-argument (convert-standard-filename file))) t t cmd))) Here's what works: (setq cmd (replace-match (w32-short-file-name (save-match-data (convert-standard-filename (replace-regexp-in-string "/" "\\" file t t)))) t t cmd)) Note that instead of (convert-standard-filename file) I need to explicitly replace slashes with backslashes, and shell-quote-argument must be replaced with w32-short-file-name. So, question 2: Is there a way to make these modifications without patching org?.. --Leo On Sat, Jan 15, 2011 at 10:27 PM, Matthew Fidler wrote: > Leo, > > I am not at my computer, so I can't try this out. =A0However I believe > it may be the spaces in your commands. Try: > >> (("\\.jnt\\'" . (format "%s %%s" (w32-short-file-name "C:\\Program Files= \\Windows >> Journal\\Journal.exe")) >> ("\\.pdf\\'" . (format "%s %%s" (w32-short-file-name "C:\\Program Files = (x86)\\Adobe\\Acrobat >> 10.0\\Acrobat\\Acrobat.exe") >> (auto-mode . emacs) >> ("\\.x?html?\\'" . default)) > > Matt > > On Jan 15, 2011, at 9:03 PM, Leo Alekseyev wrote: > >> Dear All, >> I would like to have links to PDF files open those files in Acrobat >> and links to Windows Journal (JNT) files open them in Windows Journal >> -- very simple; same as it would be as if I double-clicked them >> anywhere in Windows. >> >> Here is what happens now: PDF files open in emacs doc-view mode, and >> JNT files fail to open with the message "ShellExecute failed: >> Application not found^M" (sic). >> >> If I try to explicitly set the variable org-file-apps, so that its >> value is (("\\.jnt\\'" . "C:\\Program Files\\Windows >> Journal\\Journal.exe %s") >> ("\\.pdf\\'" . "C:\\Program Files (x86)\\Adobe\\Acrobat >> 10.0\\Acrobat\\Acrobat.exe %s") >> (auto-mode . emacs) >> ("\\.x?html?\\'" . default)) >> >> -- but in this case, opening those links silently fails (even though I >> can type e.g. =A0"C:\Program Files\Windows Journal\Journal.exe foo.jnt" >> from Windows command line and it works fine). >> >> Can anyone help with getting this to work right?.. =A0Links are rather >> fundamental to org-mode and it's annoying not to have them working >> right. >> >> --Leo >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >