summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-10-15 10:16:09 +0000
committerRichard M. Stallman <rms@gnu.org>1994-10-15 10:16:09 +0000
commitd0d74413b708a53a2ec0db35ffb5e47b818b88d1 (patch)
treed3cfc68931bc0069fcddb5aca7bc3dc719d3e4d2 /lisp
parentc30b759d47de447ec79d721aeb5c766919f15e10 (diff)
downloademacs-d0d74413b708a53a2ec0db35ffb5e47b818b88d1.tar.gz
(shell-command, shell-command-on-region):
Rename arg FLAG to OUTPUT-BUFFER and allow it to be a buffer.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el38
1 files changed, 27 insertions, 11 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 8ca4eb99e91..b4edb5c7ed3 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -658,17 +658,22 @@ then call `undo-more' one or more times to undo them."
(defvar shell-command-history nil
"History list for some commands that read shell commands.")
-(defun shell-command (command &optional flag)
+(defun shell-command (command &optional output-buffer)
"Execute string COMMAND in inferior shell; display output, if any.
If COMMAND ends in ampersand, execute it asynchronously.
-
-Optional second arg non-nil (prefix arg, if interactive)
-means insert output in current buffer after point (leave mark after it).
-This cannot be done asynchronously."
+The output appears in the buffer `*Shell Command*'.
+
+The optional second argument OUTPUT-BUFFER, if non-nil,
+says to put the output in some other buffer.
+If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
+If OUTPUT-BUFFER is not a buffer and not nil,
+insert output in current buffer. (This cannot be done asynchronously.)
+In either case, the output is inserted after point (leaving mark after it)."
(interactive (list (read-from-minibuffer "Shell command: "
nil nil nil 'shell-command-history)
current-prefix-arg))
- (if flag
+ (if (and output-buffer
+ (not (or (bufferp output-buffer) (stringp output-buffer))))
(progn (barf-if-buffer-read-only)
(push-mark)
;; We do not use -f for csh; we will not support broken use of
@@ -689,7 +694,8 @@ This cannot be done asynchronously."
(unwind-protect
(if (string-match "[ \t]*&[ \t]*$" command)
;; Command ending with ampersand means asynchronous.
- (let ((buffer (get-buffer-create "*Shell-Command*"))
+ (let ((buffer (get-buffer-create
+ (or output-buffer "*Shell-Command*")))
(directory default-directory)
proc)
;; Remove the ampersand.
@@ -751,7 +757,8 @@ This cannot be done asynchronously."
(goto-char opoint))
(set-buffer obuf))))
-(defun shell-command-on-region (start end command &optional flag interactive)
+(defun shell-command-on-region (start end command
+ &optional output-buffer interactive)
"Execute string COMMAND in inferior shell with region as input.
Normally display output (if any) in temp buffer `*Shell Command Output*';
Prefix arg means replace the region with it.
@@ -763,13 +770,21 @@ If the output is one line, it is displayed in the echo area,
but it is nonetheless available in buffer `*Shell Command Output*'
even though that buffer is not automatically displayed. If there is no output
or output is inserted in the current buffer then `*Shell Command Output*' is
-deleted."
+deleted.
+
+The optional second argument OUTPUT-BUFFER, if non-nil,
+says to put the output in some other buffer.
+If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
+If OUTPUT-BUFFER is not a buffer and not nil,
+insert output in the current buffer.
+In either case, the output is inserted after point (leaving mark after it)."
(interactive (list (region-beginning) (region-end)
(read-from-minibuffer "Shell command on region: "
nil nil nil 'shell-command-history)
current-prefix-arg
(prefix-numeric-value current-prefix-arg)))
- (if flag
+ (if (and output-buffer
+ (not (or (bufferp output-buffer) (stringp output-buffer))))
;; Replace specified region with output from command.
(let ((swap (and interactive (< (point) (mark)))))
;; Don't muck with mark
@@ -783,7 +798,8 @@ deleted."
(and interactive swap (exchange-point-and-mark)))
;; No prefix argument: put the output in a temp buffer,
;; replacing its entire contents.
- (let ((buffer (get-buffer-create "*Shell Command Output*"))
+ (let ((buffer (get-buffer-create
+ (or output-buffer "*Shell Command Output*")))
(success nil))
(unwind-protect
(if (eq buffer (current-buffer))