在Evince中如何使Org-mode打开PDF文件? [英] How do I make Org-mode open PDF files in Evince?

查看:184
本文介绍了在Evince中如何使Org-mode打开PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在组织模式下,当我尝试打开一个PDF文件的链接没有任何反应。另外,当我执行 C-c C-e d 导出为LaTeX并处理为PDF并打开PDF生成但未打开。在Evince中如何使Org-mode打开PDF文件?

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?

我在Ubuntu 11.10中的GNU Emacs 23.3.1和Evince 3.2.1中使用了Org-mode 7.6。

I am using Org-mode 7.6 in GNU Emacs 23.3.1 and Evince 3.2.1 in Ubuntu 11.10.

推荐答案

可能为此工作的另一个可能的构造是使用 eval-after-load 而不是 add-hook 。它只会在启动时设置一次值,您不必担心添加条目(除非您经常重新加载org)。

Another possible construct that could work for this would be to use eval-after-load rather than add-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).

将其与 setcdr ,您可以避免从列表中删除然后重新添加,如果添加,那么您将确保您可以添加或更改该值。默认情况下,只有这些值不在列表中才需要,只是为了确保你不会在下一个地方遇到冲突。

Combine that with setcdr and you can avoid having to delete from the list and then re-add, add if 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.

(eval-after-load "org"
  '(progn
     ;; .txt files aren't in the list initially, but in case that changes
     ;; in a future version of org, use if to avoid errors
     (if (assoc "\\.txt\\'" org-file-apps)
         (setcdr (assoc "\\.txt\\'" org-file-apps) "notepad.exe %s")
       (add-to-list 'org-file-apps '("\\.txt\\'" . "notepad.exe %s") t))
     ;; Change .pdf association directly within the alist
     (setcdr (assoc "\\.pdf\\'" org-file-apps) "evince %s")))






编辑澄清


Edit for clarification

eval-after-load (require'org)仅评估块叫做。如果已经加载了org,它将立即进行评估(我错误地认为每次加载一个库时都会运行,但这似乎是第一次)。 add-hook eval-after-load 之间的区别被解释为此处

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 between add-hook and eval-after-load is explained here.

由于 org-file-apps 是一个 defcustom 如果您从头开始构建列表(包括第二个(uglier)解决方案中的默认值)),则可以在单元格加载之前将其设置为更改值,您可以简单地 setq 在你的init.el和一切都可以工作。这也意味着它不会覆盖您的更改。

Since org-file-apps is a defcustom 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 simply setq in your init.el and everything would work. It also means it won't overwrite your changes.

添加(如果(assoc 没有任何东西,它只会确保如果PDF被从默认的 org-file-apps 中删除​​,它仍将被添加。唯一的解决方案不会失败,如果PDF被删除是您的第二个,其他人都认为条目存在于一种或另一种形式。

Adding (if (assoc to the PDF entry won't hurt anything, it will simply ensure that if PDFs are ever removed from the default org-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.

这篇关于在Evince中如何使Org-mode打开PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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