diff options
| author | Richard M. Stallman | 1995-03-03 06:48:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-03-03 06:48:20 +0000 |
| commit | 4d9bd664230622448a43b8960264b8419f17b157 (patch) | |
| tree | 3b24bb39f62155b93eae0f6d2961cc6877a06c4d | |
| parent | a9cc8174a22953fc5629c1b85e722aefe6026650 (diff) | |
| download | emacs-4d9bd664230622448a43b8960264b8419f17b157.tar.gz emacs-4d9bd664230622448a43b8960264b8419f17b157.zip | |
(shell-command-on-region): Obey REPLACE even if
OUTPUT-BUFFER is nil. Interactively, make REPLACE non-nil
only if there is a prefix arg.
| -rw-r--r-- | lisp/simple.el | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index b8a0e629cbd..5d0058d19a6 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -818,8 +818,7 @@ Prefix arg means replace the region with it. | |||
| 818 | 818 | ||
| 819 | The noninteractive arguments are START, END, COMMAND, OUTPUT-BUFFER, REPLACE. | 819 | The noninteractive arguments are START, END, COMMAND, OUTPUT-BUFFER, REPLACE. |
| 820 | If REPLACE is non-nil, that means insert the output | 820 | If REPLACE is non-nil, that means insert the output |
| 821 | in place of text from START to END, | 821 | in place of text from START to END, putting point and mark around it. |
| 822 | and put point at the end, but don't alter the mark. | ||
| 823 | 822 | ||
| 824 | If the output is one line, it is displayed in the echo area, | 823 | If the output is one line, it is displayed in the echo area, |
| 825 | but it is nonetheless available in buffer `*Shell Command Output*' | 824 | but it is nonetheless available in buffer `*Shell Command Output*' |
| @@ -843,19 +842,21 @@ In either case, the output is inserted after point (leaving mark after it)." | |||
| 843 | (list (region-beginning) (region-end) | 842 | (list (region-beginning) (region-end) |
| 844 | string | 843 | string |
| 845 | current-prefix-arg | 844 | current-prefix-arg |
| 846 | (prefix-numeric-value current-prefix-arg)))) | 845 | current-prefix-arg))) |
| 847 | (if (and output-buffer | 846 | (if (or replace |
| 848 | (not (or (bufferp output-buffer) (stringp output-buffer)))) | 847 | (and output-buffer |
| 848 | (not (or (bufferp output-buffer) (stringp output-buffer))))) | ||
| 849 | ;; Replace specified region with output from command. | 849 | ;; Replace specified region with output from command. |
| 850 | (let ((swap (and replace (< (point) (mark))))) | 850 | (let ((swap (and replace (< (point) (mark))))) |
| 851 | ;; Don't muck with mark | 851 | ;; Don't muck with mark unless REPLACE says we should. |
| 852 | ;; unless called interactively. | 852 | (goto-char start) |
| 853 | (and replace (push-mark)) | 853 | (and replace (push-mark)) |
| 854 | (call-process-region start end shell-file-name t t nil | 854 | (call-process-region start end shell-file-name t t nil |
| 855 | shell-command-switch command) | 855 | shell-command-switch command) |
| 856 | (let ((shell-buffer (get-buffer "*Shell Command Output*"))) | 856 | (let ((shell-buffer (get-buffer "*Shell Command Output*"))) |
| 857 | (and shell-buffer (not (eq shell-buffer (current-buffer))) | 857 | (and shell-buffer (not (eq shell-buffer (current-buffer))) |
| 858 | (kill-buffer shell-buffer))) | 858 | (kill-buffer shell-buffer))) |
| 859 | ;; Don't muck with mark unless REPLACE says we should. | ||
| 859 | (and replace swap (exchange-point-and-mark))) | 860 | (and replace swap (exchange-point-and-mark))) |
| 860 | ;; No prefix argument: put the output in a temp buffer, | 861 | ;; No prefix argument: put the output in a temp buffer, |
| 861 | ;; replacing its entire contents. | 862 | ;; replacing its entire contents. |