2

如何从 Org 模式链接到 Windows 环境中网络驱动器上的文件?

我得到错误:

eval: ShellExecute failed: 系统找不到指定的文件。

通过这种链接:

[[//share/path/to/file.csv]]

4

3 回答 3

2

我也有同样的问题。我将其追溯到org-open-at-point将 PATH 转换为w32-shell-execute无法打开的东西。使用下面的 defadvice,我可以打开 // 和 \ 网络路径。

(defadvice w32-shell-execute (around 
                              workaround-for-org-w32-shell-execute
                              activate)
  "Replace w32-shell-execute PATH directory seperators to Windows
backslash when PATH starts with '//' (i.e. Network path). This
allows allowing org-mode links in org-mode files like
[[\\\\myserver\\mypath\\mydoc.doc][mydoc.doc]] to be opened by
org-open-at-point. Forward slashes / are also accepted.

org-open-at-point transforms the links to //../../ but
unfortunately w32-shell-execute does not accept that."
  (let ((operation (ad-get-arg 0))
        (path      (ad-get-arg 1)))
    (when (and (string-equal operation "open")
               (eql (string-match "//" path 0) 0))
      (setq path (replace-regexp-in-string "/" "\\\\" path))
      ;; debug (message "Opening %s" path)
      (ad-set-arg 1 path))
    ad-do-it))

试试 [[//127.0.0.1/c$$]]

这是一个快速而肮脏的修复,但“它适用于我的机器”。

在 Emacs 24.2、组织模式 7.9.11 上验证。

编辑:当我将以下关联添加到 org-mode 时,关于“但是,对我来说一个重要的用例是打开其他类型的文件(例如 MS Office 文件)”的评论对我有用。我可以使用 [[\server\share\piyo.doc]] 等普通 org-mode url 打开 Microsoft Word、Excel 等

(mapc (lambda (file-name-matcher)
    (add-to-list 'org-file-apps
                 (cons file-name-matcher 'default) 'append))
  (list "\\.doc\\'"
        "\\.xls\\'"
        "\\.ppt\\'"))

编辑:关于“[[file+sys:]]”的注释是“open [a file] via OS, like double-click”,可以通过上面的关联来实现。在我的 Windows 计算机上,我不需要“[[file+sys:]]”。

于 2012-09-24T19:34:33.407 回答
1

Windows 的某些部分和某些 Windows 应用程序不支持 UNC 路径。Emacs 可以,但看起来您(或 org-mode)正在尝试执行某些程序,而不是简单地使用 find-file 在 Emacs 中查看文件。解决方法是安装//share/pathX:[[X:/to/file.csv]]用作您的链接。

于 2012-07-20T03:48:54.973 回答
0

如果您的 UNC 路径碰巧包含与远程磁盘驱动程序相关的管理共享之一(如 \server\c$ 或 \server\d$,则需要​​将磁盘字母后的 $ 加倍,以便它们看起来像 \server \c$$ 或 \server\d$$

于 2012-07-20T21:42:51.787 回答