From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: Re: Handling file links under Windows Date: Sun, 23 Jan 2011 15:51:45 +0100 Message-ID: <87sjwjhdvi.wl%dmaus@ictsoc.de> References: <-463692335126976696@unknownmsgid> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="===============1036845985==" Return-path: Received: from [140.186.70.92] (port=39587 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ph1KD-0003lr-Dj for emacs-orgmode@gnu.org; Sun, 23 Jan 2011 09:53:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ph1KB-0003b0-Oc for emacs-orgmode@gnu.org; Sun, 23 Jan 2011 09:53:52 -0500 Received: from mailout110.xlhost.de ([213.202.242.110]:55915 helo=mysql1.xlhost.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ph1KB-0003ap-D2 for emacs-orgmode@gnu.org; Sun, 23 Jan 2011 09:53:51 -0500 In-Reply-To: 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: Leo Alekseyev Cc: Matthew Fidler , emacs-orgmode@gnu.org --===============1036845985== Content-Type: multipart/signed; boundary="pgp-sign-Multipart_Sun_Jan_23_15:51:45_2011-1"; micalg=pgp-sha256; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit --pgp-sign-Multipart_Sun_Jan_23_15:51:45_2011-1 Content-Type: text/plain; charset=US-ASCII At Sun, 16 Jan 2011 05:41:06 -0500, Leo Alekseyev wrote: > > 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?.. If you set `org-file-apps' in your init file via setq you can use backquotes: (setq org-file-apps `(("\\.jnt\\'" . ,(format "%s %%s" (w32-short-file-name "C:\\Program Files\\Windows Journal\\Journal.exe"))))) Cf. http://www.gnu.org/s/emacs/manual/html_node/elisp/Backquote.html > > 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?.. Not sure. Maybe you could perform the translation with a translation function? C-h v org-link-translation-function RET ,----[ *Help* ] | org-link-translation-function is a variable defined in `org.el'. | Its value is nil | | This variable is potentially risky when used as a file local variable. | | Documentation: | Function to translate links with different syntax to Org syntax. | This can be used to translate links created for example by the Planner | or emacs-wiki packages to Org syntax. | The function must accept two parameters, a TYPE containing the link | protocol name like "rmail" or "gnus" as a string, and the linked path, | which is everything after the link protocol. It should return a cons | with possibly modified values of type and path. | Org contains a function for this, so if you set this variable to | `org-translate-link-from-planner', you should be able follow many | links created by planner. | | You can customize this variable. | | [back] `---- Best, -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber.... dmjena@jabber.org Email..... dmaus@ictsoc.de --pgp-sign-Multipart_Sun_Jan_23_15:51:45_2011-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iF4EAREIAAYFAk08QIEACgkQma24O1pEeOYcsgEA6sXgqhLtZgysSGX74Lsqcbi/ kZMa/XMH29aAsgNWVxAA/A/XOTPTPjD1O5TmggQHKOjT2dDB7ETrRdKi1wgOgBFe =bHEg -----END PGP SIGNATURE----- --pgp-sign-Multipart_Sun_Jan_23_15:51:45_2011-1-- --===============1036845985== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1036845985==--