aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorPaul Eggert2011-03-05 23:53:03 -0800
committerPaul Eggert2011-03-05 23:53:03 -0800
commit58635e4de85621d4f16befe15b1df44a637bd078 (patch)
treeb5dc80332d5912ba795e59ee86cea1527324709e /lisp/eshell
parent5489860be109ec6fa2a7d143cdecb6887e37f5d5 (diff)
parent555e9b5c69d70acca13310fbe533594a8f1eab98 (diff)
downloademacs-58635e4de85621d4f16befe15b1df44a637bd078.tar.gz
emacs-58635e4de85621d4f16befe15b1df44a637bd078.zip
Merge from mainline.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/em-alias.el7
-rw-r--r--lisp/eshell/em-banner.el11
-rw-r--r--lisp/eshell/em-cmpl.el3
-rw-r--r--lisp/eshell/em-dirs.el5
-rw-r--r--lisp/eshell/em-glob.el3
-rw-r--r--lisp/eshell/em-hist.el7
-rw-r--r--lisp/eshell/em-ls.el12
-rw-r--r--lisp/eshell/em-pred.el3
-rw-r--r--lisp/eshell/em-prompt.el3
-rw-r--r--lisp/eshell/em-rebind.el3
-rw-r--r--lisp/eshell/em-script.el3
-rw-r--r--lisp/eshell/em-smart.el3
-rw-r--r--lisp/eshell/em-term.el3
-rw-r--r--lisp/eshell/em-unix.el13
-rw-r--r--lisp/eshell/esh-arg.el3
-rw-r--r--lisp/eshell/esh-cmd.el45
-rw-r--r--lisp/eshell/esh-ext.el5
-rw-r--r--lisp/eshell/esh-io.el3
-rw-r--r--lisp/eshell/esh-mode.el114
-rw-r--r--lisp/eshell/esh-module.el6
-rw-r--r--lisp/eshell/esh-proc.el34
-rw-r--r--lisp/eshell/esh-test.el233
-rw-r--r--lisp/eshell/esh-util.el19
-rw-r--r--lisp/eshell/esh-var.el35
-rw-r--r--lisp/eshell/eshell.el20
25 files changed, 112 insertions, 484 deletions
diff --git a/lisp/eshell/em-alias.el b/lisp/eshell/em-alias.el
index aa138cb4dcb..4e1dbd41045 100644
--- a/lisp/eshell/em-alias.el
+++ b/lisp/eshell/em-alias.el
@@ -117,8 +117,9 @@ gained by using this module."
117 ;; :link '(custom-manual "(eshell)Auto-correction of bad commands") 117 ;; :link '(custom-manual "(eshell)Auto-correction of bad commands")
118 :group 'eshell-alias) 118 :group 'eshell-alias)
119 119
120(defcustom eshell-alias-load-hook '(eshell-alias-initialize) 120(defcustom eshell-alias-load-hook nil
121 "A hook that gets run when `eshell-alias' is loaded." 121 "A hook that gets run when `eshell-alias' is loaded."
122 :version "24.1" ; removed eshell-alias-initialize
122 :type 'hook 123 :type 'hook
123 :group 'eshell-alias) 124 :group 'eshell-alias)
124 125
@@ -156,7 +157,7 @@ command, which will automatically write them to the file named by
156(defun eshell/alias (&optional alias &rest definition) 157(defun eshell/alias (&optional alias &rest definition)
157 "Define an ALIAS in the user's alias list using DEFINITION." 158 "Define an ALIAS in the user's alias list using DEFINITION."
158 (if (not alias) 159 (if (not alias)
159 (eshell-for alias eshell-command-aliases-list 160 (dolist (alias eshell-command-aliases-list)
160 (eshell-print (apply 'format "alias %s %s\n" alias))) 161 (eshell-print (apply 'format "alias %s %s\n" alias)))
161 (if (not definition) 162 (if (not definition)
162 (setq eshell-command-aliases-list 163 (setq eshell-command-aliases-list
@@ -238,7 +239,7 @@ command, which will automatically write them to the file named by
238 "Find all possible completions for NAME. 239 "Find all possible completions for NAME.
239These are all the command aliases which begin with NAME." 240These are all the command aliases which begin with NAME."
240 (let (completions) 241 (let (completions)
241 (eshell-for alias eshell-command-aliases-list 242 (dolist (alias eshell-command-aliases-list)
242 (if (string-match (concat "^" name) (car alias)) 243 (if (string-match (concat "^" name) (car alias))
243 (setq completions (cons (car alias) completions)))) 244 (setq completions (cons (car alias) completions))))
244 completions)) 245 completions))
diff --git a/lisp/eshell/em-banner.el b/lisp/eshell/em-banner.el
index b2ebde98cee..ce987f132e3 100644
--- a/lisp/eshell/em-banner.el
+++ b/lisp/eshell/em-banner.el
@@ -64,8 +64,9 @@ This can be any sexp, and should end with at least two newlines."
64 64
65(put 'eshell-banner-message 'risky-local-variable t) 65(put 'eshell-banner-message 'risky-local-variable t)
66 66
67(defcustom eshell-banner-load-hook '(eshell-banner-initialize) 67(defcustom eshell-banner-load-hook nil
68 "A list of functions to run when `eshell-banner' is loaded." 68 "A list of functions to run when `eshell-banner' is loaded."
69 :version "24.1" ; removed eshell-banner-initialize
69 :type 'hook 70 :type 'hook
70 :group 'eshell-banner) 71 :group 'eshell-banner)
71 72
@@ -81,14 +82,6 @@ This can be any sexp, and should end with at least two newlines."
81 (assert msg) 82 (assert msg)
82 (eshell-interactive-print msg)))) 83 (eshell-interactive-print msg))))
83 84
84(eshell-deftest banner banner-displayed
85 "Startup banner is displayed at point-min"
86 (assert eshell-banner-message)
87 (let ((msg (eval eshell-banner-message)))
88 (assert msg)
89 (goto-char (point-min))
90 (looking-at msg)))
91
92(provide 'em-banner) 85(provide 'em-banner)
93 86
94;; Local Variables: 87;; Local Variables:
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index f3f104c1ede..c551684210c 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -84,8 +84,9 @@ variable names, arguments, etc."
84 84
85;;; User Variables: 85;;; User Variables:
86 86
87(defcustom eshell-cmpl-load-hook '(eshell-cmpl-initialize) 87(defcustom eshell-cmpl-load-hook nil
88 "A list of functions to run when `eshell-cmpl' is loaded." 88 "A list of functions to run when `eshell-cmpl' is loaded."
89 :version "24.1" ; removed eshell-cmpl-initialize
89 :type 'hook 90 :type 'hook
90 :group 'eshell-cmpl) 91 :group 'eshell-cmpl)
91 92
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 64555ab15ef..1aa2c34c395 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -58,8 +58,9 @@ they lack somewhat in feel from the typical shell equivalents."
58 58
59;;; User Variables: 59;;; User Variables:
60 60
61(defcustom eshell-dirs-load-hook '(eshell-dirs-initialize) 61(defcustom eshell-dirs-load-hook nil
62 "A hook that gets run when `eshell-dirs' is loaded." 62 "A hook that gets run when `eshell-dirs' is loaded."
63 :version "24.1" ; removed eshell-dirs-initialize
63 :type 'hook 64 :type 'hook
64 :group 'eshell-dirs) 65 :group 'eshell-dirs)
65 66
@@ -233,7 +234,7 @@ Thus, this does not include the current directory.")
233 234
234(defun eshell-save-some-last-dir () 235(defun eshell-save-some-last-dir ()
235 "Save the list-dir-ring for any open Eshell buffers." 236 "Save the list-dir-ring for any open Eshell buffers."
236 (eshell-for buf (buffer-list) 237 (dolist (buf (buffer-list))
237 (if (buffer-live-p buf) 238 (if (buffer-live-p buf)
238 (with-current-buffer buf 239 (with-current-buffer buf
239 (if (and eshell-mode 240 (if (and eshell-mode
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el
index 2a565c5c827..732c6c05bfe 100644
--- a/lisp/eshell/em-glob.el
+++ b/lisp/eshell/em-glob.el
@@ -61,8 +61,9 @@ by zsh for filename generation."
61 61
62;;; User Variables: 62;;; User Variables:
63 63
64(defcustom eshell-glob-load-hook '(eshell-glob-initialize) 64(defcustom eshell-glob-load-hook nil
65 "A list of functions to run when `eshell-glob' is loaded." 65 "A list of functions to run when `eshell-glob' is loaded."
66 :version "24.1" ; removed eshell-glob-initialize
66 :type 'hook 67 :type 'hook
67 :group 'eshell-glob) 68 :group 'eshell-glob)
68 69
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 5ec529f4b8f..993e9d63a94 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -70,8 +70,9 @@
70 70
71;;; User Variables: 71;;; User Variables:
72 72
73(defcustom eshell-hist-load-hook '(eshell-hist-initialize) 73(defcustom eshell-hist-load-hook nil
74 "A list of functions to call when loading `eshell-hist'." 74 "A list of functions to call when loading `eshell-hist'."
75 :version "24.1" ; removed eshell-hist-initialize
75 :type 'hook 76 :type 'hook
76 :group 'eshell-hist) 77 :group 'eshell-hist)
77 78
@@ -292,7 +293,7 @@ element, regardless of any text on the command line. In that case,
292 293
293(defun eshell-save-some-history () 294(defun eshell-save-some-history ()
294 "Save the history for any open Eshell buffers." 295 "Save the history for any open Eshell buffers."
295 (eshell-for buf (buffer-list) 296 (dolist (buf (buffer-list))
296 (if (buffer-live-p buf) 297 (if (buffer-live-p buf)
297 (with-current-buffer buf 298 (with-current-buffer buf
298 (if (and eshell-mode 299 (if (and eshell-mode
@@ -730,7 +731,7 @@ matched."
730 (narrow-to-region here (point)) 731 (narrow-to-region here (point))
731 (goto-char (point-min)) 732 (goto-char (point-min))
732 (let ((modifiers (cdr (eshell-parse-modifiers)))) 733 (let ((modifiers (cdr (eshell-parse-modifiers))))
733 (eshell-for mod modifiers 734 (dolist (mod modifiers)
734 (setq hist (funcall mod hist))) 735 (setq hist (funcall mod hist)))
735 hist)) 736 hist))
736 (delete-region here (point))))) 737 (delete-region here (point)))))
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 7714629f2fa..4ef259dee4b 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -561,7 +561,7 @@ relative to that directory."
561 (when (or (eq listing-style 'long-listing) show-size) 561 (when (or (eq listing-style 'long-listing) show-size)
562 (let ((total 0.0)) 562 (let ((total 0.0))
563 (setq size-width 0) 563 (setq size-width 0)
564 (eshell-for e entries 564 (dolist (e entries)
565 (if (nth 7 (cdr e)) 565 (if (nth 7 (cdr e))
566 (setq total (+ total (nth 7 (cdr e))) 566 (setq total (+ total (nth 7 (cdr e)))
567 size-width 567 size-width
@@ -651,7 +651,7 @@ Each member of FILES is either a string or a cons cell of the form
651 (not (eq eshell-in-pipeline-p 'last)) 651 (not (eq eshell-in-pipeline-p 'last))
652 (not (eq listing-style 'by-lines))) 652 (not (eq listing-style 'by-lines)))
653 (memq listing-style '(long-listing single-column))) 653 (memq listing-style '(long-listing single-column)))
654 (eshell-for file files 654 (dolist (file files)
655 (if file 655 (if file
656 (eshell-ls-file file size-width copy-fileinfo))) 656 (eshell-ls-file file size-width copy-fileinfo)))
657 (let ((f files) 657 (let ((f files)
@@ -676,7 +676,7 @@ Each member of FILES is either a string or a cons cell of the form
676 (setcdr f (cddr f)))))) 676 (setcdr f (cddr f))))))
677 (if (not show-size) 677 (if (not show-size)
678 (setq display-files (mapcar 'eshell-ls-annotate files)) 678 (setq display-files (mapcar 'eshell-ls-annotate files))
679 (eshell-for file files 679 (dolist (file files)
680 (let* ((str (eshell-ls-printable-size (nth 7 (cdr file)) t)) 680 (let* ((str (eshell-ls-printable-size (nth 7 (cdr file)) t))
681 (len (length str))) 681 (len (length str)))
682 (if (< len size-width) 682 (if (< len size-width)
@@ -696,7 +696,7 @@ Each member of FILES is either a string or a cons cell of the form
696 (columns (length col-widths)) 696 (columns (length col-widths))
697 (col-index 1) 697 (col-index 1)
698 need-return) 698 need-return)
699 (eshell-for file display-files 699 (dolist (file display-files)
700 (let ((name 700 (let ((name
701 (if (car file) 701 (if (car file)
702 (if show-size 702 (if show-size
@@ -731,7 +731,7 @@ ROOT-DIR, if non-nil, specifies the root directory of the listing, to
731which non-absolute directory names will be made relative if ever they 731which non-absolute directory names will be made relative if ever they
732need to be printed." 732need to be printed."
733 (let (dirs files show-names need-return (size-width 0)) 733 (let (dirs files show-names need-return (size-width 0))
734 (eshell-for entry entries 734 (dolist (entry entries)
735 (if (and (not dir-literal) 735 (if (and (not dir-literal)
736 (or (eshell-ls-filetype-p (cdr entry) ?d) 736 (or (eshell-ls-filetype-p (cdr entry) ?d)
737 (and (eshell-ls-filetype-p (cdr entry) ?l) 737 (and (eshell-ls-filetype-p (cdr entry) ?l)
@@ -757,7 +757,7 @@ need to be printed."
757 (setq need-return t)) 757 (setq need-return t))
758 (setq show-names (or show-recursive 758 (setq show-names (or show-recursive
759 (> (+ (length files) (length dirs)) 1))) 759 (> (+ (length files) (length dirs)) 1)))
760 (eshell-for dir (eshell-ls-sort-entries dirs) 760 (dolist (dir (eshell-ls-sort-entries dirs))
761 (if (and need-return (not dir-literal)) 761 (if (and need-return (not dir-literal))
762 (funcall insert-func "\n")) 762 (funcall insert-func "\n"))
763 (eshell-ls-dir dir show-names 763 (eshell-ls-dir dir show-names
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index 33085c067fd..f3027ea9b5e 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -59,8 +59,9 @@ ordinary strings."
59 59
60;;; User Variables: 60;;; User Variables:
61 61
62(defcustom eshell-pred-load-hook '(eshell-pred-initialize) 62(defcustom eshell-pred-load-hook nil
63 "A list of functions to run when `eshell-pred' is loaded." 63 "A list of functions to run when `eshell-pred' is loaded."
64 :version "24.1" ; removed eshell-pred-initialize
64 :type 'hook 65 :type 'hook
65 :group 'eshell-pred) 66 :group 'eshell-pred)
66 67
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index 448d2cdf303..3e87acc6d1e 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -37,8 +37,9 @@ as is common with most shells."
37 37
38;;; User Variables: 38;;; User Variables:
39 39
40(defcustom eshell-prompt-load-hook '(eshell-prompt-initialize) 40(defcustom eshell-prompt-load-hook nil
41 "A list of functions to call when loading `eshell-prompt'." 41 "A list of functions to call when loading `eshell-prompt'."
42 :version "24.1" ; removed eshell-prompt-initialize
42 :type 'hook 43 :type 'hook
43 :group 'eshell-prompt) 44 :group 'eshell-prompt)
44 45
diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el
index 6def23e1b71..2c346dfcd3d 100644
--- a/lisp/eshell/em-rebind.el
+++ b/lisp/eshell/em-rebind.el
@@ -41,8 +41,9 @@ the behavior of normal shells while the user editing new input text."
41 41
42;;; User Variables: 42;;; User Variables:
43 43
44(defcustom eshell-rebind-load-hook '(eshell-rebind-initialize) 44(defcustom eshell-rebind-load-hook nil
45 "A list of functions to call when loading `eshell-rebind'." 45 "A list of functions to call when loading `eshell-rebind'."
46 :version "24.1" ; removed eshell-rebind-initialize
46 :type 'hook 47 :type 'hook
47 :group 'eshell-rebind) 48 :group 'eshell-rebind)
48 49
diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el
index ed4ad1c0712..d76e19cdd07 100644
--- a/lisp/eshell/em-script.el
+++ b/lisp/eshell/em-script.el
@@ -34,8 +34,9 @@ commands, as a script file."
34 34
35;;; User Variables: 35;;; User Variables:
36 36
37(defcustom eshell-script-load-hook '(eshell-script-initialize) 37(defcustom eshell-script-load-hook nil
38 "A list of functions to call when loading `eshell-script'." 38 "A list of functions to call when loading `eshell-script'."
39 :version "24.1" ; removed eshell-script-initialize
39 :type 'hook 40 :type 'hook
40 :group 'eshell-script) 41 :group 'eshell-script)
41 42
diff --git a/lisp/eshell/em-smart.el b/lisp/eshell/em-smart.el
index 2c54930e439..f08fec8f8fa 100644
--- a/lisp/eshell/em-smart.el
+++ b/lisp/eshell/em-smart.el
@@ -84,8 +84,9 @@ it to get a real sense of how it works."
84 84
85;;; User Variables: 85;;; User Variables:
86 86
87(defcustom eshell-smart-load-hook '(eshell-smart-initialize) 87(defcustom eshell-smart-load-hook nil
88 "A list of functions to call when loading `eshell-smart'." 88 "A list of functions to call when loading `eshell-smart'."
89 :version "24.1" ; removed eshell-smart-initialize
89 :type 'hook 90 :type 'hook
90 :group 'eshell-smart) 91 :group 'eshell-smart)
91 92
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el
index be394ba5b22..7d5fbbeabeb 100644
--- a/lisp/eshell/em-term.el
+++ b/lisp/eshell/em-term.el
@@ -46,8 +46,9 @@ which commands are considered visual in nature."
46 46
47;;; User Variables: 47;;; User Variables:
48 48
49(defcustom eshell-term-load-hook '(eshell-term-initialize) 49(defcustom eshell-term-load-hook nil
50 "A list of functions to call when loading `eshell-term'." 50 "A list of functions to call when loading `eshell-term'."
51 :version "24.1" ; removed eshell-term-initialize
51 :type 'hook 52 :type 'hook
52 :group 'eshell-term) 53 :group 'eshell-term)
53 54
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index dc5650d240e..707f2ebc2ce 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -53,8 +53,9 @@ by name)."
53 :tag "UNIX commands in Lisp" 53 :tag "UNIX commands in Lisp"
54 :group 'eshell-module) 54 :group 'eshell-module)
55 55
56(defcustom eshell-unix-load-hook '(eshell-unix-initialize) 56(defcustom eshell-unix-load-hook nil
57 "A list of functions to run when `eshell-unix' is loaded." 57 "A list of functions to run when `eshell-unix' is loaded."
58 :version "24.1" ; removed eshell-unix-initialize
58 :type 'hook 59 :type 'hook
59 :group 'eshell-unix) 60 :group 'eshell-unix)
60 61
@@ -587,7 +588,7 @@ symlink, then revert to the system's definition of cat."
587 (setq args (eshell-stringify-list (eshell-flatten-list args))) 588 (setq args (eshell-stringify-list (eshell-flatten-list args)))
588 (if (or eshell-in-pipeline-p 589 (if (or eshell-in-pipeline-p
589 (catch 'special 590 (catch 'special
590 (eshell-for arg args 591 (dolist (arg args)
591 (unless (or (and (stringp arg) 592 (unless (or (and (stringp arg)
592 (> (length arg) 0) 593 (> (length arg) 0)
593 (eq (aref arg 0) ?-)) 594 (eq (aref arg 0) ?-))
@@ -610,12 +611,12 @@ symlink, then revert to the system's definition of cat."
610 :show-usage 611 :show-usage
611 :usage "[OPTION] FILE... 612 :usage "[OPTION] FILE...
612Concatenate FILE(s), or standard input, to standard output.") 613Concatenate FILE(s), or standard input, to standard output.")
613 (eshell-for file args 614 (dolist (file args)
614 (if (string= file "-") 615 (if (string= file "-")
615 (throw 'eshell-external 616 (throw 'eshell-external
616 (eshell-external-command "cat" args)))) 617 (eshell-external-command "cat" args))))
617 (let ((curbuf (current-buffer))) 618 (let ((curbuf (current-buffer)))
618 (eshell-for file args 619 (dolist (file args)
619 (with-temp-buffer 620 (with-temp-buffer
620 (insert-file-contents file) 621 (insert-file-contents file)
621 (goto-char (point-min)) 622 (goto-char (point-min))
@@ -851,7 +852,7 @@ external command."
851 (let ((ext-du (eshell-search-path "du"))) 852 (let ((ext-du (eshell-search-path "du")))
852 (if (and ext-du 853 (if (and ext-du
853 (not (catch 'have-ange-path 854 (not (catch 'have-ange-path
854 (eshell-for arg args 855 (dolist (arg args)
855 (if (string-equal 856 (if (string-equal
856 (file-remote-p (expand-file-name arg) 'method) "ftp") 857 (file-remote-p (expand-file-name arg) 'method) "ftp")
857 (throw 'have-ange-path t)))))) 858 (throw 'have-ange-path t))))))
@@ -1055,7 +1056,7 @@ Become another USER during a login session.")
1055 "localhost")) 1056 "localhost"))
1056 (dir (or (file-remote-p default-directory 'localname) 1057 (dir (or (file-remote-p default-directory 'localname)
1057 (expand-file-name default-directory)))) 1058 (expand-file-name default-directory))))
1058 (eshell-for arg args 1059 (dolist (arg args)
1059 (if (string-equal arg "-") (setq login t) (setq user arg))) 1060 (if (string-equal arg "-") (setq login t) (setq user arg)))
1060 ;; `eshell-eval-using-options' does not handle "-". 1061 ;; `eshell-eval-using-options' does not handle "-".
1061 (if (member "-" orig-args) (setq login t)) 1062 (if (member "-" orig-args) (setq login t))
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index f42440ae4ec..1fb8b7f4c32 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -117,8 +117,9 @@ treated as a literal character."
117 117
118;;; User Variables: 118;;; User Variables:
119 119
120(defcustom eshell-arg-load-hook '(eshell-arg-initialize) 120(defcustom eshell-arg-load-hook nil
121 "A hook that gets run when `eshell-arg' is loaded." 121 "A hook that gets run when `eshell-arg' is loaded."
122 :version "24.1" ; removed eshell-arg-initialize
122 :type 'hook 123 :type 'hook
123 :group 'eshell-arg) 124 :group 'eshell-arg)
124 125
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 0567beb9a53..bdcdc453272 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -229,8 +229,9 @@ return non-nil if the command is complex."
229 229
230;;; User Variables: 230;;; User Variables:
231 231
232(defcustom eshell-cmd-load-hook '(eshell-cmd-initialize) 232(defcustom eshell-cmd-load-hook nil
233 "A hook that gets run when `eshell-cmd' is loaded." 233 "A hook that gets run when `eshell-cmd' is loaded."
234 :version "24.1" ; removed eshell-cmd-initialize
234 :type 'hook 235 :type 'hook
235 :group 'eshell-cmd) 236 :group 'eshell-cmd)
236 237
@@ -319,18 +320,6 @@ otherwise t.")
319 (add-hook 'pcomplete-try-first-hook 320 (add-hook 'pcomplete-try-first-hook
320 'eshell-complete-lisp-symbols nil t))) 321 'eshell-complete-lisp-symbols nil t)))
321 322
322(eshell-deftest var last-result-var
323 "\"last result\" variable"
324 (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n"))
325
326(eshell-deftest var last-result-var2
327 "\"last result\" variable"
328 (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n"))
329
330(eshell-deftest var last-arg-var
331 "\"last arg\" variable"
332 (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n"))
333
334(defun eshell-complete-lisp-symbols () 323(defun eshell-complete-lisp-symbols ()
335 "If there is a user reference, complete it." 324 "If there is a user reference, complete it."
336 (let ((arg (pcomplete-actual-arg))) 325 (let ((arg (pcomplete-actual-arg)))
@@ -440,32 +429,12 @@ hooks should be run before and after the command."
440 (eq (caar terms) 'eshell-command-to-value)) 429 (eq (caar terms) 'eshell-command-to-value))
441 (car (cdar terms)))) 430 (car (cdar terms))))
442 431
443(eshell-deftest cmd lisp-command
444 "Evaluate Lisp command"
445 (eshell-command-result-p "(+ 1 2)" "3"))
446
447(eshell-deftest cmd lisp-command-args
448 "Evaluate Lisp command (ignore args)"
449 (eshell-command-result-p "(+ 1 2) 3" "3"))
450
451(defun eshell-rewrite-initial-subcommand (terms) 432(defun eshell-rewrite-initial-subcommand (terms)
452 "Rewrite a subcommand in initial position, such as '{+ 1 2}'." 433 "Rewrite a subcommand in initial position, such as '{+ 1 2}'."
453 (if (and (listp (car terms)) 434 (if (and (listp (car terms))
454 (eq (caar terms) 'eshell-as-subcommand)) 435 (eq (caar terms) 'eshell-as-subcommand))
455 (car terms))) 436 (car terms)))
456 437
457(eshell-deftest cmd subcommand
458 "Run subcommand"
459 (eshell-command-result-p "{+ 1 2}" "3\n"))
460
461(eshell-deftest cmd subcommand-args
462 "Run subcommand (ignore args)"
463 (eshell-command-result-p "{+ 1 2} 3" "3\n"))
464
465(eshell-deftest cmd subcommand-lisp
466 "Run subcommand + Lisp form"
467 (eshell-command-result-p "{(+ 1 2)}" "3\n"))
468
469(defun eshell-rewrite-named-command (terms) 438(defun eshell-rewrite-named-command (terms)
470 "If no other rewriting rule transforms TERMS, assume a named command." 439 "If no other rewriting rule transforms TERMS, assume a named command."
471 (let ((sym (if eshell-in-pipeline-p 440 (let ((sym (if eshell-in-pipeline-p
@@ -477,10 +446,6 @@ hooks should be run before and after the command."
477 (list sym cmd (append (list 'list) (cdr terms))) 446 (list sym cmd (append (list 'list) (cdr terms)))
478 (list sym cmd)))) 447 (list sym cmd))))
479 448
480(eshell-deftest cmd named-command
481 "Execute named command"
482 (eshell-command-result-p "+ 1 2" "3\n"))
483
484(defvar eshell-command-body) 449(defvar eshell-command-body)
485(defvar eshell-test-body) 450(defvar eshell-test-body)
486 451
@@ -987,7 +952,7 @@ at the moment are:
987 (not (member name eshell-complex-commands)) 952 (not (member name eshell-complex-commands))
988 (catch 'simple 953 (catch 'simple
989 (progn 954 (progn
990 (eshell-for pred eshell-complex-commands 955 (dolist (pred eshell-complex-commands)
991 (if (and (functionp pred) 956 (if (and (functionp pred)
992 (funcall pred name)) 957 (funcall pred name))
993 (throw 'simple nil))) 958 (throw 'simple nil)))
@@ -1165,7 +1130,7 @@ be finished later after the completion of an asynchronous subprocess."
1165 (if (and (eq (car form) 'let) 1130 (if (and (eq (car form) 'let)
1166 (not (eq (car (cadr args)) 'eshell-do-eval))) 1131 (not (eq (car (cadr args)) 'eshell-do-eval)))
1167 (eshell-manipulate "evaluating let args" 1132 (eshell-manipulate "evaluating let args"
1168 (eshell-for letarg (car args) 1133 (dolist (letarg (car args))
1169 (if (and (listp letarg) 1134 (if (and (listp letarg)
1170 (not (eq (cadr letarg) 'quote))) 1135 (not (eq (cadr letarg) 'quote)))
1171 (setcdr letarg 1136 (setcdr letarg
@@ -1241,7 +1206,7 @@ be finished later after the completion of an asynchronous subprocess."
1241 1206
1242(defun eshell/which (command &rest names) 1207(defun eshell/which (command &rest names)
1243 "Identify the COMMAND, and where it is located." 1208 "Identify the COMMAND, and where it is located."
1244 (eshell-for name (cons command names) 1209 (dolist (name (cons command names))
1245 (let (program alias direct) 1210 (let (program alias direct)
1246 (if (eq (aref name 0) eshell-explicit-command-char) 1211 (if (eq (aref name 0) eshell-explicit-command-char)
1247 (setq name (substring name 1) 1212 (setq name (substring name 1)
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index 7128d7e4749..3acbeac0b89 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -46,8 +46,9 @@ loaded into memory, thus beginning a new process."
46 46
47;;; User Variables: 47;;; User Variables:
48 48
49(defcustom eshell-ext-load-hook '(eshell-ext-initialize) 49(defcustom eshell-ext-load-hook nil
50 "A hook that gets run when `eshell-ext' is loaded." 50 "A hook that gets run when `eshell-ext' is loaded."
51 :version "24.1" ; removed eshell-ext-initialize
51 :type 'hook 52 :type 'hook
52 :group 'eshell-ext) 53 :group 'eshell-ext)
53 54
@@ -263,7 +264,7 @@ line of the form #!<interp>."
263 (let ((finterp 264 (let ((finterp
264 (catch 'found 265 (catch 'found
265 (ignore 266 (ignore
266 (eshell-for possible eshell-interpreter-alist 267 (dolist (possible eshell-interpreter-alist)
267 (cond 268 (cond
268 ((functionp (car possible)) 269 ((functionp (car possible))
269 (and (funcall (car possible) file) 270 (and (funcall (car possible) file)
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index ef8966f1d7d..71fae34b360 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -71,8 +71,9 @@ though they were files."
71 71
72;;; User Variables: 72;;; User Variables:
73 73
74(defcustom eshell-io-load-hook '(eshell-io-initialize) 74(defcustom eshell-io-load-hook nil
75 "A hook that gets run when `eshell-io' is loaded." 75 "A hook that gets run when `eshell-io' is loaded."
76 :version "24.1" ; removed eshell-io-initialize
76 :type 'hook 77 :type 'hook
77 :group 'eshell-io) 78 :group 'eshell-io)
78 79
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 3735ee35fd5..10623dba8e3 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -89,9 +89,10 @@ That is to say, the first time during an Emacs session."
89 :type 'hook 89 :type 'hook
90 :group 'eshell-mode) 90 :group 'eshell-mode)
91 91
92(defcustom eshell-exit-hook '(eshell-query-kill-processes) 92(defcustom eshell-exit-hook nil
93 "A hook that is run whenever `eshell' is exited. 93 "A hook that is run whenever `eshell' is exited.
94This hook is only run if exiting actually kills the buffer." 94This hook is only run if exiting actually kills the buffer."
95 :version "24.1" ; removed eshell-query-kill-processes
95 :type 'hook 96 :type 'hook
96 :group 'eshell-mode) 97 :group 'eshell-mode)
97 98
@@ -287,6 +288,17 @@ This is used by `eshell-watch-for-password-prompt'."
287 288
288;;; User Functions: 289;;; User Functions:
289 290
291(defun eshell-kill-buffer-function ()
292 "Function added to `kill-buffer-hook' in Eshell buffers.
293This runs the function `eshell-kill-processes-on-exit',
294and the hook `eshell-exit-hook'."
295 ;; It's fine to run this unconditionally since it can be customized
296 ;; via the `eshell-kill-processes-on-exit' variable.
297 (and (fboundp 'eshell-query-kill-processes)
298 (not (memq 'eshell-query-kill-processes eshell-exit-hook))
299 (eshell-query-kill-processes))
300 (run-hooks 'eshell-exit-hook))
301
290;;;###autoload 302;;;###autoload
291(defun eshell-mode () 303(defun eshell-mode ()
292 "Emacs shell interactive mode. 304 "Emacs shell interactive mode.
@@ -389,7 +401,7 @@ This is used by `eshell-watch-for-password-prompt'."
389 ;; load extension modules into memory. This will cause any global 401 ;; load extension modules into memory. This will cause any global
390 ;; variables they define to be visible, since some of the core 402 ;; variables they define to be visible, since some of the core
391 ;; modules sometimes take advantage of their functionality if used. 403 ;; modules sometimes take advantage of their functionality if used.
392 (eshell-for module eshell-modules-list 404 (dolist (module eshell-modules-list)
393 (let ((module-fullname (symbol-name module)) 405 (let ((module-fullname (symbol-name module))
394 module-shortname) 406 module-shortname)
395 (if (string-match "^eshell-\\(.*\\)" module-fullname) 407 (if (string-match "^eshell-\\(.*\\)" module-fullname)
@@ -403,17 +415,15 @@ This is used by `eshell-watch-for-password-prompt'."
403 (unless (file-exists-p eshell-directory-name) 415 (unless (file-exists-p eshell-directory-name)
404 (eshell-make-private-directory eshell-directory-name t)) 416 (eshell-make-private-directory eshell-directory-name t))
405 417
406 ;; load core Eshell modules for this session 418 ;; Load core Eshell modules, then extension modules, for this session.
407 (eshell-for module (eshell-subgroups 'eshell) 419 (dolist (module (append (eshell-subgroups 'eshell) eshell-modules-list))
408 (run-hooks (intern-soft (concat (symbol-name module) 420 (let ((load-hook (intern-soft (format "%s-load-hook" module)))
409 "-load-hook")))) 421 (initfunc (intern-soft (format "%s-initialize" module))))
410 422 (when (and load-hook (boundp load-hook))
411 ;; load extension modules for this session 423 (if (memq initfunc (symbol-value load-hook)) (setq initfunc nil))
412 (eshell-for module eshell-modules-list 424 (run-hooks load-hook))
413 (let ((load-hook (intern-soft (concat (symbol-name module) 425 ;; So we don't need the -initialize functions on the hooks (b#5375).
414 "-load-hook")))) 426 (and initfunc (fboundp initfunc) (funcall initfunc))))
415 (if (and load-hook (boundp load-hook))
416 (run-hooks load-hook))))
417 427
418 (if eshell-send-direct-to-subprocesses 428 (if eshell-send-direct-to-subprocesses
419 (add-hook 'pre-command-hook 'eshell-intercept-commands t t)) 429 (add-hook 'pre-command-hook 'eshell-intercept-commands t t))
@@ -428,10 +438,7 @@ This is used by `eshell-watch-for-password-prompt'."
428 (add-hook 'eshell-pre-command-hook 'eshell-command-started nil t) 438 (add-hook 'eshell-pre-command-hook 'eshell-command-started nil t)
429 (add-hook 'eshell-post-command-hook 'eshell-command-finished nil t)) 439 (add-hook 'eshell-post-command-hook 'eshell-command-finished nil t))
430 440
431 (add-hook 'kill-buffer-hook 441 (add-hook 'kill-buffer-hook 'eshell-kill-buffer-function t t)
432 (function
433 (lambda ()
434 (run-hooks 'eshell-exit-hook))) t t)
435 442
436 (if eshell-first-time-p 443 (if eshell-first-time-p
437 (run-hooks 'eshell-first-time-mode-hook)) 444 (run-hooks 'eshell-first-time-mode-hook))
@@ -440,19 +447,6 @@ This is used by `eshell-watch-for-password-prompt'."
440 447
441(put 'eshell-mode 'mode-class 'special) 448(put 'eshell-mode 'mode-class 'special)
442 449
443(eshell-deftest mode major-mode
444 "Major mode is correct"
445 (eq major-mode 'eshell-mode))
446
447(eshell-deftest mode eshell-mode-variable
448 "`eshell-mode' is true"
449 (eq eshell-mode t))
450
451(eshell-deftest var window-height
452 "LINES equals window height"
453 (let ((eshell-stringify-t t))
454 (eshell-command-result-p "= $LINES (window-height)" "t\n")))
455
456(defun eshell-command-started () 450(defun eshell-command-started ()
457 "Indicate in the modeline that a command has started." 451 "Indicate in the modeline that a command has started."
458 (setq eshell-command-running-string "**") 452 (setq eshell-command-running-string "**")
@@ -463,13 +457,6 @@ This is used by `eshell-watch-for-password-prompt'."
463 (setq eshell-command-running-string "--") 457 (setq eshell-command-running-string "--")
464 (force-mode-line-update)) 458 (force-mode-line-update))
465 459
466(eshell-deftest mode command-running-p
467 "Modeline shows no command running"
468 (or (featurep 'xemacs)
469 (not eshell-status-in-modeline)
470 (and (memq 'eshell-command-running-string mode-line-format)
471 (equal eshell-command-running-string "--"))))
472
473;;; Internal Functions: 460;;; Internal Functions:
474 461
475(defun eshell-toggle-direct-send () 462(defun eshell-toggle-direct-send ()
@@ -539,20 +526,6 @@ This is used by `eshell-watch-for-password-prompt'."
539 (= (1+ pos) limit)) 526 (= (1+ pos) limit))
540 (forward-char 1)))) 527 (forward-char 1))))
541 528
542(eshell-deftest arg forward-arg
543 "Move across command arguments"
544 (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore)
545 (let ((here (point)) begin valid)
546 (eshell-bol)
547 (setq begin (point))
548 (eshell-forward-argument 4)
549 (setq valid (= here (point)))
550 (eshell-backward-argument 4)
551 (prog1
552 (and valid (= begin (point)))
553 (eshell-bol)
554 (delete-region (point) (point-max)))))
555
556(defun eshell-forward-argument (&optional arg) 529(defun eshell-forward-argument (&optional arg)
557 "Move forward ARG arguments." 530 "Move forward ARG arguments."
558 (interactive "p") 531 (interactive "p")
@@ -652,17 +625,6 @@ waiting for input."
652 (interactive "P") 625 (interactive "P")
653 (eshell-send-input use-region t)) 626 (eshell-send-input use-region t))
654 627
655(eshell-deftest mode queue-input
656 "Queue command input"
657 (eshell-insert-command "sleep 2")
658 (eshell-insert-command "echo alpha" 'eshell-queue-input)
659 (let ((count 10))
660 (while (and eshell-current-command
661 (> count 0))
662 (sit-for 1 0)
663 (setq count (1- count))))
664 (eshell-match-result "alpha\n"))
665
666(defun eshell-send-input (&optional use-region queue-p no-newline) 628(defun eshell-send-input (&optional use-region queue-p no-newline)
667 "Send the input received to Eshell for parsing and processing. 629 "Send the input received to Eshell for parsing and processing.
668After `eshell-last-output-end', sends all text from that marker to 630After `eshell-last-output-end', sends all text from that marker to
@@ -741,20 +703,6 @@ newline."
741 (run-hooks 'eshell-post-command-hook) 703 (run-hooks 'eshell-post-command-hook)
742 (insert-and-inherit input))))))))) 704 (insert-and-inherit input)))))))))
743 705
744; (eshell-deftest proc send-to-subprocess
745; "Send input to a subprocess"
746; ;; jww (1999-12-06): what about when bc is unavailable?
747; (if (not (eshell-search-path "bc"))
748; t
749; (eshell-insert-command "bc")
750; (eshell-insert-command "1 + 2")
751; (sit-for 1 0)
752; (forward-line -1)
753; (prog1
754; (looking-at "3\n")
755; (eshell-insert-command "quit")
756; (sit-for 1 0))))
757
758(defsubst eshell-kill-new () 706(defsubst eshell-kill-new ()
759 "Add the last input text to the kill ring." 707 "Add the last input text to the kill ring."
760 (kill-ring-save eshell-last-input-start eshell-last-input-end)) 708 (kill-ring-save eshell-last-input-start eshell-last-input-end))
@@ -900,14 +848,6 @@ Does not delete the prompt."
900 (insert "*** output flushed ***\n") 848 (insert "*** output flushed ***\n")
901 (delete-region (point) (eshell-end-of-output)))) 849 (delete-region (point) (eshell-end-of-output))))
902 850
903(eshell-deftest io flush-output
904 "Flush previous output"
905 (eshell-insert-command "echo alpha")
906 (eshell-kill-output)
907 (and (eshell-match-result (regexp-quote "*** output flushed ***\n"))
908 (forward-line)
909 (= (point) eshell-last-output-start)))
910
911(defun eshell-show-output (&optional arg) 851(defun eshell-show-output (&optional arg)
912 "Display start of this batch of interpreter output at top of window. 852 "Display start of this batch of interpreter output at top of window.
913Sets mark to the value of point when this command is run. 853Sets mark to the value of point when this command is run.
@@ -968,12 +908,6 @@ When run interactively, widen the buffer first."
968 (goto-char eshell-last-output-end) 908 (goto-char eshell-last-output-end)
969 (insert-and-inherit input))) 909 (insert-and-inherit input)))
970 910
971(eshell-deftest mode run-old-command
972 "Re-run an old command"
973 (eshell-insert-command "echo alpha")
974 (goto-char eshell-last-input-start)
975 (string= (eshell-get-old-input) "echo alpha"))
976
977(defun eshell/exit () 911(defun eshell/exit ()
978 "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'." 912 "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'."
979 (throw 'eshell-terminal t)) 913 (throw 'eshell-terminal t))
diff --git a/lisp/eshell/esh-module.el b/lisp/eshell/esh-module.el
index 5a62c71355c..1581d05889e 100644
--- a/lisp/eshell/esh-module.el
+++ b/lisp/eshell/esh-module.el
@@ -43,7 +43,7 @@ customizing the variable `eshell-modules-list'."
43 43
44(defcustom eshell-module-unload-hook 44(defcustom eshell-module-unload-hook
45 '(eshell-unload-extension-modules) 45 '(eshell-unload-extension-modules)
46 "*A hook run when `eshell-module' is unloaded." 46 "A hook run when `eshell-module' is unloaded."
47 :type 'hook 47 :type 'hook
48 :group 'eshell-module) 48 :group 'eshell-module)
49 49
@@ -61,7 +61,7 @@ customizing the variable `eshell-modules-list'."
61 eshell-script 61 eshell-script
62 eshell-term 62 eshell-term
63 eshell-unix) 63 eshell-unix)
64 "*A list of optional add-on modules to be loaded by Eshell. 64 "A list of optional add-on modules to be loaded by Eshell.
65Changes will only take effect in future Eshell buffers." 65Changes will only take effect in future Eshell buffers."
66 :type (append 66 :type (append
67 (list 'set ':tag "Supported modules") 67 (list 'set ':tag "Supported modules")
@@ -92,7 +92,7 @@ customization group. Example: `eshell-cmpl' for that module."
92 92
93(defun eshell-unload-extension-modules () 93(defun eshell-unload-extension-modules ()
94 "Unload any memory resident extension modules." 94 "Unload any memory resident extension modules."
95 (eshell-for module (eshell-subgroups 'eshell-module) 95 (dolist (module (eshell-subgroups 'eshell-module))
96 (if (featurep module) 96 (if (featurep module)
97 (ignore-errors 97 (ignore-errors
98 (message "Unloading %s..." (symbol-name module)) 98 (message "Unloading %s..." (symbol-name module))
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index f697a400556..eeaccc4b890 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -38,8 +38,9 @@ finish."
38 38
39;;; User Variables: 39;;; User Variables:
40 40
41(defcustom eshell-proc-load-hook '(eshell-proc-initialize) 41(defcustom eshell-proc-load-hook nil
42 "A hook that gets run when `eshell-proc' is loaded." 42 "A hook that gets run when `eshell-proc' is loaded."
43 :version "24.1" ; removed eshell-proc-initialize
43 :type 'hook 44 :type 'hook
44 :group 'eshell-proc) 45 :group 'eshell-proc)
45 46
@@ -94,13 +95,14 @@ is created."
94 :type 'hook 95 :type 'hook
95 :group 'eshell-proc) 96 :group 'eshell-proc)
96 97
97(defcustom eshell-kill-hook '(eshell-reset-after-proc) 98(defcustom eshell-kill-hook nil
98 "Called when a process run by `eshell-gather-process-output' has ended. 99 "Called when a process run by `eshell-gather-process-output' has ended.
99It is passed two arguments: the process that was just ended, and the 100It is passed two arguments: the process that was just ended, and the
100termination status (as a string). Note that the first argument may be 101termination status (as a string). Note that the first argument may be
101nil, in which case the user attempted to send a signal, but there was 102nil, in which case the user attempted to send a signal, but there was
102no relevant process. This can be used for displaying help 103no relevant process. This can be used for displaying help
103information, for example." 104information, for example."
105 :version "24.1" ; removed eshell-reset-after-proc
104 :type 'hook 106 :type 'hook
105 :group 'eshell-proc) 107 :group 'eshell-proc)
106 108
@@ -113,6 +115,14 @@ information, for example."
113 115
114;;; Functions: 116;;; Functions:
115 117
118(defun eshell-kill-process-function (proc status)
119 "Function run when killing a process.
120Runs `eshell-reset-after-proc' and `eshell-kill-hook', passing arguments
121PROC and STATUS to both."
122 (or (memq 'eshell-reset-after-proc eshell-kill-hook)
123 (eshell-reset-after-proc proc status))
124 (run-hook-with-args 'eshell-kill-hook proc status))
125
116(defun eshell-proc-initialize () 126(defun eshell-proc-initialize ()
117 "Initialize the process handling code." 127 "Initialize the process handling code."
118 (make-local-variable 'eshell-process-list) 128 (make-local-variable 'eshell-process-list)
@@ -346,7 +356,7 @@ See `eshell-needs-pipe'."
346 (eshell-update-markers eshell-last-output-end) 356 (eshell-update-markers eshell-last-output-end)
347 ;; Simulate the effect of eshell-sentinel. 357 ;; Simulate the effect of eshell-sentinel.
348 (eshell-close-handles (if (numberp exit-status) exit-status -1)) 358 (eshell-close-handles (if (numberp exit-status) exit-status -1))
349 (run-hook-with-args 'eshell-kill-hook command exit-status) 359 (eshell-kill-process-function command exit-status)
350 (or eshell-in-pipeline-p 360 (or eshell-in-pipeline-p
351 (setq eshell-last-sync-output-start nil)) 361 (setq eshell-last-sync-output-start nil))
352 (if (not (numberp exit-status)) 362 (if (not (numberp exit-status))
@@ -391,14 +401,14 @@ PROC is the process that's exiting. STRING is the exit message."
391 (eshell-close-handles (process-exit-status proc) 'nil 401 (eshell-close-handles (process-exit-status proc) 'nil
392 (cadr entry)))) 402 (cadr entry))))
393 (eshell-remove-process-entry entry)))) 403 (eshell-remove-process-entry entry))))
394 (run-hook-with-args 'eshell-kill-hook proc string))))) 404 (eshell-kill-process-function proc string)))))
395 405
396(defun eshell-process-interact (func &optional all query) 406(defun eshell-process-interact (func &optional all query)
397 "Interact with a process, using PROMPT if more than one, via FUNC. 407 "Interact with a process, using PROMPT if more than one, via FUNC.
398If ALL is non-nil, background processes will be interacted with as well. 408If ALL is non-nil, background processes will be interacted with as well.
399If QUERY is non-nil, query the user with QUERY before calling FUNC." 409If QUERY is non-nil, query the user with QUERY before calling FUNC."
400 (let (defunct result) 410 (let (defunct result)
401 (eshell-for entry eshell-process-list 411 (dolist (entry eshell-process-list)
402 (if (and (memq (process-status (car entry)) 412 (if (and (memq (process-status (car entry))
403 '(run stop open closed)) 413 '(run stop open closed))
404 (or all 414 (or all
@@ -412,7 +422,7 @@ If QUERY is non-nil, query the user with QUERY before calling FUNC."
412 ;; clean up the process list; this can get dirty if an error 422 ;; clean up the process list; this can get dirty if an error
413 ;; occurred that brought the user into the debugger, and then they 423 ;; occurred that brought the user into the debugger, and then they
414 ;; quit, so that the sentinel was never called. 424 ;; quit, so that the sentinel was never called.
415 (eshell-for d defunct 425 (dolist (d defunct)
416 (eshell-remove-process-entry d)) 426 (eshell-remove-process-entry d))
417 result)) 427 result))
418 428
@@ -485,31 +495,29 @@ See the variable `eshell-kill-processes-on-exit'."
485 (kill-buffer buf))) 495 (kill-buffer buf)))
486 (message nil)))) 496 (message nil))))
487 497
488(custom-add-option 'eshell-exit-hook 'eshell-query-kill-processes)
489
490(defun eshell-interrupt-process () 498(defun eshell-interrupt-process ()
491 "Interrupt a process." 499 "Interrupt a process."
492 (interactive) 500 (interactive)
493 (unless (eshell-process-interact 'interrupt-process) 501 (unless (eshell-process-interact 'interrupt-process)
494 (run-hook-with-args 'eshell-kill-hook nil "interrupt"))) 502 (eshell-kill-process-function nil "interrupt")))
495 503
496(defun eshell-kill-process () 504(defun eshell-kill-process ()
497 "Kill a process." 505 "Kill a process."
498 (interactive) 506 (interactive)
499 (unless (eshell-process-interact 'kill-process) 507 (unless (eshell-process-interact 'kill-process)
500 (run-hook-with-args 'eshell-kill-hook nil "killed"))) 508 (eshell-kill-process-function nil "killed")))
501 509
502(defun eshell-quit-process () 510(defun eshell-quit-process ()
503 "Send quit signal to process." 511 "Send quit signal to process."
504 (interactive) 512 (interactive)
505 (unless (eshell-process-interact 'quit-process) 513 (unless (eshell-process-interact 'quit-process)
506 (run-hook-with-args 'eshell-kill-hook nil "quit"))) 514 (eshell-kill-process-function nil "quit")))
507 515
508;(defun eshell-stop-process () 516;(defun eshell-stop-process ()
509; "Send STOP signal to process." 517; "Send STOP signal to process."
510; (interactive) 518; (interactive)
511; (unless (eshell-process-interact 'stop-process) 519; (unless (eshell-process-interact 'stop-process)
512; (run-hook-with-args 'eshell-kill-hook nil "stopped"))) 520; (eshell-kill-process-function nil "stopped")))
513 521
514;(defun eshell-continue-process () 522;(defun eshell-continue-process ()
515; "Send CONTINUE signal to process." 523; "Send CONTINUE signal to process."
@@ -518,7 +526,7 @@ See the variable `eshell-kill-processes-on-exit'."
518; ;; jww (1999-09-17): this signal is not dealt with yet. For 526; ;; jww (1999-09-17): this signal is not dealt with yet. For
519; ;; example, `eshell-reset' will be called, and so will 527; ;; example, `eshell-reset' will be called, and so will
520; ;; `eshell-resume-eval'. 528; ;; `eshell-resume-eval'.
521; (run-hook-with-args 'eshell-kill-hook nil "continue"))) 529; (eshell-kill-process-function nil "continue")))
522 530
523(defun eshell-send-eof-to-process () 531(defun eshell-send-eof-to-process ()
524 "Send EOF to process." 532 "Send EOF to process."
diff --git a/lisp/eshell/esh-test.el b/lisp/eshell/esh-test.el
deleted file mode 100644
index f5c55dd8ae7..00000000000
--- a/lisp/eshell/esh-test.el
+++ /dev/null
@@ -1,233 +0,0 @@
1;;; esh-test.el --- Eshell test suite
2
3;; Copyright (C) 1999-2011 Free Software Foundation, Inc.
4
5;; Author: John Wiegley <johnw@gnu.org>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;; The purpose of this module is to verify that Eshell works as
25;; expected. To run it on your system, use the command
26;; \\[eshell-test].
27
28;;; Code:
29
30(eval-when-compile
31 (require 'eshell)
32 (require 'esh-util))
33(require 'esh-mode)
34
35(defgroup eshell-test nil
36 "This module is meant to ensure that Eshell is working correctly."
37 :tag "Eshell test suite"
38 :group 'eshell)
39
40;;; User Variables:
41
42(defface eshell-test-ok
43 '((((class color) (background light)) (:foreground "Green" :bold t))
44 (((class color) (background dark)) (:foreground "Green" :bold t)))
45 "The face used to highlight OK result strings."
46 :group 'eshell-test)
47(define-obsolete-face-alias 'eshell-test-ok-face 'eshell-test-ok "22.1")
48
49(defface eshell-test-failed
50 '((((class color) (background light)) (:foreground "OrangeRed" :bold t))
51 (((class color) (background dark)) (:foreground "OrangeRed" :bold t))
52 (t (:bold t)))
53 "The face used to highlight FAILED result strings."
54 :group 'eshell-test)
55(define-obsolete-face-alias 'eshell-test-failed-face 'eshell-test-failed "22.1")
56
57(defcustom eshell-show-usage-metrics nil
58 "If non-nil, display different usage metrics for each Eshell command."
59 :set (lambda (symbol value)
60 (if value
61 (add-hook 'eshell-mode-hook 'eshell-show-usage-metrics)
62 (remove-hook 'eshell-mode-hook 'eshell-show-usage-metrics))
63 (set symbol value))
64 :type '(choice (const :tag "No metrics" nil)
65 (const :tag "Cons cells consumed" t)
66 (const :tag "Time elapsed" 0))
67 :group 'eshell-test)
68
69;;; Code:
70
71(defvar test-buffer)
72
73(defun eshell-insert-command (text &optional func)
74 "Insert a command at the end of the buffer."
75 (goto-char eshell-last-output-end)
76 (insert-and-inherit text)
77 (funcall (or func 'eshell-send-input)))
78
79(defun eshell-match-result (regexp)
80 "Insert a command at the end of the buffer."
81 (goto-char eshell-last-input-end)
82 (looking-at regexp))
83
84(defun eshell-command-result-p (text regexp &optional func)
85 "Insert a command at the end of the buffer."
86 (eshell-insert-command text func)
87 (eshell-match-result regexp))
88
89(defvar eshell-test-failures nil)
90
91(defun eshell-run-test (module funcsym label command)
92 "Test whether FORM evaluates to a non-nil value."
93 (when (let ((sym (intern-soft (concat "eshell-" (symbol-name module)))))
94 (or (memq sym (eshell-subgroups 'eshell))
95 (eshell-using-module sym)))
96 (with-current-buffer test-buffer
97 (insert-before-markers
98 (format "%-70s " (substring label 0 (min 70 (length label)))))
99 (insert-before-markers " ....")
100 (eshell-redisplay))
101 (let ((truth (eval command)))
102 (with-current-buffer test-buffer
103 (delete-char -6)
104 (insert-before-markers
105 "[" (let (str)
106 (if truth
107 (progn
108 (setq str " OK ")
109 (put-text-property 0 6 'face 'eshell-test-ok str))
110 (setq str "FAILED")
111 (setq eshell-test-failures (1+ eshell-test-failures))
112 (put-text-property 0 6 'face 'eshell-test-failed str))
113 str) "]")
114 (add-text-properties (line-beginning-position) (point)
115 (list 'test-func funcsym))
116 (eshell-redisplay)))))
117
118(defun eshell-test-goto-func ()
119 "Jump to the function that defines a particular test."
120 (interactive)
121 (let ((fsym (get-text-property (point) 'test-func)))
122 (when fsym
123 (let* ((def (symbol-function fsym))
124 (library (locate-library (symbol-file fsym 'defun)))
125 (name (substring (symbol-name fsym)
126 (length "eshell-test--")))
127 (inhibit-redisplay t))
128 (find-file library)
129 (goto-char (point-min))
130 (re-search-forward (concat "^(eshell-deftest\\s-+\\w+\\s-+"
131 name))
132 (beginning-of-line)))))
133
134(defun eshell-run-one-test (&optional arg)
135 "Jump to the function that defines a particular test."
136 (interactive "P")
137 (let ((fsym (get-text-property (point) 'test-func)))
138 (when fsym
139 (beginning-of-line)
140 (delete-region (point) (line-end-position))
141 (let ((test-buffer (current-buffer)))
142 (set-buffer (let ((inhibit-redisplay t))
143 (save-window-excursion (eshell t))))
144 (funcall fsym)
145 (unless arg
146 (kill-buffer (current-buffer)))))))
147
148;;;###autoload
149(defun eshell-test (&optional arg)
150 "Test Eshell to verify that it works as expected."
151 (interactive "P")
152 (let* ((begin (float-time))
153 (test-buffer (get-buffer-create "*eshell test*")))
154 (set-buffer (let ((inhibit-redisplay t))
155 (save-window-excursion (eshell t))))
156 (with-current-buffer test-buffer
157 (erase-buffer)
158 (setq major-mode 'eshell-test-mode)
159 (setq mode-name "EShell Test")
160 (set (make-local-variable 'eshell-test-failures) 0)
161 (local-set-key [(control ?c) (control ?c)] 'eshell-test-goto-func)
162 (local-set-key [(control ?c) (control ?r)] 'eshell-run-one-test)
163 (local-set-key [(control ?m)] 'eshell-test-goto-func)
164 (local-set-key [return] 'eshell-test-goto-func)
165
166 (insert "Testing Eshell under " (emacs-version))
167 (switch-to-buffer test-buffer)
168 (delete-other-windows))
169 (eshell-for funcname (sort (all-completions "eshell-test--"
170 obarray 'functionp)
171 'string-lessp)
172 (with-current-buffer test-buffer
173 (insert "\n"))
174 (funcall (intern-soft funcname)))
175 (with-current-buffer test-buffer
176 (insert (format "\n\n--- %s --- (completed in %d seconds)\n"
177 (current-time-string)
178 (- (float-time) begin)))
179 (message "Eshell test suite completed: %s failure%s"
180 (if (> eshell-test-failures 0)
181 (number-to-string eshell-test-failures)
182 "No")
183 (if (= eshell-test-failures 1) "" "s"))))
184 (goto-char eshell-last-output-end)
185 (unless arg
186 (kill-buffer (current-buffer))))
187
188
189(defvar eshell-metric-before-command 0)
190(defvar eshell-metric-after-command 0)
191
192(defun eshell-show-usage-metrics ()
193 "If run at Eshell mode startup, metrics are shown after each command."
194 (set (make-local-variable 'eshell-metric-before-command)
195 (if (eq eshell-show-usage-metrics t)
196 0
197 (current-time)))
198 (set (make-local-variable 'eshell-metric-after-command)
199 (if (eq eshell-show-usage-metrics t)
200 0
201 (current-time)))
202
203 (add-hook 'eshell-pre-command-hook
204 (function
205 (lambda ()
206 (setq eshell-metric-before-command
207 (if (eq eshell-show-usage-metrics t)
208 (car (memory-use-counts))
209 (current-time))))) nil t)
210
211 (add-hook 'eshell-post-command-hook
212 (function
213 (lambda ()
214 (setq eshell-metric-after-command
215 (if (eq eshell-show-usage-metrics t)
216 (car (memory-use-counts))
217 (current-time)))
218 (eshell-interactive-print
219 (concat
220 (int-to-string
221 (if (eq eshell-show-usage-metrics t)
222 (- eshell-metric-after-command
223 eshell-metric-before-command 7)
224 (- (float-time
225 eshell-metric-after-command)
226 (float-time
227 eshell-metric-before-command))))
228 "\n"))))
229 nil t))
230
231(provide 'esh-test)
232
233;;; esh-test.el ends here
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 2de147acb00..dbe4f824deb 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -147,18 +147,6 @@ function `string-to-number'."
147 147
148(put 'eshell-condition-case 'lisp-indent-function 2) 148(put 'eshell-condition-case 'lisp-indent-function 2)
149 149
150(defmacro eshell-deftest (module name label &rest forms)
151 (if (and (fboundp 'cl-compiling-file) (cl-compiling-file))
152 nil
153 (let ((fsym (intern (concat "eshell-test--" (symbol-name name)))))
154 `(eval-when-compile
155 (ignore
156 (defun ,fsym () ,label
157 (eshell-run-test (quote ,module) (quote ,fsym) ,label
158 (quote (progn ,@forms)))))))))
159
160(put 'eshell-deftest 'lisp-indent-function 2)
161
162(defun eshell-find-delimiter 150(defun eshell-find-delimiter
163 (open close &optional bound reverse-p backslash-p) 151 (open close &optional bound reverse-p backslash-p)
164 "From point, find the CLOSE delimiter corresponding to OPEN. 152 "From point, find the CLOSE delimiter corresponding to OPEN.
@@ -285,7 +273,6 @@ Prepend remote identification of `default-directory', if any."
285 (setq text (replace-match " " t t text))) 273 (setq text (replace-match " " t t text)))
286 text)) 274 text))
287 275
288;; FIXME this is just dolist.
289(defmacro eshell-for (for-var for-list &rest forms) 276(defmacro eshell-for (for-var for-list &rest forms)
290 "Iterate through a list" 277 "Iterate through a list"
291 `(let ((list-iter ,for-list)) 278 `(let ((list-iter ,for-list))
@@ -296,10 +283,12 @@ Prepend remote identification of `default-directory', if any."
296 283
297(put 'eshell-for 'lisp-indent-function 2) 284(put 'eshell-for 'lisp-indent-function 2)
298 285
286(make-obsolete 'eshell-for 'dolist "24.1")
287
299(defun eshell-flatten-list (args) 288(defun eshell-flatten-list (args)
300 "Flatten any lists within ARGS, so that there are no sublists." 289 "Flatten any lists within ARGS, so that there are no sublists."
301 (let ((new-list (list t))) 290 (let ((new-list (list t)))
302 (eshell-for a args 291 (dolist (a args)
303 (if (and (listp a) 292 (if (and (listp a)
304 (listp (cdr a))) 293 (listp (cdr a)))
305 (nconc new-list (eshell-flatten-list a)) 294 (nconc new-list (eshell-flatten-list a))
@@ -405,7 +394,7 @@ list."
405 (unless (listp entries) 394 (unless (listp entries)
406 (setq entries (list entries) 395 (setq entries (list entries)
407 listified t)) 396 listified t))
408 (eshell-for entry entries 397 (dolist (entry entries)
409 (unless (and exclude (string-match exclude entry)) 398 (unless (and exclude (string-match exclude entry))
410 (setq p predicates valid (null p)) 399 (setq p predicates valid (null p))
411 (while p 400 (while p
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 4c42b305ec2..69004a841f1 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -109,7 +109,6 @@
109 109
110(eval-when-compile 110(eval-when-compile
111 (require 'pcomplete) 111 (require 'pcomplete)
112 (require 'esh-test)
113 (require 'esh-util) 112 (require 'esh-util)
114 (require 'esh-opt) 113 (require 'esh-opt)
115 (require 'esh-mode)) 114 (require 'esh-mode))
@@ -126,8 +125,9 @@ variable value, a subcommand, or even the result of a Lisp form."
126 125
127;;; User Variables: 126;;; User Variables:
128 127
129(defcustom eshell-var-load-hook '(eshell-var-initialize) 128(defcustom eshell-var-load-hook nil
130 "A list of functions to call when loading `eshell-var'." 129 "A list of functions to call when loading `eshell-var'."
130 :version "24.1" ; removed eshell-var-initialize
131 :type 'hook 131 :type 'hook
132 :group 'eshell-var) 132 :group 'eshell-var)
133 133
@@ -351,8 +351,7 @@ This function is explicit for adding to `eshell-parse-argument-hook'."
351 '((?h "help" nil nil "show this usage screen") 351 '((?h "help" nil nil "show this usage screen")
352 :external "env" 352 :external "env"
353 :usage "<no arguments>") 353 :usage "<no arguments>")
354 (eshell-for setting (sort (eshell-environment-variables) 354 (dolist (setting (sort (eshell-environment-variables) 'string-lessp))
355 'string-lessp)
356 (eshell-buffered-print setting "\n")) 355 (eshell-buffered-print setting "\n"))
357 (eshell-flush))) 356 (eshell-flush)))
358 357
@@ -374,7 +373,7 @@ This function is explicit for adding to `eshell-parse-argument-hook'."
374This involves setting any variable aliases which affect the 373This involves setting any variable aliases which affect the
375environment, as specified in `eshell-variable-aliases-list'." 374environment, as specified in `eshell-variable-aliases-list'."
376 (let ((process-environment (eshell-copy-environment))) 375 (let ((process-environment (eshell-copy-environment)))
377 (eshell-for var-alias eshell-variable-aliases-list 376 (dolist (var-alias eshell-variable-aliases-list)
378 (if (nth 2 var-alias) 377 (if (nth 2 var-alias)
379 (setenv (car var-alias) 378 (setenv (car var-alias)
380 (eshell-stringify 379 (eshell-stringify
@@ -477,30 +476,6 @@ Possible options are:
477 (t 476 (t
478 (error "Invalid variable reference"))))) 477 (error "Invalid variable reference")))))
479 478
480(eshell-deftest var interp-cmd
481 "Interpolate command result"
482 (eshell-command-result-p "+ ${+ 1 2} 3" "6\n"))
483
484(eshell-deftest var interp-lisp
485 "Interpolate Lisp form evalution"
486 (eshell-command-result-p "+ $(+ 1 2) 3" "6\n"))
487
488(eshell-deftest var interp-concat
489 "Interpolate and concat command"
490 (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n"))
491
492(eshell-deftest var interp-concat-lisp
493 "Interpolate and concat Lisp form"
494 (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n"))
495
496(eshell-deftest var interp-concat2
497 "Interpolate and concat two commands"
498 (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n"))
499
500(eshell-deftest var interp-concat-lisp2
501 "Interpolate and concat two Lisp forms"
502 (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n"))
503
504(defun eshell-parse-indices () 479(defun eshell-parse-indices ()
505 "Parse and return a list of list of indices." 480 "Parse and return a list of list of indices."
506 (let (indices) 481 (let (indices)
@@ -623,7 +598,7 @@ For example, to retrieve the second element of a user's record in
623 "Generate list of applicable variables." 598 "Generate list of applicable variables."
624 (let ((argname pcomplete-stub) 599 (let ((argname pcomplete-stub)
625 completions) 600 completions)
626 (eshell-for alias eshell-variable-aliases-list 601 (dolist (alias eshell-variable-aliases-list)
627 (if (string-match (concat "^" argname) (car alias)) 602 (if (string-match (concat "^" argname) (car alias))
628 (setq completions (cons (car alias) completions)))) 603 (setq completions (cons (car alias) completions))))
629 (sort 604 (sort
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index 7690a102a9b..1a9d7c97b83 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -280,26 +280,12 @@ shells such as bash, zsh, rc, 4dos."
280 :type 'string 280 :type 'string
281 :group 'eshell) 281 :group 'eshell)
282 282
283(eshell-deftest mode same-window-buffer-names
284 "`eshell-buffer-name' is a member of `same-window-buffer-names'"
285 (member eshell-buffer-name same-window-buffer-names))
286
287(defcustom eshell-directory-name 283(defcustom eshell-directory-name
288 (locate-user-emacs-file "eshell/" ".eshell/") 284 (locate-user-emacs-file "eshell/" ".eshell/")
289 "The directory where Eshell control files should be kept." 285 "The directory where Eshell control files should be kept."
290 :type 'directory 286 :type 'directory
291 :group 'eshell) 287 :group 'eshell)
292 288
293(eshell-deftest mode eshell-directory-exists
294 "`eshell-directory-name' exists and is writable"
295 (file-writable-p eshell-directory-name))
296
297(eshell-deftest mode eshell-directory-modes
298 "`eshell-directory-name' has correct access protections"
299 (or (eshell-under-windows-p)
300 (= (file-modes eshell-directory-name)
301 eshell-private-directory-modes)))
302
303;;;_* Running Eshell 289;;;_* Running Eshell
304;; 290;;
305;; There are only three commands used to invoke Eshell. The first two 291;; There are only three commands used to invoke Eshell. The first two
@@ -450,10 +436,6 @@ corresponding to a successful execution."
450 (set status-var eshell-last-command-status)) 436 (set status-var eshell-last-command-status))
451 (cadr result)))))) 437 (cadr result))))))
452 438
453(eshell-deftest mode simple-command-result
454 "`eshell-command-result' works with a simple command."
455 (= (eshell-command-result "+ 1 2") 3))
456
457;;;_* Reporting bugs 439;;;_* Reporting bugs
458;; 440;;
459;; If you do encounter a bug, on any system, please report 441;; If you do encounter a bug, on any system, please report
@@ -474,7 +456,7 @@ Emacs."
474 ;; if the user set `eshell-prefer-to-shell' to t, but never loaded 456 ;; if the user set `eshell-prefer-to-shell' to t, but never loaded
475 ;; Eshell, then `eshell-subgroups' will be unbound 457 ;; Eshell, then `eshell-subgroups' will be unbound
476 (when (fboundp 'eshell-subgroups) 458 (when (fboundp 'eshell-subgroups)
477 (eshell-for module (eshell-subgroups 'eshell) 459 (dolist (module (eshell-subgroups 'eshell))
478 ;; this really only unloads as many modules as possible, 460 ;; this really only unloads as many modules as possible,
479 ;; since other `require' references (such as by customizing 461 ;; since other `require' references (such as by customizing
480 ;; `eshell-prefer-to-shell' to a non-nil value) might make it 462 ;; `eshell-prefer-to-shell' to a non-nil value) might make it