changeset 37436:33a9a90f3e76

(eshell-command): Made a few changes so that `eshell-command' could be called programmatically. (eshell-non-interactive-p): Moved this variable here.
author John Wiegley <johnw@newartisans.com>
date Tue, 24 Apr 2001 01:37:31 +0000
parents dac074fd9cac
children ed485de91fcf
files lisp/eshell/eshell.el
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/eshell/eshell.el	Tue Apr 24 01:37:08 2001 +0000
+++ b/lisp/eshell/eshell.el	Tue Apr 24 01:37:31 2001 +0000
@@ -328,18 +328,25 @@
   (define-key eshell-mode-map [(meta return)] 'exit-minibuffer)
   (define-key eshell-mode-map [(meta control ?m)] 'exit-minibuffer))
 
+(defvar eshell-non-interactive-p nil
+  "A variable which is non-nil when Eshell is not running interactively.
+Modules should use this variable so that they don't clutter
+non-interactive sessions, such as when using `eshell-command'.")
+
 ;;;###autoload
 (defun eshell-command (&optional command arg)
   "Execute the Eshell command string COMMAND.
 With prefix ARG, insert output into the current buffer at point."
   (interactive)
   (require 'esh-cmd)
-  (setq arg current-prefix-arg)
+  (unless arg
+    (setq arg current-prefix-arg))
   (unwind-protect
       (let ((eshell-non-interactive-p t))
 	(add-hook 'minibuffer-setup-hook 'eshell-mode)
 	(add-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
-	(setq command (read-from-minibuffer "Emacs shell command: ")))
+	(unless command
+	  (setq command (read-from-minibuffer "Emacs shell command: "))))
     (remove-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
     (remove-hook 'minibuffer-setup-hook 'eshell-mode))
   (unless command