Mercurial > emacs
comparison 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 |
comparison
equal
deleted
inserted
replaced
91203:db40129142b2 | 91204:53108e6cea98 |
---|---|
21 | 21 |
22 ;; You should have received a copy of the GNU General Public License | 22 ;; You should have received a copy of the GNU General Public License |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | 25 ;; Boston, MA 02110-1301, USA. |
26 | |
27 (provide 'eshell) | |
28 | |
29 (eval-when-compile (require 'esh-maint)) | |
30 | |
31 (defgroup eshell nil | |
32 "Eshell is a command shell implemented entirely in Emacs Lisp. It | |
33 invokes no external processes beyond those requested by the user. It | |
34 is intended to be a functional replacement for command shells such as | |
35 bash, zsh, rc, 4dos; since Emacs itself is capable of handling most of | |
36 the tasks accomplished by such tools." | |
37 :tag "The Emacs shell" | |
38 :link '(info-link "(eshell)Top") | |
39 :version "21.1" | |
40 :group 'applications) | |
41 | 26 |
42 ;;; Commentary: | 27 ;;; Commentary: |
43 | 28 |
44 ;;;_* What does Eshell offer you? | 29 ;;;_* What does Eshell offer you? |
45 ;; | 30 ;; |
71 ;; @ I/O redirection to buffers, files, symbols, processes, etc. | 56 ;; @ I/O redirection to buffers, files, symbols, processes, etc. |
72 ;; @ Many niceties otherwise seen only in 4DOS | 57 ;; @ Many niceties otherwise seen only in 4DOS |
73 ;; @ Alias functions, both Lisp and Eshell-syntax | 58 ;; @ Alias functions, both Lisp and Eshell-syntax |
74 ;; @ Piping, sequenced commands, background jobs, etc... | 59 ;; @ Piping, sequenced commands, background jobs, etc... |
75 ;; | 60 ;; |
76 ;;;_* Eshell is free software | |
77 ;; | |
78 ;; Eshell is free software; you can redistribute it and/or modify it | |
79 ;; under the terms of the GNU General Public License as published by | |
80 ;; the Free Software Foundation; either version 3, or (at your option) | |
81 ;; any later version. | |
82 ;; | |
83 ;; This program is distributed in the hope that it will be useful, but | |
84 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
85 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
86 ;; General Public License for more details. | |
87 ;; | |
88 ;; You should have received a copy of the GNU General Public License | |
89 ;; along with Eshell; see the file COPYING. If not, write to the Free | |
90 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
91 ;; MA 02110-1301, USA. | |
92 ;; | |
93 ;;;_* How to begin | 61 ;;;_* How to begin |
94 ;; | 62 ;; |
95 ;; To start using Eshell, add the following to your .emacs file: | 63 ;; To start using Eshell, simply type `M-x eshell'. |
96 ;; | |
97 ;; (load "eshell-auto") | |
98 ;; | |
99 ;; This will define all of the necessary autoloads. | |
100 ;; | |
101 ;; Now type `M-x eshell'. See the INSTALL file for full installation | |
102 ;; instructions. | |
103 ;; | 64 ;; |
104 ;;;_* Philosophy | 65 ;;;_* Philosophy |
105 ;; | 66 ;; |
106 ;; A shell is a layer which metaphorically surrounds the kernel, or | 67 ;; A shell is a layer which metaphorically surrounds the kernel, or |
107 ;; heart of an operating system. This kernel can be seen as an engine | 68 ;; heart of an operating system. This kernel can be seen as an engine |
261 ;; Now your eshell.elc file contains all of the .elc files that make | 222 ;; Now your eshell.elc file contains all of the .elc files that make |
262 ;; up Eshell, in the right load order. When you next load Eshell, it | 223 ;; up Eshell, in the right load order. When you next load Eshell, it |
263 ;; will only have to read in this one file, which will greatly speed | 224 ;; will only have to read in this one file, which will greatly speed |
264 ;; things up. | 225 ;; things up. |
265 | 226 |
227 (eval-when-compile | |
228 (require 'cl) | |
229 (require 'esh-util)) | |
230 (require 'esh-util) | |
231 (require 'esh-mode) | |
232 | |
233 (defgroup eshell nil | |
234 "Eshell is a command shell implemented entirely in Emacs Lisp. It | |
235 invokes no external processes beyond those requested by the user. It | |
236 is intended to be a functional replacement for command shells such as | |
237 bash, zsh, rc, 4dos; since Emacs itself is capable of handling most of | |
238 the tasks accomplished by such tools." | |
239 :tag "The Emacs shell" | |
240 :link '(info-link "(eshell)Top") | |
241 :version "21.1" | |
242 :group 'applications) | |
243 | |
244 | |
266 ;;;_* User Options | 245 ;;;_* User Options |
267 ;; | 246 ;; |
268 ;; The following user options modify the behavior of Eshell overall. | 247 ;; The following user options modify the behavior of Eshell overall. |
269 | 248 (defvar eshell-buffer-name) |
270 (unless (featurep 'esh-util) | |
271 (load "esh-util" nil t)) | |
272 | 249 |
273 (defsubst eshell-add-to-window-buffer-names () | 250 (defsubst eshell-add-to-window-buffer-names () |
274 "Add `eshell-buffer-name' to `same-window-buffer-names'." | 251 "Add `eshell-buffer-name' to `same-window-buffer-names'." |
275 (add-to-list 'same-window-buffer-names eshell-buffer-name)) | 252 (add-to-list 'same-window-buffer-names eshell-buffer-name)) |
276 | 253 |
278 "Remove `eshell-buffer-name' from `same-window-buffer-names'." | 255 "Remove `eshell-buffer-name' from `same-window-buffer-names'." |
279 (setq same-window-buffer-names | 256 (setq same-window-buffer-names |
280 (delete eshell-buffer-name same-window-buffer-names))) | 257 (delete eshell-buffer-name same-window-buffer-names))) |
281 | 258 |
282 (defcustom eshell-load-hook nil | 259 (defcustom eshell-load-hook nil |
283 "*A hook run once Eshell has been loaded." | 260 "A hook run once Eshell has been loaded." |
284 :type 'hook | 261 :type 'hook |
285 :group 'eshell) | 262 :group 'eshell) |
286 | 263 |
287 (defcustom eshell-unload-hook | 264 (defcustom eshell-unload-hook |
288 '(eshell-remove-from-window-buffer-names | 265 '(eshell-remove-from-window-buffer-names |
289 eshell-unload-all-modules) | 266 eshell-unload-all-modules) |
290 "*A hook run when Eshell is unloaded from memory." | 267 "A hook run when Eshell is unloaded from memory." |
291 :type 'hook | 268 :type 'hook |
292 :group 'eshell) | 269 :group 'eshell) |
293 | 270 |
294 (defcustom eshell-buffer-name "*eshell*" | 271 (defcustom eshell-buffer-name "*eshell*" |
295 "*The basename used for Eshell buffers." | 272 "The basename used for Eshell buffers." |
296 :set (lambda (symbol value) | 273 :set (lambda (symbol value) |
297 ;; remove the old value of `eshell-buffer-name', if present | 274 ;; remove the old value of `eshell-buffer-name', if present |
298 (if (boundp 'eshell-buffer-name) | 275 (if (boundp 'eshell-buffer-name) |
299 (eshell-remove-from-window-buffer-names)) | 276 (eshell-remove-from-window-buffer-names)) |
300 (set symbol value) | 277 (set symbol value) |
307 (eshell-deftest mode same-window-buffer-names | 284 (eshell-deftest mode same-window-buffer-names |
308 "`eshell-buffer-name' is a member of `same-window-buffer-names'" | 285 "`eshell-buffer-name' is a member of `same-window-buffer-names'" |
309 (member eshell-buffer-name same-window-buffer-names)) | 286 (member eshell-buffer-name same-window-buffer-names)) |
310 | 287 |
311 (defcustom eshell-directory-name (convert-standard-filename "~/.eshell/") | 288 (defcustom eshell-directory-name (convert-standard-filename "~/.eshell/") |
312 "*The directory where Eshell control files should be kept." | 289 "The directory where Eshell control files should be kept." |
313 :type 'directory | 290 :type 'directory |
314 :group 'eshell) | 291 :group 'eshell) |
315 | 292 |
316 (eshell-deftest mode eshell-directory-exists | 293 (eshell-deftest mode eshell-directory-exists |
317 "`eshell-directory-name' exists and is writable" | 294 "`eshell-directory-name' exists and is writable" |
354 ;; window that that command was invoked from. To achieve this, | 331 ;; window that that command was invoked from. To achieve this, |
355 ;; it's necessary to add `eshell-buffer-name' to the variable | 332 ;; it's necessary to add `eshell-buffer-name' to the variable |
356 ;; `same-window-buffer-names', which is done when Eshell is loaded | 333 ;; `same-window-buffer-names', which is done when Eshell is loaded |
357 (assert (and buf (buffer-live-p buf))) | 334 (assert (and buf (buffer-live-p buf))) |
358 (pop-to-buffer buf) | 335 (pop-to-buffer buf) |
359 (if (fboundp 'eshell-mode) | 336 (unless (eq major-mode 'eshell-mode) |
360 (unless (eq major-mode 'eshell-mode) | 337 (eshell-mode)) |
361 (eshell-mode)) | |
362 (error "`eshell-auto' must be loaded before Eshell can be used")) | |
363 buf)) | 338 buf)) |
364 | 339 |
365 (defun eshell-return-exits-minibuffer () | 340 (defun eshell-return-exits-minibuffer () |
366 (define-key eshell-mode-map [(control ?g)] 'abort-recursive-edit) | 341 (define-key eshell-mode-map [(control ?g)] 'abort-recursive-edit) |
367 (define-key eshell-mode-map [return] 'exit-minibuffer) | 342 (define-key eshell-mode-map [return] 'exit-minibuffer) |
404 (setq command | 379 (setq command |
405 (concat command | 380 (concat command |
406 (format " >>> #<buffer %s>" | 381 (format " >>> #<buffer %s>" |
407 (buffer-name (current-buffer)))))) | 382 (buffer-name (current-buffer)))))) |
408 (save-excursion | 383 (save-excursion |
409 (require 'esh-mode) | |
410 (let ((buf (set-buffer (generate-new-buffer " *eshell cmd*"))) | 384 (let ((buf (set-buffer (generate-new-buffer " *eshell cmd*"))) |
411 (eshell-non-interactive-p t)) | 385 (eshell-non-interactive-p t)) |
412 (eshell-mode) | 386 (eshell-mode) |
413 (let* ((proc (eshell-eval-command | 387 (let* ((proc (eshell-eval-command |
414 (list 'eshell-commands | 388 (list 'eshell-commands |
463 (if (not command) | 437 (if (not command) |
464 (ignore | 438 (ignore |
465 (if (and status-var (symbolp status-var)) | 439 (if (and status-var (symbolp status-var)) |
466 (set status-var 0))) | 440 (set status-var 0))) |
467 (with-temp-buffer | 441 (with-temp-buffer |
468 (require 'esh-mode) | |
469 (let ((eshell-non-interactive-p t)) | 442 (let ((eshell-non-interactive-p t)) |
470 (eshell-mode) | 443 (eshell-mode) |
471 (let ((result (eshell-do-eval | 444 (let ((result (eshell-do-eval |
472 (list 'eshell-commands | 445 (list 'eshell-commands |
473 (list 'eshell-command-to-value | 446 (list 'eshell-command-to-value |
481 "`eshell-command-result' works with a simple command." | 454 "`eshell-command-result' works with a simple command." |
482 (= (eshell-command-result "+ 1 2") 3)) | 455 (= (eshell-command-result "+ 1 2") 3)) |
483 | 456 |
484 ;;;_* Reporting bugs | 457 ;;;_* Reporting bugs |
485 ;; | 458 ;; |
486 ;; Since Eshell has not yet been in use by a wide audience, and since | 459 ;; If you do encounter a bug, on any system, please report |
487 ;; the number of possible configurations is quite large, it is certain | |
488 ;; that many bugs slipped past the rigors of testing it was put | |
489 ;; through. If you do encounter a bug, on any system, please report | |
490 ;; it -- in addition to any particular oddities in your configuration | 460 ;; it -- in addition to any particular oddities in your configuration |
491 ;; -- so that the problem may be corrected for the benefit of others. | 461 ;; -- so that the problem may be corrected for the benefit of others. |
492 | 462 |
493 (defconst eshell-report-bug-address "johnw@gnu.org" | |
494 "E-mail address to send Eshell bug reports to.") | |
495 | |
496 ;;;###autoload | 463 ;;;###autoload |
497 (defun eshell-report-bug (topic) | 464 (define-obsolete-function-alias 'eshell-report-bug 'report-emacs-bug "23.1") |
498 "Report a bug in Eshell. | |
499 Prompts for the TOPIC. Leaves you in a mail buffer. | |
500 Please include any configuration details that might be involved." | |
501 (interactive "sBug Subject: ") | |
502 (compose-mail eshell-report-bug-address topic) | |
503 (goto-char (point-min)) | |
504 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$")) | |
505 (forward-line 1) | |
506 (let ((signature (buffer-substring (point) (point-max)))) | |
507 ;; Discourage users from writing non-English text. | |
508 (set-buffer-multibyte nil) | |
509 (delete-region (point) (point-max)) | |
510 (insert signature) | |
511 (backward-char (length signature))) | |
512 (insert "emacs-version: " (emacs-version)) | |
513 (insert "\n\nThere appears to be a bug in Eshell.\n\n" | |
514 "Please describe exactly what actions " | |
515 "triggered the bug and the precise\n" | |
516 "symptoms of the bug:\n\n") | |
517 ;; This is so the user has to type something in order to send | |
518 ;; the report easily. | |
519 (use-local-map (nconc (make-sparse-keymap) (current-local-map)))) | |
520 | 465 |
521 ;;; Code: | 466 ;;; Code: |
522 | 467 |
523 (defun eshell-unload-all-modules () | 468 (defun eshell-unload-all-modules () |
524 "Unload all modules that were loaded by Eshell, if possible. | 469 "Unload all modules that were loaded by Eshell, if possible. |
541 (message "Unloading %s...done" (symbol-name module))))) | 486 (message "Unloading %s...done" (symbol-name module))))) |
542 (message "Unloading eshell...done"))) | 487 (message "Unloading eshell...done"))) |
543 | 488 |
544 (run-hooks 'eshell-load-hook) | 489 (run-hooks 'eshell-load-hook) |
545 | 490 |
491 (provide 'eshell) | |
492 | |
546 ;;; arch-tag: 9d4d5214-0e4e-4e02-b349-39add640d63f | 493 ;;; arch-tag: 9d4d5214-0e4e-4e02-b349-39add640d63f |
547 ;;; eshell.el ends here | 494 ;;; eshell.el ends here |