使用默认的Windows应用程序从emacs打开文件 [英] Opening files with default Windows application from within emacs

查看:277
本文介绍了使用默认的Windows应用程序从emacs打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows XP上调整emacs中的 dired-find-file 函数,这样当我打开(说)一个pdf文件从dired它启动Acrobat Reader的副本,并打开该文件,而不是在emacs中打开该文件。但是我不能在 shell-command / call-process 中使用什么变体。这是我到目前为止:

I'm trying to tweak the dired-find-file function in emacs on Windows XP so that when I open (say) a pdf file from dired it fires up a copy of Acrobat Reader and opens that file with it, instead of opening it within emacs. But I can't work out what variant on shell-command/call-process to use. Here's what I have so far:

(defadvice dired-find-file (around dired-find-file-external (filename &optional wildcards))
  "Open non-text files with an appropriate external program."
  (if (string= ".pdf" (substring filename (- (length filename) 4))) ; obviously I'll replace this with something more general/robust
    (shell-command filename) ;; what should go here?
    (ad-do-it)))

(ad-activate 'dired-find-file)

我知道我可以用硬编码来启动Acrobat通过给读者提供.exe文件的位置。但是,我宁愿有一些需要较少的搜索,当默认应用程序移动/更改时不会中断。我应该使用什么?

I know I could hard-code it to start Acrobat Reader by giving it the location of the .exe file. But I'd rather have something which requires less searching from me and which won't break when default applications move/change. What should I use?

推荐答案


  1. 评估以下elisp

  2. 运行dired(Mx dired)

  3. 浏览到目录和文件

  4. 点击文件,按F3将打开文件在Windows扩展上。

  1. Evaluate the following elisp
  2. Run dired (M-x dired)
  3. Browse to directory and file
  4. With point on file, pressing F3 will open the file based on the windows extension.

(defun w32-browser(doc)(w32-shell-execute 1 doc))

(eval-after-loaddired'(define-key dired-mode-map [f3](lambda )(w32-browser(dired-replace-in-string/\\(dired-get-filename))))))

这篇关于使用默认的Windows应用程序从emacs打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆