comparison lisp/simple.el @ 4488:b0a70d8d9af4

(shell-command, shell-command-on-region): Fix bugs in previous change.
author Richard M. Stallman <rms@gnu.org>
date Sun, 08 Aug 1993 07:47:33 +0000
parents 7101a887f80d
children db555f6edd6b
comparison
equal deleted inserted replaced
4487:177aaa70734d 4488:b0a70d8d9af4
628 then call `undo-more' one or more times to undo them." 628 then call `undo-more' one or more times to undo them."
629 (or pending-undo-list 629 (or pending-undo-list
630 (error "No further undo information")) 630 (error "No further undo information"))
631 (setq pending-undo-list (primitive-undo count pending-undo-list))) 631 (setq pending-undo-list (primitive-undo count pending-undo-list)))
632 632
633 (defvar last-shell-command "")
634 (defvar last-shell-command-on-region "")
635
636 (defvar shell-command-history nil 633 (defvar shell-command-history nil
637 "History list for some commands that read shell commands.") 634 "History list for some commands that read shell commands.")
638 635
639 (defun shell-command (command &optional flag) 636 (defun shell-command (command &optional flag)
640 "Execute string COMMAND in inferior shell; display output, if any. 637 "Execute string COMMAND in inferior shell; display output, if any.
641 If COMMAND ends in ampersand, execute it asynchronously. 638 If COMMAND ends in ampersand, execute it asynchronously.
642 639
643 Optional second arg non-nil (prefix arg, if interactive) 640 Optional second arg non-nil (prefix arg, if interactive)
644 means insert output in current buffer after point (leave mark after it). 641 means insert output in current buffer after point (leave mark after it).
645 This cannot be done asynchronously." 642 This cannot be done asynchronously."
646 (interactive (list (read-string "Shell command: " last-shell-command) 643 (interactive (list (read-from-minibuffer "Shell command: "
647 current-prefix-arg nil nil 'shell-command-history)) 644 nil nil nil 'shell-command-history)
645 current-prefix-arg))
648 (if flag 646 (if flag
649 (progn (barf-if-buffer-read-only) 647 (progn (barf-if-buffer-read-only)
650 (push-mark) 648 (push-mark)
651 ;; We do not use -f for csh; we will not support broken use of 649 ;; We do not use -f for csh; we will not support broken use of
652 ;; .cshrcs. Even the BSD csh manual says to use 650 ;; .cshrcs. Even the BSD csh manual says to use
736 but it is nonetheless available in buffer `*Shell Command Output*' 734 but it is nonetheless available in buffer `*Shell Command Output*'
737 even though that buffer is not automatically displayed. If there is no output 735 even though that buffer is not automatically displayed. If there is no output
738 or output is inserted in the current buffer then `*Shell Command Output*' is 736 or output is inserted in the current buffer then `*Shell Command Output*' is
739 deleted." 737 deleted."
740 (interactive (list (region-beginning) (region-end) 738 (interactive (list (region-beginning) (region-end)
741 (read-string "Shell command on region: " 739 (read-from-minibuffer "Shell command on region: "
742 last-shell-command-on-region 740 nil nil nil 'shell-command-history)
743 nil nil 'shell-command-history)
744 current-prefix-arg 741 current-prefix-arg
745 (prefix-numeric-value current-prefix-arg))) 742 (prefix-numeric-value current-prefix-arg)))
746 (if flag 743 (if flag
747 ;; Replace specified region with output from command. 744 ;; Replace specified region with output from command.
748 (let ((swap (and interactive (< (point) (mark))))) 745 (let ((swap (and interactive (< (point) (mark)))))