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