From d7d3a8fc36728cb375ab2d965a65278e497b1161 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 6 May 2013 09:40:20 +0300 Subject: [PATCH] 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. --- core/prelude-core.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/prelude-core.el b/core/prelude-core.el index 6ec11d5..a4c4b68 100644 --- a/core/prelude-core.el +++ b/core/prelude-core.el @@ -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))))