annotate lisp/eshell/eshell.el @ 91204:53108e6cea98

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
author Miles Bader <miles@gnu.org>
date Thu, 06 Dec 2007 09:51:45 +0000
parents f55f9811f5d7 52787def92eb
children 606f2d163a64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38120
diff changeset
1 ;;; eshell.el --- the Emacs command shell
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 69385
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74509
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
38120
64002802a902 Added a version string.
John Wiegley <johnw@newartisans.com>
parents: 38119
diff changeset
7 ;; Version: 2.4.2
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; Keywords: processes
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
78220
a1e8300d3c55 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 54564
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 54564
diff changeset
25 ;; Boston, MA 02110-1301, USA.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;;_* What does Eshell offer you?
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; Despite the sheer fact that running an Emacs shell can be fun, here
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; are a few of the unique features offered by Eshell:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; @ Integration with the Emacs Lisp programming environment
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; @ A high degree of configurability
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; @ The ability to have the same shell on every system Emacs has been
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; ported to. Since Eshell imposes no external requirements, and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; relies upon only the Lisp functions exposed by Emacs, it is quite
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; operating system independent. Several of the common UNIX
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; commands, such as ls, mv, rm, ln, etc., have been implemented in
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; Lisp in order to provide a more consistent work environment.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; For those who might be using an older version of Eshell, version
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; 2.1 represents an entirely new, module-based architecture. It
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; supports most of the features offered by modern shells. Here is a
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; brief list of some of its more visible features:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; @ Command argument completion (tcsh, zsh)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; @ Input history management (bash)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; @ Intelligent output scrolling
50937
dfc70cb4fd02 Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46705
diff changeset
53 ;; @ Pseudo-devices (such as "/dev/clip" for copying to the clipboard)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; @ Extended globbing (zsh)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; @ Argument and globbing predication (zsh)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; @ I/O redirection to buffers, files, symbols, processes, etc.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; @ Many niceties otherwise seen only in 4DOS
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; @ Alias functions, both Lisp and Eshell-syntax
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; @ Piping, sequenced commands, background jobs, etc...
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;;;_* How to begin
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;;
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
63 ;; To start using Eshell, simply type `M-x eshell'.
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;;;_* Philosophy
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; A shell is a layer which metaphorically surrounds the kernel, or
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; heart of an operating system. This kernel can be seen as an engine
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; of pure functionality, waiting to serve, while the user programs
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; take advantage of that functionality to accomplish their purpose.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;; The shell's role is to make that functionality accessible to the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; user in an unformed state. Very roughly, it associates kernel
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; functionality with textual commands, allowing the user to interact
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;; with the operating system via linguistic constructs. Process
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; invocation is perhaps the most significant form this takes, using
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; the kernel's `fork' and `exec' functions.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;; Other programs also interact with the functionality of the kernel,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; but these user applications typically offer a specific range of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 ;; functionality, and thus are not classed as "shells" proper.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; (What they lose in quiddity, they gain in rigidity).
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; Emacs is also a user application, but it does make the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; functionality of the kernel accessible through an interpreted
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;; language -- namely, Lisp. For that reason, there is little
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;; preventing Emacs from serving the same role as a modern shell. It
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; too can manipulate the kernel in an unpredetermined way to cause
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; system changes. All it's missing is the shell-ish linguistic
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;; model.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;; Enter Eshell. Eshell translates "shell-like" syntax into Lisp
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;; in order to exercise the kernel in the same manner as typical
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ;; system shells. There is a fundamental difference here, however,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;; although it may seem subtle at first...
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 ;; Shells like csh and Bourne shell were written several decades ago,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 ;; in different times, under more restrictive circumstances. This
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;; confined perspective shows itself in the paradigm used by nearly
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 ;; all command-line shells since. They are linear in conception, byte
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 ;; stream-based, sequential, and confined to movement within a single
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ;; host machine.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 ;; Emacs, on the other hand, is more than just a limited translator
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 ;; that can invoke subprocesses and redirect file handles. It also
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 ;; manages character buffers, windowing frames, network connections,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 ;; registers, bookmarks, processes, etc. In other words, it's a very
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 ;; multi-dimensional environment, within which eshell emulates a highly
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 ;; linear methodology.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 ;; Taking a moment, let's look at how this could affect the future of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 ;; a shell allowed to develop in such a wider field of play:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 ;; @ There is no reason why directory movement should be linear, and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 ;; confined to a single file-system. Emacs, through w3 and ange-ftp,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 ;; has access to the entire Web. Why not allow a user to cd to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 ;; multiple directories simultaneously, for example? It might make
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 ;; some tasks easier, such as diff'ing files separated by very long
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 ;; pathnames.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 ;; @ Data sources are available from anywhere Emacs can derive
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 ;; information from: not just from files or the output of other
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 ;; processes.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 ;; @ Multiple shell invocations all share the same environment -- even
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 ;; the same process list! It would be possible to have "process
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 ;; views", so that one buffer is watching standard output, another
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 ;; standard error, and another the result of standard output grep'd
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 ;; through a regular expression...
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 ;; @ It is not necessary to "leave" the shell, losing all input and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 ;; output history, environment variables, directory stack, etc.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 ;; Emacs could save the contents of your eshell environment, and
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 ;; restore all of it (or at least as much as possible) each time you
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 ;; restart. This could occur automatically, without requiring
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 ;; complex initialization scripts.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 ;; @ Typos occur all of the time; many of them are repeats of common
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 ;; errors, such as 'dri' for `dir'. Since executing non-existent
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 ;; programs is rarely the intention of the user, eshell could prompt
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 ;; for the replacement string, and then record that in a database of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 ;; known misspellings. (Note: The typo at the beginning of this
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 ;; paragraph wasn't discovered until two months after I wrote the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 ;; text; it was not intentional).
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 ;; @ Emacs' register and bookmarking facilities can be used for
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 ;; remembering where you've been, and what you've seen -- to varying
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 ;; levels of persistence. They could perhaps even be tied to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 ;; specific "moments" during eshell execution, which would include
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 ;; the environment at that time, as well as other variables.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 ;; Although this would require functionality orthogonal to Emacs'
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 ;; own bookmarking facilities, the interface used could be made to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 ;; operate very similarly.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 ;; This presents a brief idea of what the fuller dimensionality of an
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 ;; Emacs shell could offer. It's not just the language of a shell
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 ;; that determines how it's used, but also the Weltanschauung
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 ;; underlying its design -- and which is felt behind even the smallest
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 ;; feature. I would hope the freedom provided by using Emacs as a
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 ;; parent environment will invite rich ideas from others. It
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 ;; certainly feels as though all I've done so far is to tie down the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 ;; horse, so to speak, so that he will run at a man's pace.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 ;;;_* Influences
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 ;; The author of Eshell has been a long-time user of the following
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 ;; shells, all of which contributed to Eshell's design:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 ;; @ rc
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 ;; @ bash
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 ;; @ zsh
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 ;; @ sh
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 ;; @ 4nt
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 ;; @ csh
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175
38119
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
176 ;;;_* Speeding up load time
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
177 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
178 ;; If you find that Eshell loads too slowly, there is something you
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
179 ;; can do to speed it up.
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
180 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
181 ;; Create a file, named /tmp/elc, containing this filelist:
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
182 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
183 ;; esh-util.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
184 ;; eshell.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
185 ;; esh-module.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
186 ;; esh-var.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
187 ;; esh-proc.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
188 ;; esh-arg.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
189 ;; esh-io.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
190 ;; esh-ext.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
191 ;; esh-cmd.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
192 ;; esh-mode.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
193 ;; esh-opt.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
194 ;; em-alias.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
195 ;; em-banner.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
196 ;; em-basic.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
197 ;; em-cmpl.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
198 ;; em-dirs.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
199 ;; em-pred.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
200 ;; em-glob.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
201 ;; em-hist.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
202 ;; em-ls.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
203 ;; em-prompt.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
204 ;; em-rebind.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
205 ;; em-script.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
206 ;; em-smart.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
207 ;; em-term.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
208 ;; em-unix.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
209 ;; em-xtra.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
210 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
211 ;; The order is very important. Remove from the filelist any features
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
212 ;; you don't use. These all begin with "em-". If you don't use
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
213 ;; Eshell's key rebinding module, you can remove "em-rebind.elc" from
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
214 ;; the filelist. The modules you are currently using are listed in
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
215 ;; `eshell-modules-list'.
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
216 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
217 ;; Now, concatenating all of the above mentioned .elc files, in that
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
218 ;; order, to another file. Here is how to do this on UNIX:
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
219 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
220 ;; cat `cat /tmp/elc` > tmp.elc ; mv tmp.elc eshell.elc
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
221 ;;
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
222 ;; Now your eshell.elc file contains all of the .elc files that make
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
223 ;; up Eshell, in the right load order. When you next load Eshell, it
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
224 ;; will only have to read in this one file, which will greatly speed
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
225 ;; things up.
9c0099738383 Don't load in esh-util if it's already loaded. Also, added a comment
John Wiegley <johnw@newartisans.com>
parents: 37436
diff changeset
226
87083
52787def92eb Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86487
diff changeset
227 (eval-when-compile
52787def92eb Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86487
diff changeset
228 (require 'cl)
52787def92eb Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86487
diff changeset
229 (require 'esh-util))
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
230 (require 'esh-util)
87083
52787def92eb Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86487
diff changeset
231 (require 'esh-mode)
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
232
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
233 (defgroup eshell nil
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
234 "Eshell is a command shell implemented entirely in Emacs Lisp. It
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
235 invokes no external processes beyond those requested by the user. It
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
236 is intended to be a functional replacement for command shells such as
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
237 bash, zsh, rc, 4dos; since Emacs itself is capable of handling most of
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
238 the tasks accomplished by such tools."
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
239 :tag "The Emacs shell"
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
240 :link '(info-link "(eshell)Top")
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
241 :version "21.1"
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
242 :group 'applications)
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
243
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
244
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 ;;;_* User Options
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 ;; The following user options modify the behavior of Eshell overall.
87083
52787def92eb Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86487
diff changeset
248 (defvar eshell-buffer-name)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (defsubst eshell-add-to-window-buffer-names ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 "Add `eshell-buffer-name' to `same-window-buffer-names'."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (add-to-list 'same-window-buffer-names eshell-buffer-name))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (defsubst eshell-remove-from-window-buffer-names ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 "Remove `eshell-buffer-name' from `same-window-buffer-names'."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (setq same-window-buffer-names
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (delete eshell-buffer-name same-window-buffer-names)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (defcustom eshell-load-hook nil
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
260 "A hook run once Eshell has been loaded."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 :type 'hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 :group 'eshell)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (defcustom eshell-unload-hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 '(eshell-remove-from-window-buffer-names
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 eshell-unload-all-modules)
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
267 "A hook run when Eshell is unloaded from memory."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 :type 'hook
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 :group 'eshell)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (defcustom eshell-buffer-name "*eshell*"
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
272 "The basename used for Eshell buffers."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 :set (lambda (symbol value)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 ;; remove the old value of `eshell-buffer-name', if present
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (if (boundp 'eshell-buffer-name)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (eshell-remove-from-window-buffer-names))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (set symbol value)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 ;; add the new value
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (eshell-add-to-window-buffer-names)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 value)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 :type 'string
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 :group 'eshell)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (eshell-deftest mode same-window-buffer-names
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 "`eshell-buffer-name' is a member of `same-window-buffer-names'"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (member eshell-buffer-name same-window-buffer-names))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287
30271
54ff6ef3d884 (eshell-directory-name): Run default directory
Eli Zaretskii <eliz@gnu.org>
parents: 29934
diff changeset
288 (defcustom eshell-directory-name (convert-standard-filename "~/.eshell/")
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
289 "The directory where Eshell control files should be kept."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 :type 'directory
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 :group 'eshell)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (eshell-deftest mode eshell-directory-exists
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 "`eshell-directory-name' exists and is writable"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (file-writable-p eshell-directory-name))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (eshell-deftest mode eshell-directory-modes
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 "`eshell-directory-name' has correct access protections"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (or (eshell-under-windows-p)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (= (file-modes eshell-directory-name)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 eshell-private-directory-modes)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 ;;;_* Running Eshell
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 ;;
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 ;; There are only three commands used to invoke Eshell. The first two
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 ;; are intended for interactive use, while the third is meant for
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 ;; programmers. They are:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 ;;;###autoload
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (defun eshell (&optional arg)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 "Create an interactive Eshell buffer.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 The buffer used for Eshell sessions is determined by the value of
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 `eshell-buffer-name'. If there is already an Eshell session active in
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 that buffer, Emacs will simply switch to it. Otherwise, a new session
46705
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
315 will begin. A numeric prefix arg (as in `C-u 42 M-x eshell RET')
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
316 switches to the session with that number, creating it if necessary. A
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
317 nonnumeric prefix arg means to create a new session. Returns the
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
318 buffer selected (or created)."
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (interactive "P")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (assert eshell-buffer-name)
46705
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
321 (let ((buf (cond ((numberp arg)
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
322 (get-buffer-create (format "%s<%d>"
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
323 eshell-buffer-name
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
324 arg)))
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
325 (arg
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
326 (generate-new-buffer eshell-buffer-name))
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
327 (t
9f4f7bee7b8d (eshell): Numeric prefix arg means to switch
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43321
diff changeset
328 (get-buffer-create eshell-buffer-name)))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 ;; Simply calling `pop-to-buffer' will not mimic the way that
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 ;; shell-mode buffers appear, since they always reuse the same
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 ;; window that that command was invoked from. To achieve this,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 ;; it's necessary to add `eshell-buffer-name' to the variable
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 ;; `same-window-buffer-names', which is done when Eshell is loaded
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (assert (and buf (buffer-live-p buf)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (pop-to-buffer buf)
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
336 (unless (eq major-mode 'eshell-mode)
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
337 (eshell-mode))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 buf))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (defun eshell-return-exits-minibuffer ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (define-key eshell-mode-map [(control ?g)] 'abort-recursive-edit)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (define-key eshell-mode-map [return] 'exit-minibuffer)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (define-key eshell-mode-map [(control ?m)] 'exit-minibuffer)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (define-key eshell-mode-map [(control ?j)] 'exit-minibuffer)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (define-key eshell-mode-map [(meta return)] 'exit-minibuffer)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (define-key eshell-mode-map [(meta control ?m)] 'exit-minibuffer))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347
37436
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
348 (defvar eshell-non-interactive-p nil
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
349 "A variable which is non-nil when Eshell is not running interactively.
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
350 Modules should use this variable so that they don't clutter
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
351 non-interactive sessions, such as when using `eshell-command'.")
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
352
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 ;;;###autoload
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (defun eshell-command (&optional command arg)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 "Execute the Eshell command string COMMAND.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 With prefix ARG, insert output into the current buffer at point."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (interactive)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (require 'esh-cmd)
37436
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
359 (unless arg
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
360 (setq arg current-prefix-arg))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (unwind-protect
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (let ((eshell-non-interactive-p t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (add-hook 'minibuffer-setup-hook 'eshell-mode)
43321
358616bbe6a1 (eshell-command): Before reading from the minibuffer, add
John Wiegley <johnw@newartisans.com>
parents: 42686
diff changeset
364 (add-hook 'minibuffer-exit-hook 'eshell-add-command-to-history)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (add-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
37436
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
366 (unless command
33a9a90f3e76 (eshell-command): Made a few changes so that `eshell-command' could be
John Wiegley <johnw@newartisans.com>
parents: 37281
diff changeset
367 (setq command (read-from-minibuffer "Emacs shell command: "))))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (remove-hook 'eshell-mode-hook 'eshell-return-exits-minibuffer)
43321
358616bbe6a1 (eshell-command): Before reading from the minibuffer, add
John Wiegley <johnw@newartisans.com>
parents: 42686
diff changeset
369 (remove-hook 'minibuffer-exit-hook 'eshell-add-command-to-history)
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (remove-hook 'minibuffer-setup-hook 'eshell-mode))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (unless command
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (error "No command specified!"))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 ;; redirection into the current buffer is achieved by adding an
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 ;; output redirection to the end of the command, of the form
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 ;; 'COMMAND >>> #<buffer BUFFER>'. This will not interfere with
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 ;; other redirections, since multiple redirections merely cause the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 ;; output to be copied to multiple target locations
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (if arg
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (setq command
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (concat command
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (format " >>> #<buffer %s>"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (buffer-name (current-buffer))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (save-excursion
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (let ((buf (set-buffer (generate-new-buffer " *eshell cmd*")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (eshell-non-interactive-p t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (eshell-mode)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (let* ((proc (eshell-eval-command
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (list 'eshell-commands
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (eshell-parse-command command))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 intr
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (bufname (if (and proc (listp proc))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 "*EShell Async Command Output*"
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (setq intr t)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 "*EShell Command Output*")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (if (buffer-live-p (get-buffer bufname))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (kill-buffer bufname))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (rename-buffer bufname)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 ;; things get a little coarse here, since the desire is to
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 ;; make the output as attractive as possible, with no
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ;; extraneous newlines
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (when intr
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (if (eshell-interactive-process)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (eshell-wait-for-process (eshell-interactive-process)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (assert (not (eshell-interactive-process)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (goto-char (point-max))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (while (and (bolp) (not (bobp)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (delete-backward-char 1)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (assert (and buf (buffer-live-p buf)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (unless arg
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (let ((len (if (not intr) 2
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (count-lines (point-min) (point-max)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 (cond
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 ((= len 0)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (message "(There was no command output)")
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (kill-buffer buf))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 ((= len 1)
37281
85c38f2eac06 (eshell-command): Needed a "%s" format specifier, in case the buffer
John Wiegley <johnw@newartisans.com>
parents: 32451
diff changeset
417 (message "%s" (buffer-string))
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (kill-buffer buf))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (t
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (save-selected-window
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (select-window (display-buffer buf))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (goto-char (point-min))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 ;; cause the output buffer to take up as little screen
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 ;; real-estate as possible, if temp buffer resizing is
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 ;; enabled
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (and intr temp-buffer-resize-mode
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (resize-temp-buffer-window)))))))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 ;;;###autoload
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (defun eshell-command-result (command &optional status-var)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 "Execute the given Eshell COMMAND, and return the result.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 The result might be any Lisp object.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 If STATUS-VAR is a symbol, it will be set to the exit status of the
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 command. This is the only way to determine whether the value returned
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 corresponding to a successful execution."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 ;; a null command produces a null, successful result
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (if (not command)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (ignore
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (if (and status-var (symbolp status-var))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (set status-var 0)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (with-temp-buffer
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (let ((eshell-non-interactive-p t))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (eshell-mode)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (let ((result (eshell-do-eval
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (list 'eshell-commands
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (list 'eshell-command-to-value
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (eshell-parse-command command))) t)))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (assert (eq (car result) 'quote))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (if (and status-var (symbolp status-var))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (set status-var eshell-last-command-status))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (cadr result))))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (eshell-deftest mode simple-command-result
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 "`eshell-command-result' works with a simple command."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (= (eshell-command-result "+ 1 2") 3))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 ;;;_* Reporting bugs
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 ;;
86424
abb353cfc8db (eshell-report-bug-address): Remove.
Glenn Morris <rgm@gnu.org>
parents: 86416
diff changeset
459 ;; If you do encounter a bug, on any system, please report
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 ;; it -- in addition to any particular oddities in your configuration
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 ;; -- so that the problem may be corrected for the benefit of others.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 ;;;###autoload
86487
70414d2bb729 (eshell-report-bug): Add version number of obsolescence.
Glenn Morris <rgm@gnu.org>
parents: 86424
diff changeset
464 (define-obsolete-function-alias 'eshell-report-bug 'report-emacs-bug "23.1")
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 ;;; Code:
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (defun eshell-unload-all-modules ()
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 "Unload all modules that were loaded by Eshell, if possible.
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 If the user has require'd in any of the modules, or customized a
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 variable with a :require tag (such as `eshell-prefer-to-shell'), it
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 will be impossible to unload Eshell completely without restarting
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 Emacs."
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 ;; if the user set `eshell-prefer-to-shell' to t, but never loaded
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 ;; Eshell, then `eshell-subgroups' will be unbound
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (when (fboundp 'eshell-subgroups)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (eshell-for module (eshell-subgroups 'eshell)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 ;; this really only unloads as many modules as possible,
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 ;; since other `require' references (such as by customizing
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 ;; `eshell-prefer-to-shell' to a non-nil value) might make it
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 ;; impossible to unload Eshell completely
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (if (featurep module)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (ignore-errors
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (message "Unloading %s..." (symbol-name module))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (unload-feature module)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (message "Unloading %s...done" (symbol-name module)))))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (message "Unloading eshell...done")))
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (run-hooks 'eshell-load-hook)
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490
86416
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
491 (provide 'eshell)
b8c6722b2727 Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
492
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50937
diff changeset
493 ;;; arch-tag: 9d4d5214-0e4e-4e02-b349-39add640d63f
29876
edfec1c0d511 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 ;;; eshell.el ends here