changeset 10912:be434b59c22e

(shell-command-on-region): Obey REPLACE even if OUTPUT-BUFFER is nil. Interactively, make REPLACE non-nil only if there is a prefix arg.
author Richard M. Stallman <rms@gnu.org>
date Fri, 03 Mar 1995 06:48:20 +0000
parents 83fb3fdeda96
children 880d7c28921c
files lisp/simple.el
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Fri Mar 03 06:41:20 1995 +0000
+++ b/lisp/simple.el	Fri Mar 03 06:48:20 1995 +0000
@@ -818,8 +818,7 @@
 
 The noninteractive arguments are START, END, COMMAND, OUTPUT-BUFFER, REPLACE.
 If REPLACE is non-nil, that means insert the output
-in place of text from START to END,
-and put point at the end, but don't alter the mark.
+in place of text from START to END, putting point and mark around it.
 
 If the output is one line, it is displayed in the echo area,
 but it is nonetheless available in buffer `*Shell Command Output*'
@@ -843,19 +842,21 @@
 		 (list (region-beginning) (region-end)
 		       string
 		       current-prefix-arg
-		       (prefix-numeric-value current-prefix-arg))))
-  (if (and output-buffer
-	   (not (or (bufferp output-buffer) (stringp output-buffer))))
+		       current-prefix-arg)))
+  (if (or replace
+	  (and output-buffer
+	       (not (or (bufferp output-buffer) (stringp output-buffer)))))
       ;; Replace specified region with output from command.
       (let ((swap (and replace (< (point) (mark)))))
-	;; Don't muck with mark
-	;; unless called interactively.
+	;; Don't muck with mark unless REPLACE says we should.
+	(goto-char start)
 	(and replace (push-mark))
 	(call-process-region start end shell-file-name t t nil
 			     shell-command-switch command)
 	(let ((shell-buffer (get-buffer "*Shell Command Output*")))
 	  (and shell-buffer (not (eq shell-buffer (current-buffer)))
 	       (kill-buffer shell-buffer)))
+	;; Don't muck with mark unless REPLACE says we should.
 	(and replace swap (exchange-point-and-mark)))
     ;; No prefix argument: put the output in a temp buffer,
     ;; replacing its entire contents.