annotate lisp/eshell/esh-mode.el @ 110963:8e3439ed2228

* lisp/Makefile.in (compile-clean): Use `` instead of $(). (Former is more portable than the latter.)
author Glenn Morris <rgm@gnu.org>
date Tue, 12 Oct 2010 20:23:47 -0700
parents f57f72bb4757
children 417b1e4d63cd
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: 38111
diff changeset
1 ;;; esh-mode.el --- user interface
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
101005
b1e378ad4ae9 Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105831
diff changeset
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
32526
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 32446
diff changeset
6 ;; Author: John Wiegley <johnw@gnu.org>
8e57189d61b4 Add author information.
Gerd Moellmann <gerd@gnu.org>
parents: 32446
diff changeset
7
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
94661
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94661
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; (at your option) any later version.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94661
b5b0801a7637 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; Basically, Eshell is used just like shell mode (<M-x shell>). The
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; keystrokes for navigating the buffer, and accessing the command
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;; history, are identical. Unlike shell mode, however, Eshell mode's
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; governing process is Emacs itself. With shell mode, an inferior
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; shell process is executed that communicates with Emacs via comint
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; -- a mode for handling sub-process interaction. Eshell mode, on
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; the other hand, is a truly native Emacs shell. No subprocess are
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; invoked except the ones requested by the user at the prompt.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; After entering a command, use <RET> to invoke it ([Command
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; invocation]) . If there is a command on disk, it will be executed
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; as in a normal shell. If there is no command by that name on disk,
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; but a Lisp function with that name is defined, the Lisp function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; will be called, using the arguments passed on the command line.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; Some of the other features of the command interaction mode are:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; @ <M-RET> can be used to accumulate further commands while a
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; command is currently running. Since all input is passed to the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; subprocess being executed, there is no automatic input queueing
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; as there is with other shells.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; @ <C-c C-t> can be used to truncate the buffer if it grows too
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; large.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; @ <C-c C-r> will move point to the beginning of the output of the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;; last command. With a prefix argument, it will narrow to view
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; only that output.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; @ <C-c C-o> will delete the output from the last command.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; @ <C-c C-f> will move forward a complete shell argument.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;;
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; @ <C-c C-b> will move backward a complete shell argument.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59
101347
d1ba3386e97a Comment (header format fix).
Glenn Morris <rgm@gnu.org>
parents: 101332
diff changeset
60 ;;; Code:
d1ba3386e97a Comment (header format fix).
Glenn Morris <rgm@gnu.org>
parents: 101332
diff changeset
61
87085
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
62 (provide 'esh-mode)
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
63
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
64 (eval-when-compile (require 'esh-util))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 (require 'esh-module)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (require 'esh-cmd)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 (require 'esh-io)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 (require 'esh-var)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69
87085
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
70 (defgroup eshell-mode nil
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
71 "This module contains code for handling input from the user."
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
72 :tag "User interface"
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
73 :group 'eshell)
84c9097aaf6a Require individual files if needed when compiling, rather than
Glenn Morris <rgm@gnu.org>
parents: 86202
diff changeset
74
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;;; User Variables:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (defcustom eshell-mode-unload-hook nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
78 "A hook that gets run when `eshell-mode' is unloaded."
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (defcustom eshell-mode-hook nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
83 "A hook that gets run when `eshell-mode' is entered."
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (defcustom eshell-first-time-mode-hook nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
88 "A hook that gets run the first time `eshell-mode' is entered.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 That is to say, the first time during an Emacs session."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (defcustom eshell-exit-hook '(eshell-query-kill-processes)
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
94 "A hook that is run whenever `eshell' is exited.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 This hook is only run if exiting actually kills the buffer."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (defcustom eshell-kill-on-exit t
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
100 "If non-nil, kill the Eshell buffer on the `exit' command.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 Otherwise, the buffer will simply be buried."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 :type 'boolean
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (defcustom eshell-input-filter-functions nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
106 "Functions to call before input is processed.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 The input is contained in the region from `eshell-last-input-start' to
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 `eshell-last-input-end'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
112 (defcustom eshell-send-direct-to-subprocesses nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
113 "If t, send any input immediately to a subprocess."
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
114 :type 'boolean
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
115 :group 'eshell-mode)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
116
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (defcustom eshell-expand-input-functions nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
118 "Functions to call before input is parsed.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 Each function is passed two arguments, which bounds the region of the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 current input text."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (defcustom eshell-scroll-to-bottom-on-input nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
125 "Controls whether input to interpreter causes window to scroll.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 If nil, then do not scroll. If t or `all', scroll all windows showing
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 buffer. If `this', scroll only the selected window.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 See `eshell-preinput-scroll-to-bottom'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 :type '(radio (const :tag "Do not scroll Eshell windows" nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (const :tag "Scroll all windows showing the buffer" all)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (const :tag "Scroll only the selected window" this))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (defcustom eshell-scroll-to-bottom-on-output nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
136 "Controls whether interpreter output causes window to scroll.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 If nil, then do not scroll. If t or `all', scroll all windows showing
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 buffer. If `this', scroll only the selected window. If `others',
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 scroll only those that are not the selected window.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 See variable `eshell-scroll-show-maximum-output' and function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 `eshell-postoutput-scroll-to-bottom'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 :type '(radio (const :tag "Do not scroll Eshell windows" nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (const :tag "Scroll all windows showing the buffer" all)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (const :tag "Scroll only the selected window" this)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (const :tag "Scroll all windows other than selected" this))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 (defcustom eshell-scroll-show-maximum-output t
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
150 "Controls how interpreter output causes window to scroll.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 If non-nil, then show the maximum output when the window is scrolled.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 See variable `eshell-scroll-to-bottom-on-output' and function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 `eshell-postoutput-scroll-to-bottom'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 :type 'boolean
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (defcustom eshell-buffer-maximum-lines 1024
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
159 "The maximum size in lines for eshell buffers.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 Eshell buffers are truncated from the top to be no greater than this
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 number, if the function `eshell-truncate-buffer' is on
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 `eshell-output-filter-functions'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 :type 'integer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (defcustom eshell-output-filter-functions
78869
238c49dfaa1b (eshell-output-filter-functions): Add eshell-postoutput-scroll-to-bottom.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
167 '(eshell-postoutput-scroll-to-bottom
238c49dfaa1b (eshell-output-filter-functions): Add eshell-postoutput-scroll-to-bottom.
Glenn Morris <rgm@gnu.org>
parents: 78220
diff changeset
168 eshell-handle-control-codes
101331
562944d6149f Add eshell-handle-ansi-color to the default list of output filters.
John Wiegley <johnw@newartisans.com>
parents: 101005
diff changeset
169 eshell-handle-ansi-color
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 eshell-watch-for-password-prompt)
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
171 "Functions to call before output is displayed.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 These functions are only called for output that is displayed
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 interactively, and not for output which is redirected."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 (defcustom eshell-preoutput-filter-functions nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
178 "Functions to call before output is inserted into the buffer.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 These functions get one argument, a string containing the text to be
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 inserted. They return the string as it should be inserted."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 :type 'hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (defcustom eshell-password-prompt-regexp
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
185 "[Pp]ass\\(word\\|phrase\\).*:\\s *\\'"
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
186 "Regexp matching prompts for passwords in the inferior process.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 This is used by `eshell-watch-for-password-prompt'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 :type 'regexp
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (defcustom eshell-skip-prompt-function nil
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
192 "A function called from beginning of line to skip the prompt."
35974
0faaf71003ac (eshell-skip-prompt-function): Fix :type.
Dave Love <fx@gnu.org>
parents: 33020
diff changeset
193 :type '(choice (const nil) function)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 (defcustom eshell-status-in-modeline t
110580
f57f72bb4757 Cosmetic doc fixes for eshell.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
197 "If non-nil, let the user know a command is running in the modeline."
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 :type 'boolean
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 :group 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (defvar eshell-first-time-p t
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 "A variable which is non-nil the first time Eshell is loaded.")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 ;; Internal Variables:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 ;; these are only set to `nil' initially for the sake of the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 ;; byte-compiler, when compiling other files which `require' this one
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (defvar eshell-mode nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (defvar eshell-mode-map nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (defvar eshell-command-running-string "--")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (defvar eshell-command-map nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (defvar eshell-command-prefix nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 (defvar eshell-last-input-start nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 (defvar eshell-last-input-end nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (defvar eshell-last-output-start nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (defvar eshell-last-output-block-begin nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (defvar eshell-last-output-end nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (defvar eshell-currently-handling-window nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 (defvar eshell-mode-syntax-table nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (defvar eshell-mode-abbrev-table nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (define-abbrev-table 'eshell-mode-abbrev-table ())
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (if (not eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (let ((i 0))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (setq eshell-mode-syntax-table (make-syntax-table))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (while (< i ?0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (modify-syntax-entry i "_ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (setq i (1+ i)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (setq i (1+ ?9))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (while (< i ?A)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (modify-syntax-entry i "_ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (setq i (1+ i)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (setq i (1+ ?Z))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (while (< i ?a)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (modify-syntax-entry i "_ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (setq i (1+ i)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (setq i (1+ ?z))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 (while (< i 128)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (modify-syntax-entry i "_ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 (setq i (1+ i)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 (modify-syntax-entry ? " " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (modify-syntax-entry ?\t " " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (modify-syntax-entry ?\f " " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (modify-syntax-entry ?\n "> " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 ;; Give CR the same syntax as newline, for selective-display.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (modify-syntax-entry ?\^m "> " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 ;;; (modify-syntax-entry ?\; "< " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (modify-syntax-entry ?` "' " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (modify-syntax-entry ?' "' " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (modify-syntax-entry ?, "' " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 ;; Used to be singlequote; changed for flonums.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (modify-syntax-entry ?. "_ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (modify-syntax-entry ?- "_ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (modify-syntax-entry ?| ". " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (modify-syntax-entry ?# "' " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (modify-syntax-entry ?\" "\" " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (modify-syntax-entry ?\\ "/ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (modify-syntax-entry ?\( "() " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (modify-syntax-entry ?\) ")( " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (modify-syntax-entry ?\{ "(} " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (modify-syntax-entry ?\} "){ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (modify-syntax-entry ?\[ "(] " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (modify-syntax-entry ?\] ")[ " eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 ;; All non-word multibyte characters should be `symbol'.
86202
794e428cd497 * eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85946
diff changeset
267 (if (featurep 'xemacs)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (map-char-table
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (lambda (key val)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (and (characterp key)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (>= (char-int key) 256)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (/= (char-syntax key) ?w)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (modify-syntax-entry key "_ "
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 eshell-mode-syntax-table))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (standard-syntax-table))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (map-char-table
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (lambda (key val)
88402
3e3e42664df2 Adjusted for the change of map-char-table.
Kenichi Handa <handa@m17n.org>
parents: 43338
diff changeset
280 (and (if (consp key)
89483
2f877ed80fa6 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 88123 88402
diff changeset
281 (and (>= (car key) 128)
2f877ed80fa6 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 88123 88402
diff changeset
282 (/= (char-syntax (car key)) ?w))
88402
3e3e42664df2 Adjusted for the change of map-char-table.
Kenichi Handa <handa@m17n.org>
parents: 43338
diff changeset
283 (and (>= key 256)
3e3e42664df2 Adjusted for the change of map-char-table.
Kenichi Handa <handa@m17n.org>
parents: 43338
diff changeset
284 (/= (char-syntax key) ?w)))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (modify-syntax-entry key "_ "
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 eshell-mode-syntax-table))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (standard-syntax-table)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 ;;; User Functions:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 ;;;###autoload
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (defun eshell-mode ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 "Emacs shell interactive mode.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 \\{eshell-mode-map}"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (kill-all-local-variables)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (setq major-mode 'eshell-mode)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (setq mode-name "EShell")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (set (make-local-variable 'eshell-mode) t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (make-local-variable 'eshell-mode-map)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (setq eshell-mode-map (make-sparse-keymap))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (use-local-map eshell-mode-map)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (when eshell-status-in-modeline
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (make-local-variable 'eshell-command-running-string)
45735
642c25258945 (eshell-mode, eshell-mode): Use copy-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 43338
diff changeset
308 (let ((fmt (copy-sequence mode-line-format)))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (make-local-variable 'mode-line-format)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (setq mode-line-format fmt))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (let ((modeline (memq 'mode-line-modified mode-line-format)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (if modeline
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (setcar modeline 'eshell-command-running-string))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (define-key eshell-mode-map [return] 'eshell-send-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (define-key eshell-mode-map [(control ?m)] 'eshell-send-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (define-key eshell-mode-map [(control ?j)] 'eshell-send-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (define-key eshell-mode-map [(meta return)] 'eshell-queue-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (define-key eshell-mode-map [(meta control ?m)] 'eshell-queue-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (define-key eshell-mode-map [(meta control ?l)] 'eshell-show-output)
101332
2a6f8380eb41 Patch to change the default binding of C-a to eshell-bol. I don't think it's
John Wiegley <johnw@newartisans.com>
parents: 101331
diff changeset
321 (define-key eshell-mode-map [(control ?a)] 'eshell-bol)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (set (make-local-variable 'eshell-command-prefix)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (make-symbol "eshell-command-prefix"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (fset eshell-command-prefix (make-sparse-keymap))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (set (make-local-variable 'eshell-command-map)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (symbol-function eshell-command-prefix))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (define-key eshell-mode-map [(control ?c)] eshell-command-prefix)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
330 ;; without this, find-tag complains about read-only text being
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
331 ;; modified
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
332 (if (eq (key-binding [(meta ?.)]) 'find-tag)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
333 (define-key eshell-mode-map [(meta ?.)] 'eshell-find-tag))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (define-key eshell-command-map [(meta ?o)] 'eshell-mark-output)
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
335 (define-key eshell-command-map [(meta ?d)] 'eshell-toggle-direct-send)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (define-key eshell-command-map [(control ?a)] 'eshell-bol)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (define-key eshell-command-map [(control ?b)] 'eshell-backward-argument)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (define-key eshell-command-map [(control ?e)] 'eshell-show-maximum-output)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (define-key eshell-command-map [(control ?f)] 'eshell-forward-argument)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (define-key eshell-command-map [return] 'eshell-copy-old-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (define-key eshell-command-map [(control ?m)] 'eshell-copy-old-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (define-key eshell-command-map [(control ?o)] 'eshell-kill-output)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (define-key eshell-command-map [(control ?r)] 'eshell-show-output)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (define-key eshell-command-map [(control ?t)] 'eshell-truncate-buffer)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (define-key eshell-command-map [(control ?u)] 'eshell-kill-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (define-key eshell-command-map [(control ?w)] 'backward-kill-word)
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
348 (define-key eshell-command-map [(control ?y)] 'eshell-repeat-argument)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (setq local-abbrev-table eshell-mode-abbrev-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (set-syntax-table eshell-mode-syntax-table)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (set (make-local-variable 'dired-directory) default-directory)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (set (make-local-variable 'list-buffers-directory)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (expand-file-name default-directory))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 ;; always set the tab width to 8 in Eshell buffers, since external
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 ;; commands which do their own formatting almost always expect this
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (set (make-local-variable 'tab-width) 8)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
361 ;; don't ever use auto-fill in Eshell buffers
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
362 (setq auto-fill-function nil)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
363
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 ;; always display everything from a return value
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (if (boundp 'print-length)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (set (make-local-variable 'print-length) nil))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (if (boundp 'print-level)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (set (make-local-variable 'print-level) nil))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 ;; set require-final-newline to nil; otherwise, all redirected
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 ;; output will end with a newline, whether or not the source
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 ;; indicated it!
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (set (make-local-variable 'require-final-newline) nil)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (set (make-local-variable 'max-lisp-eval-depth)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (max 3000 max-lisp-eval-depth))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (set (make-local-variable 'max-specpdl-size)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (max 6000 max-lisp-eval-depth))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (set (make-local-variable 'eshell-last-input-start) (point-marker))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (set (make-local-variable 'eshell-last-input-end) (point-marker))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (set (make-local-variable 'eshell-last-output-start) (point-marker))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (set (make-local-variable 'eshell-last-output-end) (point-marker))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (set (make-local-variable 'eshell-last-output-block-begin) (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385
45735
642c25258945 (eshell-mode, eshell-mode): Use copy-sequence.
Richard M. Stallman <rms@gnu.org>
parents: 43338
diff changeset
386 (let ((modules-list (copy-sequence eshell-modules-list)))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (make-local-variable 'eshell-modules-list)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (setq eshell-modules-list modules-list))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 ;; load extension modules into memory. This will cause any global
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 ;; variables they define to be visible, since some of the core
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 ;; modules sometimes take advantage of their functionality if used.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (eshell-for module eshell-modules-list
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (let ((module-fullname (symbol-name module))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 module-shortname)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (if (string-match "^eshell-\\(.*\\)" module-fullname)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (setq module-shortname
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (concat "em-" (match-string 1 module-fullname))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (unless module-shortname
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (error "Invalid Eshell module name: %s" module-fullname))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (unless (featurep (intern module-shortname))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (load module-shortname))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (unless (file-exists-p eshell-directory-name)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (eshell-make-private-directory eshell-directory-name t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 ;; load core Eshell modules for this session
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (eshell-for module (eshell-subgroups 'eshell)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (run-hooks (intern-soft (concat (symbol-name module)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 "-load-hook"))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 ;; load extension modules for this session
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (eshell-for module eshell-modules-list
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (let ((load-hook (intern-soft (concat (symbol-name module)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 "-load-hook"))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (if (and load-hook (boundp load-hook))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (run-hooks load-hook))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
419 (if eshell-send-direct-to-subprocesses
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
420 (add-hook 'pre-command-hook 'eshell-intercept-commands t t))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
421
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
422 (if eshell-scroll-to-bottom-on-input
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
423 (add-hook 'pre-command-hook 'eshell-preinput-scroll-to-bottom t t))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (when eshell-scroll-show-maximum-output
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (set (make-local-variable 'scroll-conservatively) 1000))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (when eshell-status-in-modeline
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (add-hook 'eshell-pre-command-hook 'eshell-command-started nil t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (add-hook 'eshell-post-command-hook 'eshell-command-finished nil t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (add-hook 'kill-buffer-hook
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (lambda ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (run-hooks 'eshell-exit-hook))) t t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (if eshell-first-time-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (run-hooks 'eshell-first-time-mode-hook))
62760
8cd0894899dc (eshell-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents: 62332
diff changeset
439 (run-mode-hooks 'eshell-mode-hook)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (run-hooks 'eshell-post-command-hook))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (put 'eshell-mode 'mode-class 'special)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (eshell-deftest mode major-mode
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 "Major mode is correct"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (eq major-mode 'eshell-mode))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (eshell-deftest mode eshell-mode-variable
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 "`eshell-mode' is true"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (eq eshell-mode t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (eshell-deftest var window-height
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 "LINES equals window height"
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
454 (let ((eshell-stringify-t t))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
455 (eshell-command-result-p "= $LINES (window-height)" "t\n")))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (defun eshell-command-started ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 "Indicate in the modeline that a command has started."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (setq eshell-command-running-string "**")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (force-mode-line-update))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (defun eshell-command-finished ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 "Indicate in the modeline that a command has finished."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (setq eshell-command-running-string "--")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (force-mode-line-update))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (eshell-deftest mode command-running-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 "Modeline shows no command running"
86202
794e428cd497 * eshell/esh-util.el (eshell-under-xemacs-p): Remove.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85946
diff changeset
469 (or (featurep 'xemacs)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (not eshell-status-in-modeline)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (and (memq 'eshell-command-running-string mode-line-format)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (equal eshell-command-running-string "--"))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 ;;; Internal Functions:
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
476 (defun eshell-toggle-direct-send ()
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
477 (interactive)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
478 (if eshell-send-direct-to-subprocesses
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
479 (progn
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
480 (setq eshell-send-direct-to-subprocesses nil)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
481 (remove-hook 'pre-command-hook 'eshell-intercept-commands t)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
482 (message "Sending subprocess input on RET"))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
483 (setq eshell-send-direct-to-subprocesses t)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
484 (add-hook 'pre-command-hook 'eshell-intercept-commands t t)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
485 (message "Sending subprocess input directly")))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
486
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
487 (defun eshell-self-insert-command (N)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
488 (interactive "i")
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
489 (process-send-string
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
490 (eshell-interactive-process)
101005
b1e378ad4ae9 Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
491 (char-to-string (if (symbolp last-command-event)
b1e378ad4ae9 Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
492 (get last-command-event 'ascii-character)
b1e378ad4ae9 Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
493 last-command-event))))
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
494
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
495 (defun eshell-intercept-commands ()
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
496 (when (and (eshell-interactive-process)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
497 (not (and (integerp last-input-event)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
498 (memq last-input-event '(?\C-x ?\C-c)))))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
499 (let ((possible-events (where-is-internal this-command))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
500 (name (symbol-name this-command))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
501 (intercept t))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
502 ;; Assume that any multikey combination which does NOT target an
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
503 ;; Eshell command, is a combo the user wants invoked rather than
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
504 ;; sent to the underlying subprocess.
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
505 (unless (and (> (length name) 7)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
506 (equal (substring name 0 7) "eshell-"))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
507 (while possible-events
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
508 (if (> (length (car possible-events)) 1)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
509 (setq intercept nil possible-events nil)
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
510 (setq possible-events (cdr possible-events)))))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
511 (if intercept
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
512 (setq this-command 'eshell-self-insert-command)))))
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
513
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
514 (defun eshell-find-tag (&optional tagname next-p regexp-p)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
515 "A special version of `find-tag' that ignores read-onlyness."
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
516 (interactive)
31241
3099993cba0f See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31240
diff changeset
517 (require 'etags)
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
518 (let ((inhibit-read-only t)
32446
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31326
diff changeset
519 (no-default (eobp))
aab90b31807c Added better remote directory support to Eshell, as well as a few bug
John Wiegley <johnw@newartisans.com>
parents: 31326
diff changeset
520 (find-tag-default-function 'ignore))
62332
18090a2d479a (eshell-find-tag): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents: 62262
diff changeset
521 (with-no-warnings
18090a2d479a (eshell-find-tag): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents: 62262
diff changeset
522 (setq tagname (car (find-tag-interactive "Find tag: "))))
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
523 (find-tag tagname next-p regexp-p)))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
524
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (defun eshell-move-argument (limit func property arg)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 "Move forward ARG arguments."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (catch 'eshell-incomplete
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (eshell-parse-arguments (save-excursion (eshell-bol) (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (line-end-position)))
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
530 (let ((pos (save-excursion
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
531 (funcall func 1)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
532 (while (and (> arg 0) (/= (point) limit))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
533 (if (get-text-property (point) property)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
534 (setq arg (1- arg)))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
535 (if (> arg 0)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
536 (funcall func 1)))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
537 (point))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (goto-char pos)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (if (and (eq func 'forward-char)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (= (1+ pos) limit))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (forward-char 1))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (eshell-deftest arg forward-arg
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 "Move across command arguments"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (let ((here (point)) begin valid)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (eshell-bol)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (setq begin (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (eshell-forward-argument 4)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (setq valid (= here (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (eshell-backward-argument 4)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (prog1
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (and valid (= begin (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (eshell-bol)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (delete-region (point) (point-max)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (defun eshell-forward-argument (&optional arg)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 "Move forward ARG arguments."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (interactive "p")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (eshell-move-argument (point-max) 'forward-char 'arg-end arg))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (defun eshell-backward-argument (&optional arg)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 "Move backward ARG arguments."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 (interactive "p")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (eshell-move-argument (point-min) 'backward-char 'arg-begin arg))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
567 (defun eshell-repeat-argument (&optional arg)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
568 (interactive "p")
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
569 (let ((begin (save-excursion
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
570 (eshell-backward-argument arg)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
571 (point))))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
572 (kill-ring-save begin (point))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
573 (yank)))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
574
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (defun eshell-bol ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 "Goes to the beginning of line, then skips past the prompt, if any."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (interactive)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (beginning-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (and eshell-skip-prompt-function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (funcall eshell-skip-prompt-function)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (defsubst eshell-push-command-mark ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 "Push a mark at the end of the last input text."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (push-mark (1- eshell-last-input-end) t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (custom-add-option 'eshell-pre-command-hook 'eshell-push-command-mark)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (defsubst eshell-goto-input-start ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 "Goto the start of the last command input.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 Putting this function on `eshell-pre-command-hook' will mimic Plan 9's
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 9term behavior."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (goto-char eshell-last-input-start))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (custom-add-option 'eshell-pre-command-hook 'eshell-push-command-mark)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 (defsubst eshell-interactive-print (string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 "Print STRING to the eshell display buffer."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (eshell-output-filter nil string))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (defsubst eshell-begin-on-new-line ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 "This function outputs a newline if not at beginning of line."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 (goto-char eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 (or (bolp)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 (eshell-interactive-print "\n"))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 (defsubst eshell-reset (&optional no-hooks)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 "Output a prompt on a new line, aborting any current input.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 If NO-HOOKS is non-nil, then `eshell-post-command-hook' won't be run."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 (goto-char (point-max))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 (setq eshell-last-input-start (point-marker)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 eshell-last-input-end (point-marker)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 eshell-last-output-start (point-marker)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 eshell-last-output-block-begin (point)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 eshell-last-output-end (point-marker))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (eshell-begin-on-new-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 (unless no-hooks
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 (run-hooks 'eshell-post-command-hook)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 (goto-char (point-max))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 (defun eshell-parse-command-input (beg end &optional args)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 "Parse the command input from BEG to END.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 The difference is that `eshell-parse-command' expects a complete
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 command string (and will error if it doesn't get one), whereas this
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 function will inform the caller whether more input is required.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 If nil is returned, more input is necessary (probably because a
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 multi-line input string wasn't terminated properly). Otherwise, it
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 will return the parsed command."
31240
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
630 (let (delim command)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
631 (if (setq delim
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
632 (catch 'eshell-incomplete
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
633 (ignore
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
634 (setq command (eshell-parse-command (cons beg end)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
635 args t)))))
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
636 (ignore
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
637 (message "Expecting completion of delimeter %c ..."
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
638 (if (listp delim)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
639 (car delim)
10b1c85c0bbe See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 29934
diff changeset
640 delim)))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 command)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 (defun eshell-update-markers (pmark)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 "Update the input and output markers relative to point and PMARK."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 (set-marker eshell-last-input-start pmark)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 (set-marker eshell-last-input-end (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 (set-marker eshell-last-output-end (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (defun eshell-queue-input (&optional use-region)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 "Queue the current input text for execution by Eshell.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 Particularly, don't send the text to the current process, even if it's
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 waiting for input."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 (interactive "P")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 (eshell-send-input use-region t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 (eshell-deftest mode queue-input
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 "Queue command input"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 (eshell-insert-command "sleep 2")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 (eshell-insert-command "echo alpha" 'eshell-queue-input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 (let ((count 10))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 (while (and eshell-current-command
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 (> count 0))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 (sit-for 1 0)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 (setq count (1- count))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 (eshell-match-result "alpha\n"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 (defun eshell-send-input (&optional use-region queue-p no-newline)
62262
9e498efab42b (eshell-send-input): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 57929
diff changeset
668 "Send the input received to Eshell for parsing and processing.
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 After `eshell-last-output-end', sends all text from that marker to
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 point as input. Before that marker, calls `eshell-get-old-input' to
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 retrieve old input, copies it to the end of the buffer, and sends it.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 If USE-REGION is non-nil, the current region (between point and mark)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 will be used as input.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 If QUEUE-P is non-nil, input will be queued until the next prompt,
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 rather than sent to the currently active process. If no process, the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 input is processed immediately.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 If NO-NEWLINE is non-nil, the input is sent without an implied final
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 newline."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 (interactive "P")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 ;; Note that the input string does not include its terminal newline.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 (let ((proc-running-p (and (eshell-interactive-process)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 (not queue-p)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 (inhibit-point-motion-hooks t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 after-change-functions)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 (unless (and proc-running-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 (not (eq (process-status
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 (eshell-interactive-process)) 'run)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 (if (or proc-running-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 (>= (point) eshell-last-output-end))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 (goto-char (point-max))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 (let ((copy (eshell-get-old-input use-region)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 (goto-char eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 (insert-and-inherit copy)))
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
697 (unless (or no-newline
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
698 (and eshell-send-direct-to-subprocesses
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
699 proc-running-p))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 (insert-before-markers-and-inherit ?\n))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 (if proc-running-p
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 (progn
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 (eshell-update-markers eshell-last-output-end)
31326
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
704 (if (or eshell-send-direct-to-subprocesses
a36c3cf583d4 See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 31241
diff changeset
705 (= eshell-last-input-start eshell-last-input-end))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 (unless no-newline
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 (process-send-string (eshell-interactive-process) "\n"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 (process-send-region (eshell-interactive-process)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 eshell-last-input-start
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 eshell-last-input-end)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 (if (= eshell-last-output-end (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (run-hooks 'eshell-post-command-hook)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (let (input)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (eshell-condition-case err
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 (progn
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 (setq input (buffer-substring-no-properties
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 eshell-last-output-end (1- (point))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 (run-hook-with-args 'eshell-expand-input-functions
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 eshell-last-output-end (1- (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 (let ((cmd (eshell-parse-command-input
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 eshell-last-output-end (1- (point)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 (when cmd
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 (eshell-update-markers eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 (setq input (buffer-substring-no-properties
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 eshell-last-input-start
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 (1- eshell-last-input-end)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 (run-hooks 'eshell-input-filter-functions)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 (and (catch 'eshell-terminal
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 (ignore
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
730 (if (eshell-invoke-directly cmd input)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
731 (eval cmd)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 32526
diff changeset
732 (eshell-eval-command cmd input))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 (eshell-life-is-too-much)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 (quit
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (eshell-reset t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (run-hooks 'eshell-post-command-hook)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 (signal 'quit nil))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 (error
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 (eshell-reset t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 (eshell-interactive-print
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 (concat (error-message-string err) "\n"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 (run-hooks 'eshell-post-command-hook)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 (insert-and-inherit input)))))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744
38111
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
745 ; (eshell-deftest proc send-to-subprocess
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
746 ; "Send input to a subprocess"
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
747 ; ;; jww (1999-12-06): what about when bc is unavailable?
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
748 ; (if (not (eshell-search-path "bc"))
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
749 ; t
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
750 ; (eshell-insert-command "bc")
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
751 ; (eshell-insert-command "1 + 2")
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
752 ; (sit-for 1 0)
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
753 ; (forward-line -1)
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
754 ; (prog1
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
755 ; (looking-at "3\n")
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
756 ; (eshell-insert-command "quit")
737e1a913c78 Disabled a test that often yields false failures.
John Wiegley <johnw@newartisans.com>
parents: 37435
diff changeset
757 ; (sit-for 1 0))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 (defsubst eshell-kill-new ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 "Add the last input text to the kill ring."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 (kill-ring-save eshell-last-input-start eshell-last-input-end))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 (custom-add-option 'eshell-input-filter-functions 'eshell-kill-new)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 (defun eshell-output-filter (process string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 "Send the output from PROCESS (STRING) to the interactive display.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 This is done after all necessary filtering has been done."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 (let ((oprocbuf (if process (process-buffer process)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 (current-buffer)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 (inhibit-point-motion-hooks t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 after-change-functions)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 (let ((functions eshell-preoutput-filter-functions))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773 (while (and functions string)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774 (setq string (funcall (car functions) string))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 (setq functions (cdr functions))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 (if (and string oprocbuf (buffer-name oprocbuf))
79344
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
777 (let (opoint obeg oend)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
778 (with-current-buffer oprocbuf
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
779 (setq opoint (point))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
780 (setq obeg (point-min))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
781 (setq oend (point-max))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
782 (let ((buffer-read-only nil)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
783 (nchars (length string))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
784 (ostart nil))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
785 (widen)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
786 (goto-char eshell-last-output-end)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
787 (setq ostart (point))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
788 (if (<= (point) opoint)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
789 (setq opoint (+ opoint nchars)))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
790 (if (< (point) obeg)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
791 (setq obeg (+ obeg nchars)))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
792 (if (<= (point) oend)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
793 (setq oend (+ oend nchars)))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
794 (insert-before-markers string)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
795 (if (= (window-start (selected-window)) (point))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
796 (set-window-start (selected-window)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
797 (- (point) nchars)))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
798 (if (= (point) eshell-last-input-end)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
799 (set-marker eshell-last-input-end
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
800 (- eshell-last-input-end nchars)))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
801 (set-marker eshell-last-output-start ostart)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
802 (set-marker eshell-last-output-end (point))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
803 (force-mode-line-update))
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
804 (narrow-to-region obeg oend)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
805 (goto-char opoint)
c0cc9997f433 Johan Bockg? <bojohan at gnu.org>
Glenn Morris <rgm@gnu.org>
parents: 78869
diff changeset
806 (eshell-run-output-filters))))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808 (defun eshell-run-output-filters ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
809 "Run the `eshell-output-filter-functions' on the current output."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 (save-current-buffer
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811 (run-hooks 'eshell-output-filter-functions))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
812 (setq eshell-last-output-block-begin
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
813 (marker-position eshell-last-output-end)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815 ;;; jww (1999-10-23): this needs testing
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816 (defun eshell-preinput-scroll-to-bottom ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817 "Go to the end of buffer in all windows showing it.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
818 Movement occurs if point in the selected window is not after the
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 process mark, and `this-command' is an insertion command. Insertion
63513
3a1ff24e79ba (eshell-preinput-scroll-to-bottom): Fix spelling in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 62760
diff changeset
820 commands recognized are `self-insert-command', `yank', and
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 `hilit-yank'. Depends on the value of
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
822 `eshell-scroll-to-bottom-on-input'.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
823
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
824 This function should be a pre-command hook."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825 (if (memq this-command '(self-insert-command yank hilit-yank))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
826 (let* ((selected (selected-window))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 (current (current-buffer))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828 (scroll eshell-scroll-to-bottom-on-input))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 (if (< (point) eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830 (if (eq scroll 'this)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 (goto-char (point-max))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832 (walk-windows
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
833 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 (lambda (window)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
835 (when (and (eq (window-buffer window) current)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836 (or (eq scroll t) (eq scroll 'all)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (select-window window)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838 (goto-char (point-max))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 (select-window selected))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840 nil t))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 ;;; jww (1999-10-23): this needs testing
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
843 (defun eshell-postoutput-scroll-to-bottom ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 "Go to the end of buffer in all windows showing it.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845 Does not scroll if the current line is the last line in the buffer.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 Depends on the value of `eshell-scroll-to-bottom-on-output' and
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 `eshell-scroll-show-maximum-output'.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 This function should be in the list `eshell-output-filter-functions'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 (let* ((selected (selected-window))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 (current (current-buffer))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 (scroll eshell-scroll-to-bottom-on-output))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 (unwind-protect
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 (walk-windows
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 (function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 (lambda (window)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 (if (eq (window-buffer window) current)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 (progn
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 (select-window window)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 (if (and (< (point) eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 (or (eq scroll t) (eq scroll 'all)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 ;; Maybe user wants point to jump to end.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 (and (eq scroll 'this)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 (eq selected window))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 (and (eq scroll 'others)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 (not (eq selected window)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867 ;; If point was at the end, keep it at end.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 (>= (point) eshell-last-output-start)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 (goto-char eshell-last-output-end))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 ;; Optionally scroll so that the text
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 ;; ends at the bottom of the window.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 (if (and eshell-scroll-show-maximum-output
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 (>= (point) eshell-last-output-end))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 (goto-char (point-max))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (recenter -1)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 (select-window selected)))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 nil t)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 (set-buffer current))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 (defun eshell-beginning-of-input ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 "Return the location of the start of the previous input."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 eshell-last-input-start)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 (defun eshell-beginning-of-output ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 "Return the location of the end of the previous output block."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 eshell-last-input-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 (defun eshell-end-of-output ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 "Return the location of the end of the previous output block."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
891 (if (eshell-using-module 'eshell-prompt)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 eshell-last-output-start
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893 eshell-last-output-end))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 (defun eshell-kill-output ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896 "Kill all output from interpreter since last input.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 Does not delete the prompt."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 (interactive)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900 (goto-char (eshell-beginning-of-output))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 (insert "*** output flushed ***\n")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902 (delete-region (point) (eshell-end-of-output))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904 (eshell-deftest io flush-output
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905 "Flush previous output"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
906 (eshell-insert-command "echo alpha")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 (eshell-kill-output)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908 (and (eshell-match-result (regexp-quote "*** output flushed ***\n"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 (forward-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 (= (point) eshell-last-output-start)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912 (defun eshell-show-output (&optional arg)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 "Display start of this batch of interpreter output at top of window.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914 Sets mark to the value of point when this command is run.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 With a prefix argument, narrows region to last command output."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 (interactive "P")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 (goto-char (eshell-beginning-of-output))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 (set-window-start (selected-window)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920 (goto-char (eshell-beginning-of-input))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
921 (line-beginning-position)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
922 (if arg
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923 (narrow-to-region (eshell-beginning-of-output)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
924 (eshell-end-of-output)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925 (eshell-end-of-output))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
927 (defun eshell-mark-output (&optional arg)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
928 "Display start of this batch of interpreter output at top of window.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
929 Sets mark to the value of point when this command is run.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
930 With a prefix argument, narrows region to last command output."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
931 (interactive "P")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
932 (push-mark (eshell-show-output arg)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
933
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
934 (defun eshell-kill-input ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
935 "Kill all text from last stuff output by interpreter to point."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
936 (interactive)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
937 (if (> (point) eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
938 (kill-region eshell-last-output-end (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
939 (let ((here (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
940 (eshell-bol)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
941 (kill-region (point) here))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
942
57929
7cab04dc2b65 (eshell-show-maximum-output): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 53870
diff changeset
943 (defun eshell-show-maximum-output (&optional interactive)
7cab04dc2b65 (eshell-show-maximum-output): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 53870
diff changeset
944 "Put the end of the buffer at the bottom of the window.
7cab04dc2b65 (eshell-show-maximum-output): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 53870
diff changeset
945 When run interactively, widen the buffer first."
7cab04dc2b65 (eshell-show-maximum-output): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 53870
diff changeset
946 (interactive "p")
7cab04dc2b65 (eshell-show-maximum-output): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 53870
diff changeset
947 (if interactive
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
948 (widen))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
949 (goto-char (point-max))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
950 (recenter -1))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
951
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
952 (defun eshell-get-old-input (&optional use-current-region)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
953 "Return the command input on the current line."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
954 (if use-current-region
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
955 (buffer-substring (min (point) (mark))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
956 (max (point) (mark)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
957 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
958 (beginning-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
959 (and eshell-skip-prompt-function
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
960 (funcall eshell-skip-prompt-function))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
961 (let ((beg (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
962 (end-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
963 (buffer-substring beg (point))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
964
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
965 (defun eshell-copy-old-input ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
966 "Insert after prompt old input at point as new input to be edited."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
967 (interactive)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
968 (let ((input (eshell-get-old-input)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
969 (goto-char eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
970 (insert-and-inherit input)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
971
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
972 (eshell-deftest mode run-old-command
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
973 "Re-run an old command"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
974 (eshell-insert-command "echo alpha")
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
975 (goto-char eshell-last-input-start)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
976 (string= (eshell-get-old-input) "echo alpha"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
977
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
978 (defun eshell/exit ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
979 "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
980 (throw 'eshell-terminal t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
981
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
982 (defun eshell-life-is-too-much ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
983 "Kill the current buffer (or bury it). Good-bye Eshell."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
984 (interactive)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
985 (if (not eshell-kill-on-exit)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
986 (bury-buffer)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
987 (kill-buffer (current-buffer))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
988
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
989 (defun eshell-truncate-buffer ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
990 "Truncate the buffer to `eshell-buffer-maximum-lines'.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
991 This function could be on `eshell-output-filter-functions' or bound to
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
992 a key."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
993 (interactive)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
994 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
995 (goto-char eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
996 (let ((lines (count-lines 1 (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
997 (inhibit-read-only t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
998 (forward-line (- eshell-buffer-maximum-lines))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
999 (beginning-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1000 (let ((pos (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1001 (if (bobp)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 101347
diff changeset
1002 (if (called-interactively-p 'interactive)
57929
7cab04dc2b65 (eshell-show-maximum-output): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 53870
diff changeset
1003 (message "Buffer too short to truncate"))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1004 (delete-region (point-min) (point))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 101347
diff changeset
1005 (if (called-interactively-p 'interactive)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1006 (message "Truncated buffer from %d to %d lines (%.1fk freed)"
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1007 lines eshell-buffer-maximum-lines
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1008 (/ pos 1024.0))))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1009
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1010 (custom-add-option 'eshell-output-filter-functions
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1011 'eshell-truncate-buffer)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1012
38438
7b528c6c17a3 (eshell-send-invisible): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents: 38414
diff changeset
1013 (defun eshell-send-invisible (str)
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1014 "Read a string without echoing.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1015 Then send it to the process running in the current buffer."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1016 (interactive "P") ; Defeat snooping via C-x ESC ESC
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1017 (let ((str (read-passwd
53870
94735a7620dd (eshell-send-invisible): Fix format string.
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
1018 (format "%s Password: "
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1019 (process-name (eshell-interactive-process))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1020 (if (stringp str)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1021 (process-send-string (eshell-interactive-process)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1022 (concat str "\n"))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1023 (message "Warning: text will be echoed"))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1024
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1025 (defun eshell-watch-for-password-prompt ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1026 "Prompt in the minibuffer for password and send without echoing.
38438
7b528c6c17a3 (eshell-send-invisible): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents: 38414
diff changeset
1027 This function uses `eshell-send-invisible' to read and send a password to the
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1028 buffer's process if STRING contains a password prompt defined by
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1029 `eshell-password-prompt-regexp'.
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1030
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1031 This function could be in the list `eshell-output-filter-functions'."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1032 (when (eshell-interactive-process)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1033 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1034 (goto-char eshell-last-output-block-begin)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1035 (beginning-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1036 (if (re-search-forward eshell-password-prompt-regexp
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1037 eshell-last-output-end t)
38438
7b528c6c17a3 (eshell-send-invisible): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents: 38414
diff changeset
1038 (eshell-send-invisible nil)))))
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1039
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1040 (custom-add-option 'eshell-output-filter-functions
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1041 'eshell-watch-for-password-prompt)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1042
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1043 (defun eshell-handle-control-codes ()
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1044 "Act properly when certain control codes are seen."
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1045 (save-excursion
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1046 (let ((orig (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1047 (goto-char eshell-last-output-block-begin)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1048 (unless (eolp)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1049 (beginning-of-line))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1050 (while (< (point) eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1051 (let ((char (char-after)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1052 (cond
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1053 ((eq char ?\r)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1054 (if (< (1+ (point)) eshell-last-output-end)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1055 (if (memq (char-after (1+ (point)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1056 '(?\n ?\r))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1057 (delete-char 1)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1058 (let ((end (1+ (point))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1059 (beginning-of-line)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1060 (delete-region (point) end)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1061 (add-text-properties (point) (1+ (point))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1062 '(invisible t))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1063 (forward-char)))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1064 ((eq char ?\a)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1065 (delete-char 1)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1066 (beep))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1067 ((eq char ?\C-h)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1068 (delete-backward-char 1)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1069 (delete-char 1))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1070 (t
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1071 (forward-char))))))))
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1072
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1073 (custom-add-option 'eshell-output-filter-functions
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1074 'eshell-handle-control-codes)
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1075
105831
064a30d48e7e (ansi-color-apply-on-region): Autoload it...
Glenn Morris <rgm@gnu.org>
parents: 105372
diff changeset
1076 (autoload 'ansi-color-apply-on-region "ansi-color")
064a30d48e7e (ansi-color-apply-on-region): Autoload it...
Glenn Morris <rgm@gnu.org>
parents: 105372
diff changeset
1077
76468
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1078 (defun eshell-handle-ansi-color ()
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1079 "Handle ANSI color codes."
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1080 (ansi-color-apply-on-region eshell-last-output-start
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1081 eshell-last-output-end))
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1082
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1083 (custom-add-option 'eshell-output-filter-functions
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1084 'eshell-handle-ansi-color)
b32293a2b36f eshell ansi-color hook
Mark A. Hershberger <mah@everybody.org>
parents: 75346
diff changeset
1085
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91327
diff changeset
1086 ;; arch-tag: ec65bc2b-da14-4547-81d3-a32af3a4dc57
29870
ccc03e321fdf *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1087 ;;; esh-mode.el ends here