如何在 Evince 中以 Org 模式打开 PDF 文件?
在组织模式下,当我尝试打开 PDF 文件的链接时,没有任何反应。另外,当我执行Cc Ce d导出为LaTeX并处理为PDF并打开时,会生成PDF但未打开。如何在 Evince 中以 Org 模式打开 PDF 文件?
我在 GNU Emacs 23.3.1 中使用 Org-mode 7.6,在 Ubuntu 11.10 中使用 Evince 3.2.1。
In Org-mode when I try to open a link to a PDF file nothing happens. Also, when I do C-c C-e d to export as LaTeX and process to PDF and open the PDF is generated but not opened. How do I make Org-mode open PDF files in Evince?
I am using Org-mode 7.6 in GNU Emacs 23.3.1 and Evince 3.2.1 in Ubuntu 11.10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果 org 使用您的系统默认值,您必须编辑 ./mailcap 文件。
尝试添加这一行:
If org uses your system defaults, you have to edit your ./mailcap file.
Try adding this line:
另一种可能的结构是使用
eval-after-load
而不是add-hook
。它只会在启动时设置一次值,您不必担心是否添加条目(除非您定期重新加载组织)。将其与
setcdr
结合使用,您可以避免从列表中删除然后重新添加,添加if
即可确保添加或更改值。仅当默认情况下不在列表中的值才需要 if ,只是为了确保最终不会在某处发生冲突。编辑以澄清
eval-after-load
仅在调用(require 'org)
时评估该块。如果 org 已经加载,它将立即评估(我错误地认为它在每次加载库时运行,但这似乎只是第一次)。add-hook
和eval-after-load
之间的区别解释如下此处。由于
org-file-apps
是一个defcustom
如果您在加载 org 之前设置这些值,如果您从头开始构建列表(包括默认值),则它不会更改这些值就像在你的第二个(丑陋的)解决方案中一样)你可以简单地在 init.el 中setq
,一切都会正常。这也意味着它不会覆盖您的更改。将
(if (assoc
) 添加到 PDF 条目不会造成任何损害,它只会确保如果从默认的org-file-apps
中删除 PDF,它会如果 PDF 被删除,唯一不会失败的解决方案是您的第二个解决方案,其他方案都假设该条目以一种或另一种形式存在。Another possible construct that could work for this would be to use
eval-after-load
rather thanadd-hook
. It will only set the values once on startup, you won't have to worry about entries being added or not (unless you regularly reload org).Combine that with
setcdr
and you can avoid having to delete from the list and then re-add, addif
and you'll ensure that you either add or change the value. The if is only needed for values that aren't in the list by default, just to make sure you don't end up with conflicts somewhere down the line.Edit for clarification
eval-after-load
only evaluates the block when(require 'org)
is called. If org is already loaded it will evaluate immediately (I mistakenly thought it ran each time a library was loaded, but it seems to be only the first time). The difference betweenadd-hook
andeval-after-load
is explained here.Since
org-file-apps
is adefcustom
it won't change the values if you set them before org is loaded, if you build the list from scratch (including default values as in your second (uglier) solution) you could simplysetq
in your init.el and everything would work. It also means it won't overwrite your changes.Adding
(if (assoc
to the PDF entry won't hurt anything, it will simply ensure that if PDFs are ever removed from the defaultorg-file-apps
that it will still be added. The only solution that would not fail if PDFs were removed is your second one. The others all assume the entry exists in one form or another.您可以使用类似于 https://stackoverflow.com/a/3985552/789593 的构造,但将其调整为 PDF 文件和艾文斯。您想要做的是更改列表
org-file-apps
。这可以通过将以下内容添加到 .emacs 中来完成:这将删除 PDF 文件的默认设置,并在 Evince 中打开它们(并保留 org-file-apps 中包含的其他所有内容)。我是 elisp 的新手,所以我不知道这个解决方案是否强大,但它对我有用,并且似乎比下面的更优雅。
另一种似乎更丑陋的选择是查找默认值并设置所有这些值,但更改 PDF 文件的值:
You can use a construct similar to https://stackoverflow.com/a/3985552/789593 but adapt it to PDF files and Evince. What you want to do is to alter the list
org-file-apps
. This can be done by adding the following to your .emacs:This will delete the default setting for PDF files and instead open them in Evince (and retain everything else included in
org-file-apps
). I am new to elisp so I do not know if this solution is robust, but it works for me and seems to be more elegant than the one below.Another option, which seems uglier, is to instead look up the default values and set them all that but change the value for PDF files: