Add arch taglines
[bpt/emacs.git] / lisp / eshell / eshell.el
index 4cccc7a..e76bcb1 100644 (file)
@@ -1,4 +1,4 @@
-;;; eshell --- the Emacs command shell
+;;; eshell.el --- the Emacs command shell
 
 ;; Copyright (C) 1999, 2000 Free Software Foundation
 
@@ -64,7 +64,7 @@ the tasks accomplished by such tools."
 ;; @ Command argument completion (tcsh, zsh)
 ;; @ Input history management (bash)
 ;; @ Intelligent output scrolling
-;; @ Psuedo-devices (such as "/dev/clip" for copying to the clipboard)
+;; @ Pseudo-devices (such as "/dev/clip" for copying to the clipboard)
 ;; @ Extended globbing (zsh)
 ;; @ Argument and globbing predication (zsh)
 ;; @ I/O redirection to buffers, files, symbols, processes, etc.
@@ -352,13 +352,20 @@ the tasks accomplished by such tools."
 The buffer used for Eshell sessions is determined by the value of
 `eshell-buffer-name'.  If there is already an Eshell session active in
 that buffer, Emacs will simply switch to it.  Otherwise, a new session
-will begin.  A new session is always created if the the prefix
-argument ARG is specified.  Returns the buffer selected (or created)."
+will begin.  A numeric prefix arg (as in `C-u 42 M-x eshell RET')
+switches to the session with that number, creating it if necessary.  A
+nonnumeric prefix arg means to create a new session.  Returns the
+buffer selected (or created)."
   (interactive "P")
   (assert eshell-buffer-name)
-  (let ((buf (if arg
-                (generate-new-buffer eshell-buffer-name)
-              (get-buffer-create eshell-buffer-name))))
+  (let ((buf (cond ((numberp arg)
+                   (get-buffer-create (format "%s<%d>"
+                                              eshell-buffer-name
+                                              arg)))
+                  (arg
+                   (generate-new-buffer eshell-buffer-name))
+                  (t
+                   (get-buffer-create eshell-buffer-name)))))
     ;; Simply calling `pop-to-buffer' will not mimic the way that
     ;; shell-mode buffers appear, since they always reuse the same
     ;; window that that command was invoked from.  To achieve this,
@@ -397,10 +404,12 @@ With prefix ARG, insert output into the current buffer at point."
   (unwind-protect
       (let ((eshell-non-interactive-p t))
        (add-hook 'minibuffer-setup-hook 'eshell-mode)
+       (add-hook 'minibuffer-exit-hook 'eshell-add-command-to-history)
        (add-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
        (unless command
          (setq command (read-from-minibuffer "Emacs shell command: "))))
     (remove-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
+    (remove-hook 'minibuffer-exit-hook 'eshell-add-command-to-history)
     (remove-hook 'minibuffer-setup-hook 'eshell-mode))
   (unless command
     (error "No command specified!"))
@@ -552,4 +561,5 @@ Emacs."
 
 (run-hooks 'eshell-load-hook)
 
+;;; arch-tag: 9d4d5214-0e4e-4e02-b349-39add640d63f
 ;;; eshell.el ends here