aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell/eshell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/eshell/eshell.el')
-rw-r--r--lisp/eshell/eshell.el50
1 files changed, 16 insertions, 34 deletions
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index 0c1c03941e5..a9a854221a4 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -1,6 +1,6 @@
1;;; eshell.el --- the Emacs command shell 1;;; eshell.el --- the Emacs command shell
2 2
3;; Copyright (C) 1999-2011 Free Software Foundation, Inc. 3;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6;; Version: 2.4.2 6;; Version: 2.4.2
@@ -140,12 +140,12 @@
140;; paragraph wasn't discovered until two months after I wrote the 140;; paragraph wasn't discovered until two months after I wrote the
141;; text; it was not intentional). 141;; text; it was not intentional).
142;; 142;;
143;; @ Emacs' register and bookmarking facilities can be used for 143;; @ Emacs's register and bookmarking facilities can be used for
144;; remembering where you've been, and what you've seen -- to varying 144;; remembering where you've been, and what you've seen -- to varying
145;; levels of persistence. They could perhaps even be tied to 145;; levels of persistence. They could perhaps even be tied to
146;; specific "moments" during eshell execution, which would include 146;; specific "moments" during eshell execution, which would include
147;; the environment at that time, as well as other variables. 147;; the environment at that time, as well as other variables.
148;; Although this would require functionality orthogonal to Emacs' 148;; Although this would require functionality orthogonal to Emacs's
149;; own bookmarking facilities, the interface used could be made to 149;; own bookmarking facilities, the interface used could be made to
150;; operate very similarly. 150;; operate very similarly.
151;; 151;;
@@ -222,36 +222,33 @@
222;; things up. 222;; things up.
223 223
224(eval-when-compile 224(eval-when-compile
225 (require 'cl) 225 (require 'cl-lib)
226 (require 'esh-util)) 226 (require 'esh-util))
227(require 'esh-util) 227(require 'esh-util)
228(require 'esh-mode) 228(require 'esh-mode)
229 229
230(defgroup eshell nil 230(defgroup eshell nil
231 "A command shell implemented entirely in Emacs Lisp. 231 "Command shell implemented entirely in Emacs Lisp.
232It invokes no external processes beyond those requested by the 232It invokes no external processes beyond those requested by the
233user, and is intended to be a functional replacement for command 233user, and is intended to be a functional replacement for command
234shells such as bash, zsh, rc, 4dos." 234shells such as bash, zsh, rc, 4dos."
235 :tag "The Emacs shell"
236 :link '(info-link "(eshell)Top") 235 :link '(info-link "(eshell)Top")
237 :version "21.1" 236 :version "21.1"
238 :group 'applications) 237 :group 'applications)
239 238
240;; This is hack to force make-autoload to put the whole definition
241;; into the autoload file (see esh-module.el).
242(defalias 'eshell-defgroup 'defgroup)
243
244;;;_* User Options 239;;;_* User Options
245;; 240;;
246;; The following user options modify the behavior of Eshell overall. 241;; The following user options modify the behavior of Eshell overall.
247(defvar eshell-buffer-name) 242(defvar eshell-buffer-name)
248 243
249(defsubst eshell-add-to-window-buffer-names () 244(defun eshell-add-to-window-buffer-names ()
250 "Add `eshell-buffer-name' to `same-window-buffer-names'." 245 "Add `eshell-buffer-name' to `same-window-buffer-names'."
246 (declare (obsolete nil "24.3"))
251 (add-to-list 'same-window-buffer-names eshell-buffer-name)) 247 (add-to-list 'same-window-buffer-names eshell-buffer-name))
252 248
253(defsubst eshell-remove-from-window-buffer-names () 249(defun eshell-remove-from-window-buffer-names ()
254 "Remove `eshell-buffer-name' from `same-window-buffer-names'." 250 "Remove `eshell-buffer-name' from `same-window-buffer-names'."
251 (declare (obsolete nil "24.3"))
255 (setq same-window-buffer-names 252 (setq same-window-buffer-names
256 (delete eshell-buffer-name same-window-buffer-names))) 253 (delete eshell-buffer-name same-window-buffer-names)))
257 254
@@ -260,23 +257,13 @@ shells such as bash, zsh, rc, 4dos."
260 :type 'hook 257 :type 'hook
261 :group 'eshell) 258 :group 'eshell)
262 259
263(defcustom eshell-unload-hook 260(defcustom eshell-unload-hook '(eshell-unload-all-modules)
264 '(eshell-remove-from-window-buffer-names
265 eshell-unload-all-modules)
266 "A hook run when Eshell is unloaded from memory." 261 "A hook run when Eshell is unloaded from memory."
267 :type 'hook 262 :type 'hook
268 :group 'eshell) 263 :group 'eshell)
269 264
270(defcustom eshell-buffer-name "*eshell*" 265(defcustom eshell-buffer-name "*eshell*"
271 "The basename used for Eshell buffers." 266 "The basename used for Eshell buffers."
272 :set (lambda (symbol value)
273 ;; remove the old value of `eshell-buffer-name', if present
274 (if (boundp 'eshell-buffer-name)
275 (eshell-remove-from-window-buffer-names))
276 (set symbol value)
277 ;; add the new value
278 (eshell-add-to-window-buffer-names)
279 value)
280 :type 'string 267 :type 'string
281 :group 'eshell) 268 :group 'eshell)
282 269
@@ -303,7 +290,7 @@ switches to the session with that number, creating it if necessary. A
303nonnumeric prefix arg means to create a new session. Returns the 290nonnumeric prefix arg means to create a new session. Returns the
304buffer selected (or created)." 291buffer selected (or created)."
305 (interactive "P") 292 (interactive "P")
306 (assert eshell-buffer-name) 293 (cl-assert eshell-buffer-name)
307 (let ((buf (cond ((numberp arg) 294 (let ((buf (cond ((numberp arg)
308 (get-buffer-create (format "%s<%d>" 295 (get-buffer-create (format "%s<%d>"
309 eshell-buffer-name 296 eshell-buffer-name
@@ -312,13 +299,8 @@ buffer selected (or created)."
312 (generate-new-buffer eshell-buffer-name)) 299 (generate-new-buffer eshell-buffer-name))
313 (t 300 (t
314 (get-buffer-create eshell-buffer-name))))) 301 (get-buffer-create eshell-buffer-name)))))
315 ;; Simply calling `pop-to-buffer' will not mimic the way that 302 (cl-assert (and buf (buffer-live-p buf)))
316 ;; shell-mode buffers appear, since they always reuse the same 303 (pop-to-buffer-same-window buf)
317 ;; window that that command was invoked from. To achieve this,
318 ;; it's necessary to add `eshell-buffer-name' to the variable
319 ;; `same-window-buffer-names', which is done when Eshell is loaded
320 (assert (and buf (buffer-live-p buf)))
321 (pop-to-buffer buf)
322 (unless (eq major-mode 'eshell-mode) 304 (unless (eq major-mode 'eshell-mode)
323 (eshell-mode)) 305 (eshell-mode))
324 buf)) 306 buf))
@@ -385,11 +367,11 @@ With prefix ARG, insert output into the current buffer at point."
385 (when intr 367 (when intr
386 (if (eshell-interactive-process) 368 (if (eshell-interactive-process)
387 (eshell-wait-for-process (eshell-interactive-process))) 369 (eshell-wait-for-process (eshell-interactive-process)))
388 (assert (not (eshell-interactive-process))) 370 (cl-assert (not (eshell-interactive-process)))
389 (goto-char (point-max)) 371 (goto-char (point-max))
390 (while (and (bolp) (not (bobp))) 372 (while (and (bolp) (not (bobp)))
391 (delete-char -1))) 373 (delete-char -1)))
392 (assert (and buf (buffer-live-p buf))) 374 (cl-assert (and buf (buffer-live-p buf)))
393 (unless arg 375 (unless arg
394 (let ((len (if (not intr) 2 376 (let ((len (if (not intr) 2
395 (count-lines (point-min) (point-max))))) 377 (count-lines (point-min) (point-max)))))
@@ -429,7 +411,7 @@ corresponding to a successful execution."
429 (list 'eshell-commands 411 (list 'eshell-commands
430 (list 'eshell-command-to-value 412 (list 'eshell-command-to-value
431 (eshell-parse-command command))) t))) 413 (eshell-parse-command command))) t)))
432 (assert (eq (car result) 'quote)) 414 (cl-assert (eq (car result) 'quote))
433 (if (and status-var (symbolp status-var)) 415 (if (and status-var (symbolp status-var))
434 (set status-var eshell-last-command-status)) 416 (set status-var eshell-last-command-status))
435 (cadr result)))))) 417 (cadr result))))))