From: Juri Linkov Date: Thu, 2 Jul 2009 22:47:52 +0000 (+0000) Subject: (async-shell-command): New command. X-Git-Tag: emacs-pretest-23.1.90~2337 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c945a962d9fcfb55dae2c9df2f419164258ba360;p=emacs.git (async-shell-command): New command. --- diff --git a/lisp/simple.el b/lisp/simple.el index 44d3ae5040d..0bdc21a75b0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2054,6 +2054,23 @@ to `shell-command-history'." (or hist 'shell-command-history) args))) +(defun async-shell-command (command &optional output-buffer error-buffer) + "Execute string COMMAND asynchronously in background. + +Like `shell-command' but if COMMAND doesn't end in ampersand, adds `&' +surrounded by whitespace and executes the command asynchronously. +The output appears in the buffer `*Async Shell Command*'." + (interactive + (list + (read-shell-command "Async shell command: " nil nil + (and buffer-file-name + (file-relative-name buffer-file-name))) + current-prefix-arg + shell-command-default-error-buffer)) + (unless (string-match "&[ \t]*\\'" command) + (setq command (concat command " &"))) + (shell-command command output-buffer error-buffer)) + (defun shell-command (command &optional output-buffer error-buffer) "Execute string COMMAND in inferior shell; display output, if any. With prefix argument, insert the COMMAND's output at point.