在使用emacs阅读pdf过程中,发现pdf-tools过于卡顿,想要利用外部程序打开pdf文件(edge浏览器),先后将org-file-apps
配置如下:
(add-to-list 'org-file-apps '("\\.pdf\\'" . "open %s"))
(add-to-list 'org-file-apps '("\\.pdf\\'" . "edge %s"))
;; 将edge的路径加入.bash_profile里的PATH后
(add-to-list 'org-file-apps '("\\.pdf\\'" . "Microsoft\ edge %s"))
均无效,求助应该如何配置?
环境:MacOS
你指的是打开 Org Mode 文件链接吧,默认就是用系统程序打开的:Preview.app
没说能这么用的吧。用指定 App 打开文件,用 open 的 -a:
$ open -a "Google Chrome" test.pdf
是打开文件链接,我知道在shell里是open -a,在emacs里怎么配置,是要修改org-file-apps
吗?
(defun zerolee-open-with (arg)
"使用外部程序打开浏览的文件或者当前光标下的链接.
处于 dired mode 时, 打开当前光标下的文件;
若当前光标下存在链接,使用外部程序打开链接;
使用 prefix ARG 时指定使用的外部程序."
(interactive "P")
(let ((current-file-name
(cond ((eq major-mode 'dired-mode) (dired-get-file-for-visit))
((help-at-pt-string)
(pcase (cdr (split-string (help-at-pt-string) ":" t " "))
((or `(,path) `(,(pred (string= "file")) ,path) `(,_ ,path ,_))
(expand-file-name path))
(`(,proto ,path) (concat proto ":" path))))
(t (or (thing-at-point 'url) buffer-file-name))))
(program (if arg
(read-shell-command "Open current file with: ")
"xdg-open")))
(call-process program nil 0 nil current-file-name)))
MacOS 将 xdg-open 换成 open
2 个赞
试了下 Google Chrome,这么写可以:
(add-to-list
'org-file-apps
'("\\.pdf\\'" . "open -a 'Google Chrome' %s"))
1 个赞