* Handling file links under Windows
@ 2011-01-16 3:01 Leo Alekseyev
2011-01-16 3:26 ` Nick Dokos
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Leo Alekseyev @ 2011-01-16 3:01 UTC (permalink / raw)
To: emacs-orgmode
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. "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?.. Links are rather
fundamental to org-mode and it's annoying not to have them working
right.
--Leo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling file links under Windows
2011-01-16 3:01 Handling file links under Windows Leo Alekseyev
@ 2011-01-16 3:26 ` Nick Dokos
[not found] ` <-463692335126976696@unknownmsgid>
2011-01-16 11:07 ` Achim Gratz
2 siblings, 0 replies; 5+ messages in thread
From: Nick Dokos @ 2011-01-16 3:26 UTC (permalink / raw)
To: Leo Alekseyev; +Cc: nicholas.dokos, emacs-orgmode
Leo Alekseyev <dnquark@gmail.com> wrote:
> 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))
>
What's with the single quotes? What happens if you say "\\.jnt" and
"\\.pdf" instead?
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling file links under Windows
[not found] ` <-463692335126976696@unknownmsgid>
@ 2011-01-16 10:41 ` Leo Alekseyev
2011-01-23 14:51 ` David Maus
0 siblings, 1 reply; 5+ messages in thread
From: Leo Alekseyev @ 2011-01-16 10:41 UTC (permalink / raw)
To: Matthew Fidler, emacs-orgmode
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
<matthew.fidler@gmail.com> wrote:
> Leo,
>
> I am not at my computer, so I can't try this out. However 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 <dnquark@gmail.com> 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. "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?.. Links 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling file links under Windows
2011-01-16 3:01 Handling file links under Windows Leo Alekseyev
2011-01-16 3:26 ` Nick Dokos
[not found] ` <-463692335126976696@unknownmsgid>
@ 2011-01-16 11:07 ` Achim Gratz
2 siblings, 0 replies; 5+ messages in thread
From: Achim Gratz @ 2011-01-16 11:07 UTC (permalink / raw)
To: emacs-orgmode
Leo Alekseyev <dnquark@gmail.com> writes:
> 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")
Let me venture the guess that those spaces in the path are not quoted
on their way to the windows shell. Something like
(("\\.jnt\\'" . "\"C:\\Program Files\\Windows Journal\\Journal.exe\" \"%s\"")
might be the ticket (can't test right now).
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Handling file links under Windows
2011-01-16 10:41 ` Leo Alekseyev
@ 2011-01-23 14:51 ` David Maus
0 siblings, 0 replies; 5+ messages in thread
From: David Maus @ 2011-01-23 14:51 UTC (permalink / raw)
To: Leo Alekseyev; +Cc: Matthew Fidler, emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 3171 bytes --]
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
[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-23 14:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-16 3:01 Handling file links under Windows Leo Alekseyev
2011-01-16 3:26 ` Nick Dokos
[not found] ` <-463692335126976696@unknownmsgid>
2011-01-16 10:41 ` Leo Alekseyev
2011-01-23 14:51 ` David Maus
2011-01-16 11:07 ` Achim Gratz
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).