summaryrefslogtreecommitdiff
path: root/.emacs.d
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-10-21 00:31:03 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-10-21 00:31:03 +0200
commitd0960305e0606817ce620c3dee240e668521388b (patch)
treec0807cd15b51c5285d6a96091d4dd4e8c6435daf /.emacs.d
parentd776574f954fa08205f0879d31feaa56733b96a3 (diff)
downloadebsd-d0960305e0606817ce620c3dee240e668521388b.tar.gz
Emacs: Improve launch-program
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/init.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 6d27d71..6405bf1 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -270,11 +270,16 @@ the only window in the frame."
;;; Processes
(defun launch-program (command)
+ "Launch program in the background (or foreground if COMMAND ends with semicolon)."
(interactive (list (read-shell-command "Launch program: ")))
- (make-process :name command
- :buffer "*launch-program*"
- :filter #'launch-program-filter
- :command (list shell-file-name shell-command-switch command))
+ (let ((name command))
+ (when (not (string= ";" (substring command -1 nil)))
+ (setq name (concat command "&"))
+ (setq command (concat "which " (car (split-string command)) ">/dev/null&&" command "&")))
+ (make-process :name name
+ :buffer "*launch-program*"
+ :filter #'launch-program-filter
+ :command (list shell-file-name shell-command-switch command)))
(switch-to-buffer "*launch-program*")
(bury-buffer "*launch-program*"))
(defun launch-program-filter (proc string)