在Emacs组织模式文件中,当我单击PDF时,文件将在PDF查看器中打开.同样,当我点击一个URL时,它会在Web浏览器中打开.但是,当我单击图像文件的路径时,字节流将在编辑器中以文本形式打开.如何配置Emacs/org-mode以使用指定的应用程序(例如图像编辑器或浏览器)打开图像?
Jér*_*dix 16
在组织模式中,这是org-file-apps控制在单击类似URL的文本时要执行的操作.
它默认配置为:
((auto-mode . emacs)
("\\.mm\\'" . default)
("\\.x?html?\\'" . default)
("\\.pdf\\'" . default))
Run Code Online (Sandbox Code Playgroud)
正如org-file-apps帮助中所述:auto-mode匹配任何条目匹配的文件auto-mode-alist,因此所有Emacs知道如何处理的文件.使用with with with命令emacs将打开Emacs中的大多数文件.
您可以在auto-mode-alist中配置图像文件扩展名.您可以通过在.emacs中执行类似的操作来覆盖此alist(例如,对于png文件):
(add-hook 'org-mode-hook
'(lambda ()
(setq org-file-apps
(append '(
("\\.png\\'" . default)
) org-file-apps ))))
Run Code Online (Sandbox Code Playgroud)
使用此代码,当我点击这样的链接时:
file:///e:/jrx/emacs/image.png
Run Code Online (Sandbox Code Playgroud)
它使用与此文件扩展名关联的默认OS程序在emacs外部打开文件.
你不必改变org-file-apps-defaults-windowsnt,org-file-apps-defaults-gnu或者org-file-apps-defaults-macosx使用相关的文件扩展名操作系统默认程序.