Improve prelude-open-with

Now it uses `xdg-open` where it makes sense. It also accepts a prefix
argument that forces manual selection of a command to run.
This commit is contained in:
Bozhidar Batsov 2013-05-06 09:40:20 +03:00
parent ecbcc19c6d
commit d7d3a8fc36

View file

@ -35,14 +35,17 @@
(require 'thingatpt)
(require 'dash)
(defun prelude-open-with ()
"Open visited file in external program."
(interactive)
(defun prelude-open-with (arg)
"Open visited file in default external program.
With a prefix ARG always prompt for command to use."
(interactive "P")
(when buffer-file-name
(shell-command (concat
(if (eq system-type 'darwin)
"open"
(read-shell-command "Open current file with: "))
(cond
((and (not arg) (eq system-type 'darwin)) "open")
((and (not arg) (member system-type '(gnu gnu/linux gnu/kfreebsd))) "xdg-open")
(t (read-shell-command "Open current file with: ")))
" "
buffer-file-name))))