I want to open a pdf with evince instead of DocView mode. Is there a possibility to open a file with a specific command like 'evince'?
7 Answers
29
votes
20
votes
There is more then one way to do that. I suggest OpenWith library. Setup for your case may look like that:
(add-to-list 'load-path "/path/to/downloaded/openwith.el")
(require 'openwith)
(setq openwith-associations '(("\\.pdf\\'" "evince" (file))))
(openwith-mode t)
It sets file handler that will work from both dired and find-file.
10
votes
5
votes
Note that you can keep the process alive after exiting Emacs by using nohup [Wikipedia], so put the point on a single file in dired:
C-u ! nohup evince ? &
which creates a Persistent Processes [EmacsWiki].
0
votes
(defun dired-open()
(interactive)
(setq file (dired-get-file-for-visit))
(setq ext (file-name-extension file))
(cond ((string= ext "pdf")
;; shell-quote-argument escapes white spaces on the file name
(async-shell-command (concat "zathura " (shell-quote-argument file))))
((string= ext "epub")
(async-shell-command (concat "zathura " (shell-quote-argument file))))
((string= ext "rar")
(async-shell-command (concat "file-roller " (shell-quote-argument file))))
((string= ext "zip")
(async-shell-command (concat "file-roller " (shell-quote-argument file))))
(t (dired-find-file))))