]> git.eshelyaron.com Git - emacs.git/commitdiff
(eshell-command): Made a few changes so that `eshell-command' could be
authorJohn Wiegley <johnw@newartisans.com>
Tue, 24 Apr 2001 01:37:31 +0000 (01:37 +0000)
committerJohn Wiegley <johnw@newartisans.com>
Tue, 24 Apr 2001 01:37:31 +0000 (01:37 +0000)
called programmatically.
(eshell-non-interactive-p): Moved this variable here.

lisp/eshell/eshell.el

index 4f682b5a314ecb41fa7b9951ddaa6fbfc4437777..8e30d5de48dbc4163239263d43810dc1703a918e 100644 (file)
@@ -328,18 +328,25 @@ argument ARG is specified.  Returns the buffer selected (or created)."
   (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