Mercurial > emacs
comparison lisp/simple.el @ 12838:7e28ff12e682
(shell-command-on-region): Don't examine order of
point and mark; use order of START and END instead.
Interactively pass point and mark, not region-beg and region-end.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 12 Aug 1995 09:22:04 +0000 |
parents | 6ee52fbbee75 |
children | 3ae9326907aa |
comparison
equal
deleted
inserted
replaced
12837:9b1559218458 | 12838:7e28ff12e682 |
---|---|
845 ;; and region-end, in case subprocess output | 845 ;; and region-end, in case subprocess output |
846 ;; relocates them while we are in the minibuffer. | 846 ;; relocates them while we are in the minibuffer. |
847 (read-from-minibuffer "Shell command on region: " | 847 (read-from-minibuffer "Shell command on region: " |
848 nil nil nil | 848 nil nil nil |
849 'shell-command-history))) | 849 'shell-command-history))) |
850 (list (region-beginning) (region-end) | 850 (list (point) (mark) |
851 string | 851 string |
852 current-prefix-arg | 852 current-prefix-arg |
853 current-prefix-arg))) | 853 current-prefix-arg))) |
854 (if (or replace | 854 (if (or replace |
855 (and output-buffer | 855 (and output-buffer |
856 (not (or (bufferp output-buffer) (stringp output-buffer))))) | 856 (not (or (bufferp output-buffer) (stringp output-buffer))))) |
857 ;; Replace specified region with output from command. | 857 ;; Replace specified region with output from command. |
858 (let ((swap (and replace (< (point) (mark))))) | 858 (let ((swap (and replace (< start end)))) |
859 ;; Don't muck with mark unless REPLACE says we should. | 859 ;; Don't muck with mark unless REPLACE says we should. |
860 (goto-char start) | 860 (goto-char start) |
861 (and replace (push-mark)) | 861 (and replace (push-mark)) |
862 (call-process-region start end shell-file-name t t nil | 862 (call-process-region start end shell-file-name t t nil |
863 shell-command-switch command) | 863 shell-command-switch command) |
875 (if (eq buffer (current-buffer)) | 875 (if (eq buffer (current-buffer)) |
876 ;; If the input is the same buffer as the output, | 876 ;; If the input is the same buffer as the output, |
877 ;; delete everything but the specified region, | 877 ;; delete everything but the specified region, |
878 ;; then replace that region with the output. | 878 ;; then replace that region with the output. |
879 (progn (setq buffer-read-only nil) | 879 (progn (setq buffer-read-only nil) |
880 (delete-region end (point-max)) | 880 (delete-region (max start end) (point-max)) |
881 (delete-region (point-min) start) | 881 (delete-region (point-min) (max start end)) |
882 (call-process-region (point-min) (point-max) | 882 (call-process-region (point-min) (point-max) |
883 shell-file-name t t nil | 883 shell-file-name t t nil |
884 shell-command-switch command) | 884 shell-command-switch command) |
885 (setq success t)) | 885 (setq success t)) |
886 ;; Clear the output buffer, then run the command with output there. | 886 ;; Clear the output buffer, then run the command with output there. |