Mercurial > emacs
comparison lisp/simple.el @ 10852:55552df3bd18
(shell-command-on-region): Rename arg; doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 28 Feb 1995 18:04:57 +0000 |
parents | bccf0295c66e |
children | cd64b7e04e23 |
comparison
equal
deleted
inserted
replaced
10851:8064f933eed7 | 10852:55552df3bd18 |
---|---|
775 (if opoint | 775 (if opoint |
776 (goto-char opoint)) | 776 (goto-char opoint)) |
777 (set-buffer obuf)))) | 777 (set-buffer obuf)))) |
778 | 778 |
779 (defun shell-command-on-region (start end command | 779 (defun shell-command-on-region (start end command |
780 &optional output-buffer interactive) | 780 &optional output-buffer replace) |
781 "Execute string COMMAND in inferior shell with region as input. | 781 "Execute string COMMAND in inferior shell with region as input. |
782 Normally display output (if any) in temp buffer `*Shell Command Output*'; | 782 Normally display output (if any) in temp buffer `*Shell Command Output*'; |
783 Prefix arg means replace the region with it. | 783 Prefix arg means replace the region with it. |
784 Noninteractive args are START, END, COMMAND, FLAG. | 784 |
785 Noninteractively FLAG means insert output in place of text from START to END, | 785 The noninteractive arguments are START, END, COMMAND, OUTPUT-BUFFER, REPLACE. |
786 If REPLACE is non-nil, that means insert the output | |
787 in place of text from START to END, | |
786 and put point at the end, but don't alter the mark. | 788 and put point at the end, but don't alter the mark. |
787 | 789 |
788 If the output is one line, it is displayed in the echo area, | 790 If the output is one line, it is displayed in the echo area, |
789 but it is nonetheless available in buffer `*Shell Command Output*' | 791 but it is nonetheless available in buffer `*Shell Command Output*' |
790 even though that buffer is not automatically displayed. If there is no output | 792 even though that buffer is not automatically displayed. |
791 or output is inserted in the current buffer then `*Shell Command Output*' is | 793 If there is no output. or ifoutput is inserted in the current buffer, |
792 deleted. | 794 then `*Shell Command Output*' is deleted. |
793 | 795 |
794 The optional second argument OUTPUT-BUFFER, if non-nil, | 796 If the optional fourth argument OUTPUT-BUFFER is non-nil, |
795 says to put the output in some other buffer. | 797 that says to put the output in some other buffer. |
796 If OUTPUT-BUFFER is a buffer or buffer name, put the output there. | 798 If OUTPUT-BUFFER is a buffer or buffer name, put the output there. |
797 If OUTPUT-BUFFER is not a buffer and not nil, | 799 If OUTPUT-BUFFER is not a buffer and not nil, |
798 insert output in the current buffer. | 800 insert output in the current buffer. |
799 In either case, the output is inserted after point (leaving mark after it)." | 801 In either case, the output is inserted after point (leaving mark after it)." |
800 (interactive (let ((string | 802 (interactive (let ((string |
809 current-prefix-arg | 811 current-prefix-arg |
810 (prefix-numeric-value current-prefix-arg)))) | 812 (prefix-numeric-value current-prefix-arg)))) |
811 (if (and output-buffer | 813 (if (and output-buffer |
812 (not (or (bufferp output-buffer) (stringp output-buffer)))) | 814 (not (or (bufferp output-buffer) (stringp output-buffer)))) |
813 ;; Replace specified region with output from command. | 815 ;; Replace specified region with output from command. |
814 (let ((swap (and interactive (< (point) (mark))))) | 816 (let ((swap (and replace (< (point) (mark))))) |
815 ;; Don't muck with mark | 817 ;; Don't muck with mark |
816 ;; unless called interactively. | 818 ;; unless called interactively. |
817 (and interactive (push-mark)) | 819 (and replace (push-mark)) |
818 (call-process-region start end shell-file-name t t nil | 820 (call-process-region start end shell-file-name t t nil |
819 shell-command-switch command) | 821 shell-command-switch command) |
820 (let ((shell-buffer (get-buffer "*Shell Command Output*"))) | 822 (let ((shell-buffer (get-buffer "*Shell Command Output*"))) |
821 (and shell-buffer (not (eq shell-buffer (current-buffer))) | 823 (and shell-buffer (not (eq shell-buffer (current-buffer))) |
822 (kill-buffer shell-buffer))) | 824 (kill-buffer shell-buffer))) |
823 (and interactive swap (exchange-point-and-mark))) | 825 (and replace swap (exchange-point-and-mark))) |
824 ;; No prefix argument: put the output in a temp buffer, | 826 ;; No prefix argument: put the output in a temp buffer, |
825 ;; replacing its entire contents. | 827 ;; replacing its entire contents. |
826 (let ((buffer (get-buffer-create | 828 (let ((buffer (get-buffer-create |
827 (or output-buffer "*Shell Command Output*"))) | 829 (or output-buffer "*Shell Command Output*"))) |
828 (success nil)) | 830 (success nil)) |