Mercurial > emacs
changeset 103694:695df25d3fc1
(async-shell-command): New command.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Thu, 02 Jul 2009 22:47:52 +0000 |
parents | e094814e8eed |
children | eace56b963d4 |
files | lisp/simple.el |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/simple.el Thu Jul 02 22:47:33 2009 +0000 +++ b/lisp/simple.el Thu Jul 02 22:47:52 2009 +0000 @@ -2054,6 +2054,23 @@ (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.