Mercurial > emacs
annotate lisp/shell.el @ 9244:853d760cba83
(shell-strip-ctrl-m): Function moved to comint.el and renamed.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 03 Oct 1994 01:10:57 +0000 |
| parents | a55d058e5e1a |
| children | c4fa081b416e |
| rev | line source |
|---|---|
|
925
6295ac3be480
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
844
diff
changeset
|
1 ;;; shell.el --- specialized comint.el for running the shell. |
|
6887
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
2 |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
3 ;; Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc. |
|
844
bf829a2d63b4
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
4 |
|
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
5 ;; Author: Olin Shivers <shivers@cs.cmu.edu> |
|
6189
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
6 ;; Maintainer: Simon Marshall <s.marshall@dcs.hull.ac.uk> |
|
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: processes |
|
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
8 |
|
6887
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
10 |
|
6887
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
14 ;; any later version. |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
15 |
|
6887
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
19 ;; GNU General Public License for more details. |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
20 |
|
6887
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 114 | 24 |
|
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
25 ;;; Commentary: |
|
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
26 |
| 252 | 27 ;;; Please send me bug reports, bug fixes, and extensions, so that I can |
| 28 ;;; merge them into the master source. | |
| 29 ;;; - Olin Shivers (shivers@cs.cmu.edu) | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
30 ;;; - Simon Marshall (s.marshall@dcs.hull.ac.uk) |
| 114 | 31 |
| 252 | 32 ;;; This file defines a a shell-in-a-buffer package (shell mode) built |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
33 ;;; on top of comint mode. This is actually cmushell with things |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
34 ;;; renamed to replace its counterpart in Emacs 18. cmushell is more |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
35 ;;; featureful, robust, and uniform than the Emacs 18 version. |
| 114 | 36 |
| 37 ;;; Since this mode is built on top of the general command-interpreter-in- | |
| 38 ;;; a-buffer mode (comint mode), it shares a common base functionality, | |
| 39 ;;; and a common set of bindings, with all modes derived from comint mode. | |
| 252 | 40 ;;; This makes these modes easier to use. |
| 114 | 41 |
| 42 ;;; For documentation on the functionality provided by comint mode, and | |
| 43 ;;; the hooks available for customising it, see the file comint.el. | |
| 252 | 44 ;;; For further information on shell mode, see the comments below. |
| 114 | 45 |
| 46 ;;; Needs fixin: | |
| 47 ;;; When sending text from a source file to a subprocess, the process-mark can | |
| 48 ;;; move off the window, so you can lose sight of the process interactions. | |
| 49 ;;; Maybe I should ensure the process mark is in the window when I send | |
| 50 ;;; text to the process? Switch selectable? | |
| 51 | |
| 252 | 52 ;; YOUR .EMACS FILE |
| 53 ;;============================================================================= | |
| 54 ;; Some suggestions for your .emacs file. | |
| 55 ;; | |
| 5163 | 56 ;; ;; Define C-c t to run my favorite command in shell mode: |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
57 ;; (setq shell-mode-hook |
| 252 | 58 ;; '((lambda () |
|
2351
bb1ff4e31fb6
Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1801
diff
changeset
|
59 ;; (define-key shell-mode-map "\C-ct" 'favorite-cmd)))) |
| 252 | 60 |
| 61 | |
| 62 ;;; Brief Command Documentation: | |
| 63 ;;;============================================================================ | |
| 64 ;;; Comint Mode Commands: (common to shell and all comint-derived modes) | |
| 65 ;;; | |
| 66 ;;; m-p comint-previous-input Cycle backwards in input history | |
| 67 ;;; m-n comint-next-input Cycle forwards | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
68 ;;; m-r comint-previous-matching-input Previous input matching a regexp |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
69 ;;; m-R comint-previous-matching-input-from-input -"- matching input |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
70 ;;; m-s comint-next-matching-input Next input that matches |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
71 ;;; m-S comint-next-matching-input-from-input -"- matching input |
|
5285
6c3cfa1f8188
(shell-mode): Pass t to comint-read-input-ring.
Richard M. Stallman <rms@gnu.org>
parents:
5163
diff
changeset
|
72 ;;; m-c-l comint-show-output Show last batch of process output |
| 252 | 73 ;;; return comint-send-input |
| 74 ;;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff. | |
| 8267 | 75 ;;; c-c c-a comint-bol Beginning of line; skip prompt |
| 252 | 76 ;;; c-c c-u comint-kill-input ^u |
| 77 ;;; c-c c-w backward-kill-word ^w | |
| 78 ;;; c-c c-c comint-interrupt-subjob ^c | |
| 79 ;;; c-c c-z comint-stop-subjob ^z | |
| 80 ;;; c-c c-\ comint-quit-subjob ^\ | |
| 81 ;;; c-c c-o comint-kill-output Delete last batch of process output | |
| 82 ;;; c-c c-r comint-show-output Show last batch of process output | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
83 ;;; c-c c-h comint-dynamic-list-input-ring List input history |
| 252 | 84 ;;; send-invisible Read line w/o echo & send to proc |
| 85 ;;; comint-continue-subjob Useful if you accidentally suspend | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
86 ;;; top-level job |
| 252 | 87 ;;; comint-mode-hook is the comint mode hook. |
| 88 | |
| 89 ;;; Shell Mode Commands: | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
90 ;;; shell Fires up the shell process |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
91 ;;; tab comint-dynamic-complete Complete filename/command/history |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
92 ;;; m-? comint-dynamic-list-filename-completions List completions in help buffer |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
93 ;;; m-c-f shell-forward-command Forward a shell command |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
94 ;;; m-c-b shell-backward-command Backward a shell command |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
95 ;;; dirs Resync the buffer's dir stack |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
96 ;;; dirtrack-toggle Turn dir tracking on/off |
| 252 | 97 ;;; |
| 98 ;;; The shell mode hook is shell-mode-hook | |
| 99 ;;; comint-prompt-regexp is initialised to shell-prompt-pattern, for backwards | |
| 100 ;;; compatibility. | |
| 101 | |
| 102 ;;; Read the rest of this file for more information. | |
| 103 | |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
104 ;;; SHELL.EL COMPATIBILITY |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
105 ;;; Notes from when this was called cmushell, and was not the standard emacs |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
106 ;;; shell package. |
| 252 | 107 ;;;============================================================================ |
| 108 ;;; In brief: this package should have no trouble coexisting with shell.el. | |
| 109 ;;; | |
| 110 ;;; Most customising variables -- e.g., explicit-shell-file-name -- are the | |
| 111 ;;; same, so the users shouldn't have much trouble. Hooks have different | |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
112 ;;; names, however, so you can customise shell mode differently from cmushell |
| 252 | 113 ;;; mode. You basically just have to remember to type M-x cmushell instead of |
| 114 ;;; M-x shell. | |
| 115 ;;; | |
| 116 ;;; It would be nice if this file was completely plug-compatible with the old | |
| 117 ;;; shell package -- if you could just name this file shell.el, and have it | |
| 118 ;;; transparently replace the old one. But you can't. Several other packages | |
| 119 ;;; (tex-mode, background, dbx, gdb, kermit, monkey, prolog, telnet) are also | |
| 120 ;;; clients of shell mode. These packages assume detailed knowledge of shell | |
| 121 ;;; mode internals in ways that are incompatible with cmushell mode (mostly | |
| 122 ;;; because of cmushell mode's greater functionality). So, unless we are | |
| 123 ;;; willing to port all of these packages, we can't have this file be a | |
| 124 ;;; complete replacement for shell.el -- that is, we can't name this file | |
| 125 ;;; shell.el, and its main entry point (shell), because dbx.el will break | |
| 126 ;;; when it loads it in and tries to use it. | |
| 127 ;;; | |
| 128 ;;; There are two ways to fix this. One: rewrite these other modes to use the | |
| 129 ;;; new package. This is a win, but can't be assumed. The other, backwards | |
| 130 ;;; compatible route, is to make this package non-conflict with shell.el, so | |
| 131 ;;; both files can be loaded in at the same time. And *that* is why some | |
| 132 ;;; functions and variables have different names: (cmushell), | |
| 133 ;;; cmushell-mode-map, that sort of thing. All the names have been carefully | |
| 134 ;;; chosen so that shell.el and cmushell.el won't tromp on each other. | |
| 135 | |
|
2557
a212ee1907fe
(shell-mode): isationization (doc fix).
Roland McGrath <roland@gnu.org>
parents:
2556
diff
changeset
|
136 ;;; Customization and Buffer Variables |
| 252 | 137 ;;; =========================================================================== |
| 138 ;;; | |
| 139 | |
|
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
140 ;;; Code: |
|
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
141 |
|
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
142 (require 'comint) |
|
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
143 |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
144 ;;;###autoload |
|
4131
c9a0f06110bd
* shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents:
3418
diff
changeset
|
145 (defvar shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" |
| 252 | 146 "Regexp to match prompts in the inferior shell. |
|
4131
c9a0f06110bd
* shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents:
3418
diff
changeset
|
147 Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
148 This variable is used to initialise `comint-prompt-regexp' in the |
| 252 | 149 shell buffer. |
| 150 | |
|
4131
c9a0f06110bd
* shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents:
3418
diff
changeset
|
151 The pattern should probably not match more than one line. If it does, |
|
c9a0f06110bd
* shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents:
3418
diff
changeset
|
152 shell-mode may become confused trying to distinguish prompt from input |
|
c9a0f06110bd
* shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents:
3418
diff
changeset
|
153 on lines which don't start with a prompt. |
|
c9a0f06110bd
* shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents:
3418
diff
changeset
|
154 |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
155 This is a fine thing to set in your `.emacs' file.") |
| 252 | 156 |
|
6255
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
157 (defvar shell-completion-fignore nil |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
158 "*List of suffixes to be disregarded during file/command completion. |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
159 This variable is used to initialize `comint-completion-fignore' in the shell |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
160 buffer. The default is nil, for compatibility with most shells. |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
161 Some people like (\"~\" \"#\" \"%\"). |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
162 |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
163 This is a fine thing to set in your `.emacs' file.") |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
164 |
|
6155
2b445a954b0b
(shell-delimiter-argument-list): Now has chars, not strings.
Richard M. Stallman <rms@gnu.org>
parents:
6152
diff
changeset
|
165 (defvar shell-delimiter-argument-list '(?\| ?& ?< ?> ?\( ?\) ?\;) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
166 "List of characters to recognise as separate arguments. |
|
6155
2b445a954b0b
(shell-delimiter-argument-list): Now has chars, not strings.
Richard M. Stallman <rms@gnu.org>
parents:
6152
diff
changeset
|
167 This variable is used to initialize `comint-delimiter-argument-list' in the |
|
2b445a954b0b
(shell-delimiter-argument-list): Now has chars, not strings.
Richard M. Stallman <rms@gnu.org>
parents:
6152
diff
changeset
|
168 shell buffer. The default is (?\\| ?& ?< ?> ?\\( ?\\) ?\\;). |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
169 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
170 This is a fine thing to set in your `.emacs' file.") |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
171 |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
172 (defvar shell-dynamic-complete-functions |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
173 '(comint-replace-by-expanded-history |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
174 shell-dynamic-complete-environment-variable |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
175 shell-dynamic-complete-command |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
176 shell-replace-by-expanded-directory |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
177 comint-dynamic-complete-filename) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
178 "List of functions called to perform completion. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
179 This variable is used to initialise `comint-dynamic-complete-functions' in the |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
180 shell buffer. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
181 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
182 This is a fine thing to set in your `.emacs' file.") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
183 |
|
8694
67f6d4905d8c
(shell-command-regexp): Use a simpler faster regexp.
Richard M. Stallman <rms@gnu.org>
parents:
8267
diff
changeset
|
184 (defvar shell-command-regexp "[^;&|\n]+" |
|
67f6d4905d8c
(shell-command-regexp): Use a simpler faster regexp.
Richard M. Stallman <rms@gnu.org>
parents:
8267
diff
changeset
|
185 "*Regexp to match a single command within a pipeline. |
|
67f6d4905d8c
(shell-command-regexp): Use a simpler faster regexp.
Richard M. Stallman <rms@gnu.org>
parents:
8267
diff
changeset
|
186 This is used for directory tracking and does not do a perfect job.") |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
187 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
188 (defvar shell-completion-execonly t |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
189 "*If non-nil, use executable files only for completion candidates. |
| 4938 | 190 This mirrors the optional behavior of tcsh. |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
191 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
192 Detecting executability of files may slow command completion considerably.") |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
193 |
| 114 | 194 (defvar shell-popd-regexp "popd" |
| 195 "*Regexp to match subshell commands equivalent to popd.") | |
| 196 | |
| 197 (defvar shell-pushd-regexp "pushd" | |
| 198 "*Regexp to match subshell commands equivalent to pushd.") | |
| 199 | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
200 (defvar shell-pushd-tohome nil |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
201 "*If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd). |
| 4938 | 202 This mirrors the optional behavior of tcsh.") |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
203 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
204 (defvar shell-pushd-dextract nil |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
205 "*If non-nil, make \"pushd +n\" pop the nth dir to the stack top. |
| 4938 | 206 This mirrors the optional behavior of tcsh.") |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
207 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
208 (defvar shell-pushd-dunique nil |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
209 "*If non-nil, make pushd only add unique directories to the stack. |
| 4938 | 210 This mirrors the optional behavior of tcsh.") |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
211 |
| 114 | 212 (defvar shell-cd-regexp "cd" |
| 213 "*Regexp to match subshell commands equivalent to cd.") | |
| 214 | |
| 215 (defvar explicit-shell-file-name nil | |
| 216 "*If non-nil, is file name to use for explicitly requested inferior shell.") | |
| 217 | |
| 218 (defvar explicit-csh-args | |
| 219 (if (eq system-type 'hpux) | |
| 220 ;; -T persuades HP's csh not to think it is smarter | |
| 221 ;; than us about what terminal modes to use. | |
| 222 '("-i" "-T") | |
| 223 '("-i")) | |
| 224 "*Args passed to inferior shell by M-x shell, if the shell is csh. | |
| 225 Value is a list of strings, which may be nil.") | |
| 226 | |
|
5538
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
227 (defvar shell-input-autoexpand 'history |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
228 "*If non-nil, expand input command history references on completion. |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
229 This mirrors the optional behavior of tcsh (its autoexpand and histlit). |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
230 |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
231 If the value is `input', then the expansion is seen on input. |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
232 If the value is `history', then the expansion is only when inserting |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
233 into the buffer's input ring. See also `comint-magic-space' and |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
234 `comint-dynamic-complete'. |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
235 |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
236 This variable supplies a default for `comint-input-autoexpand', |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
237 for Shell mode only.") |
|
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
238 |
| 114 | 239 (defvar shell-dirstack nil |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
240 "List of directories saved by pushd in this buffer's shell. |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
241 Thus, this does not include the shell's current directory.") |
| 114 | 242 |
|
6152
34d9a0aa80d1
(shell-dirtrackp): Variable definition added.
Richard M. Stallman <rms@gnu.org>
parents:
6150
diff
changeset
|
243 (defvar shell-dirtrackp t |
|
34d9a0aa80d1
(shell-dirtrackp): Variable definition added.
Richard M. Stallman <rms@gnu.org>
parents:
6150
diff
changeset
|
244 "Non-nil in a shell buffer means directory tracking is enabled.") |
|
34d9a0aa80d1
(shell-dirtrackp): Variable definition added.
Richard M. Stallman <rms@gnu.org>
parents:
6150
diff
changeset
|
245 |
|
2351
bb1ff4e31fb6
Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1801
diff
changeset
|
246 (defvar shell-last-dir nil |
|
bb1ff4e31fb6
Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1801
diff
changeset
|
247 "Keep track of last directory for ksh `cd -' command.") |
|
bb1ff4e31fb6
Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1801
diff
changeset
|
248 |
|
7083
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
249 (defvar shell-dirstack-query nil |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
250 "Command used by `shell-resync-dir' to query the shell.") |
| 114 | 251 |
|
6150
c1dde384f0dd
(shell-mode-map): Use copy-keymap.
Richard M. Stallman <rms@gnu.org>
parents:
5880
diff
changeset
|
252 (defvar shell-mode-map nil) |
| 114 | 253 (cond ((not shell-mode-map) |
|
8889
323936455525
(shell-mode-map): Inherit comint-mode-map, but copy the completion menu.
Richard M. Stallman <rms@gnu.org>
parents:
8694
diff
changeset
|
254 (setq shell-mode-map (nconc (make-sparse-keymap) comint-mode-map)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
255 (define-key shell-mode-map "\C-c\C-f" 'shell-forward-command) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
256 (define-key shell-mode-map "\C-c\C-b" 'shell-backward-command) |
| 114 | 257 (define-key shell-mode-map "\t" 'comint-dynamic-complete) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
258 (define-key shell-mode-map "\M-?" |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
259 'comint-dynamic-list-filename-completions) |
|
8889
323936455525
(shell-mode-map): Inherit comint-mode-map, but copy the completion menu.
Richard M. Stallman <rms@gnu.org>
parents:
8694
diff
changeset
|
260 (define-key shell-mode-map [menu-bar completion] |
|
323936455525
(shell-mode-map): Inherit comint-mode-map, but copy the completion menu.
Richard M. Stallman <rms@gnu.org>
parents:
8694
diff
changeset
|
261 (copy-keymap (lookup-key comint-mode-map [menu-bar completion]))) |
|
6887
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
262 (define-key-after (lookup-key shell-mode-map [menu-bar completion]) |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
263 [complete-env-variable] '("Complete Env. Variable Name" . |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
264 shell-dynamic-complete-environment-variable) |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
265 'complete-file) |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
266 (define-key-after (lookup-key shell-mode-map [menu-bar completion]) |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
267 [expand-directory] '("Expand Directory Reference" . |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
268 shell-replace-by-expanded-directory) |
|
9888d3b32db3
(shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents:
6885
diff
changeset
|
269 'complete-expand))) |
| 114 | 270 |
| 271 (defvar shell-mode-hook '() | |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
272 "*Hook for customising Shell mode.") |
| 114 | 273 |
| 274 | |
| 275 ;;; Basic Procedures | |
| 276 ;;; =========================================================================== | |
| 277 ;;; | |
| 278 | |
| 279 (defun shell-mode () | |
| 280 "Major mode for interacting with an inferior shell. | |
| 281 Return after the end of the process' output sends the text from the | |
| 282 end of process to the end of the current line. | |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
283 Return before end of process output copies the current line (except |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
284 for the prompt) to the end of the buffer and sends it. |
| 114 | 285 M-x send-invisible reads a line of text without echoing it, and sends it to |
|
6508
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
286 the shell. This is useful for entering passwords. Or, add the function |
|
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
287 `comint-watch-for-password-prompt' to `comint-output-filter-functions'. |
| 114 | 288 |
| 289 If you accidentally suspend your process, use \\[comint-continue-subjob] | |
| 290 to continue it. | |
| 291 | |
| 292 cd, pushd and popd commands given to the shell are watched by Emacs to keep | |
| 293 this buffer's default directory the same as the shell's working directory. | |
| 294 M-x dirs queries the shell and resyncs Emacs' idea of what the current | |
| 295 directory stack is. | |
| 296 M-x dirtrack-toggle turns directory tracking on and off. | |
| 297 | |
| 298 \\{shell-mode-map} | |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
299 Customization: Entry to this mode runs the hooks on `comint-mode-hook' and |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
300 `shell-mode-hook' (in that order). Before each input, the hooks on |
|
6189
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
301 `comint-input-filter-functions' are run. After each shell output, the hooks |
|
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
302 on `comint-output-filter-functions' are run. |
| 114 | 303 |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
304 Variables `shell-cd-regexp', `shell-pushd-regexp' and `shell-popd-regexp' |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
305 are used to match their respective commands, while `shell-pushd-tohome', |
| 4938 | 306 `shell-pushd-dextract' and `shell-pushd-dunique' control the behavior of the |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
307 relevant command. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
308 |
|
6255
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
309 Variables `comint-completion-autolist', `comint-completion-addsuffix', |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
310 `comint-completion-recexact' and `comint-completion-fignore' control the |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
311 behavior of file name, command name and variable name completion. Variable |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
312 `shell-completion-execonly' controls the behavior of command name completion. |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
313 Variable `shell-completion-fignore' is used to initialise the value of |
|
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
314 `comint-completion-fignore'. |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
315 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
316 Variables `comint-input-ring-file-name' and `comint-input-autoexpand' control |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
317 the initialisation of the input ring history, and history expansion. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
318 |
|
6189
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
319 Variables `comint-output-filter-functions', a hook, and |
|
6255
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
320 `comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output' |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
321 control whether input and output cause the window to scroll to the end of the |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
322 buffer." |
| 114 | 323 (interactive) |
| 324 (comint-mode) | |
| 252 | 325 (setq major-mode 'shell-mode) |
|
2556
8b6c3d4256a0
(shell-mode): Capitalize mode name.
Roland McGrath <roland@gnu.org>
parents:
2469
diff
changeset
|
326 (setq mode-name "Shell") |
| 114 | 327 (use-local-map shell-mode-map) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
328 (setq comint-prompt-regexp shell-prompt-pattern) |
|
6255
277d9ace9f5d
(shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6189
diff
changeset
|
329 (setq comint-completion-fignore shell-completion-fignore) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
330 (setq comint-delimiter-argument-list shell-delimiter-argument-list) |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
331 (setq comint-dynamic-complete-functions shell-dynamic-complete-functions) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
332 (make-local-variable 'paragraph-start) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
333 (setq paragraph-start comint-prompt-regexp) |
| 114 | 334 (make-local-variable 'shell-dirstack) |
| 252 | 335 (setq shell-dirstack nil) |
|
2351
bb1ff4e31fb6
Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1801
diff
changeset
|
336 (setq shell-last-dir nil) |
| 252 | 337 (make-local-variable 'shell-dirtrackp) |
| 338 (setq shell-dirtrackp t) | |
|
6189
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
339 (add-hook 'comint-input-filter-functions 'shell-directory-tracker) |
|
5538
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
340 (setq comint-input-autoexpand shell-input-autoexpand) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
341 ;; shell-dependent assignments. |
|
7083
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
342 (let ((shell (file-name-nondirectory (car |
|
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
343 (process-command (get-buffer-process (current-buffer))))))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
344 (setq comint-input-ring-file-name |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
345 (or (getenv "HISTFILE") |
|
7083
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
346 (cond ((string-equal shell "bash") "~/.bash_history") |
|
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
347 ((string-equal shell "ksh") "~/.sh_history") |
|
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
348 (t "~/.history")))) |
|
9235
a55d058e5e1a
(shell-mode): Compare the truename with /dev/null.
Richard M. Stallman <rms@gnu.org>
parents:
8889
diff
changeset
|
349 (if (equal (file-truename comint-input-ring-file-name) "/dev/null") |
|
8111
04ba433263d8
(shell-mode): Don't read history from /dev/null.
Richard M. Stallman <rms@gnu.org>
parents:
8033
diff
changeset
|
350 (setq comint-input-ring-file-name nil)) |
|
7083
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
351 (setq shell-dirstack-query |
|
9630c48595d8
(shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents:
6887
diff
changeset
|
352 (if (string-match "^k?sh$" shell) "pwd" "dirs"))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
353 (run-hooks 'shell-mode-hook) |
|
5538
9d84549e89b4
(shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5474
diff
changeset
|
354 (comint-read-input-ring t)) |
| 114 | 355 |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
356 ;;;###autoload |
| 114 | 357 (defun shell () |
| 358 "Run an inferior shell, with I/O through buffer *shell*. | |
| 359 If buffer exists but shell process is not running, make new shell. | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
360 If buffer exists and shell process is running, just switch to buffer `*shell*'. |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
361 Program used comes from variable `explicit-shell-file-name', |
| 252 | 362 or (if that is nil) from the ESHELL environment variable, |
| 363 or else from SHELL if there is no ESHELL. | |
| 1076 | 364 If a file `~/.emacs_SHELLNAME' exists, it is given as initial input |
| 252 | 365 (Note that this may lose due to a timing error if the shell |
| 366 discards input when it starts up.) | |
| 1076 | 367 The buffer is put in Shell mode, giving commands for sending input |
| 368 and controlling the subjobs of the shell. See `shell-mode'. | |
| 369 See also the variable `shell-prompt-pattern'. | |
| 114 | 370 |
| 252 | 371 The shell file name (sans directories) is used to make a symbol name |
| 1801 | 372 such as `explicit-csh-args'. If that symbol is a variable, |
| 114 | 373 its value is used as a list of arguments when invoking the shell. |
| 374 Otherwise, one argument `-i' is passed to the shell. | |
| 375 | |
| 376 \(Type \\[describe-mode] in the shell buffer for a list of commands.)" | |
| 377 (interactive) | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
378 (if (not (comint-check-proc "*shell*")) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
379 (let* ((prog (or explicit-shell-file-name |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
380 (getenv "ESHELL") |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
381 (getenv "SHELL") |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
382 "/bin/sh")) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
383 (name (file-name-nondirectory prog)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
384 (startfile (concat "~/.emacs_" name)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
385 (xargs-name (intern-soft (concat "explicit-" name "-args")))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
386 (set-buffer (apply 'make-comint "shell" prog |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
387 (if (file-exists-p startfile) startfile) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
388 (if (and xargs-name (boundp xargs-name)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
389 (symbol-value xargs-name) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
390 '("-i")))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
391 (shell-mode))) |
| 114 | 392 (switch-to-buffer "*shell*")) |
| 393 | |
| 394 ;;; Directory tracking | |
| 395 ;;; =========================================================================== | |
| 396 ;;; This code provides the shell mode input sentinel | |
| 397 ;;; SHELL-DIRECTORY-TRACKER | |
| 398 ;;; that tracks cd, pushd, and popd commands issued to the shell, and | |
| 399 ;;; changes the current directory of the shell buffer accordingly. | |
| 400 ;;; | |
| 401 ;;; This is basically a fragile hack, although it's more accurate than | |
| 2469 | 402 ;;; the version in Emacs 18's shell.el. It has the following failings: |
| 114 | 403 ;;; 1. It doesn't know about the cdpath shell variable. |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
404 ;;; 2. It cannot infallibly deal with command sequences, though it does well |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
405 ;;; with these and with ignoring commands forked in another shell with ()s. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
406 ;;; 3. More generally, any complex command is going to throw it. Otherwise, |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
407 ;;; you'd have to build an entire shell interpreter in emacs lisp. Failing |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
408 ;;; that, there's no way to catch shell commands where cd's are buried |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
409 ;;; inside conditional expressions, aliases, and so forth. |
| 114 | 410 ;;; |
| 411 ;;; The whole approach is a crock. Shell aliases mess it up. File sourcing | |
| 412 ;;; messes it up. You run other processes under the shell; these each have | |
| 413 ;;; separate working directories, and some have commands for manipulating | |
| 414 ;;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have | |
| 252 | 415 ;;; commands that do *not* affect the current w.d. at all, but look like they |
| 114 | 416 ;;; do (e.g., the cd command in ftp). In shells that allow you job |
| 417 ;;; control, you can switch between jobs, all having different w.d.'s. So | |
| 418 ;;; simply saying %3 can shift your w.d.. | |
| 419 ;;; | |
| 420 ;;; The solution is to relax, not stress out about it, and settle for | |
| 421 ;;; a hack that works pretty well in typical circumstances. Remember | |
| 422 ;;; that a half-assed solution is more in keeping with the spirit of Unix, | |
| 423 ;;; anyway. Blech. | |
| 424 ;;; | |
| 425 ;;; One good hack not implemented here for users of programmable shells | |
| 426 ;;; is to program up the shell w.d. manipulation commands to output | |
| 427 ;;; a coded command sequence to the tty. Something like | |
| 428 ;;; ESC | <cwd> | | |
| 429 ;;; where <cwd> is the new current working directory. Then trash the | |
| 430 ;;; directory tracking machinery currently used in this package, and | |
| 431 ;;; replace it with a process filter that watches for and strips out | |
| 432 ;;; these messages. | |
| 433 | |
| 434 (defun shell-directory-tracker (str) | |
| 435 "Tracks cd, pushd and popd commands issued to the shell. | |
| 436 This function is called on each input passed to the shell. | |
| 437 It watches for cd, pushd and popd commands and sets the buffer's | |
| 438 default directory to track these commands. | |
| 439 | |
| 440 You may toggle this tracking on and off with M-x dirtrack-toggle. | |
| 441 If emacs gets confused, you can resync with the shell with M-x dirs. | |
| 442 | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
443 See variables `shell-cd-regexp', `shell-pushd-regexp', and `shell-popd-regexp', |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
444 while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique' |
| 4938 | 445 control the behavior of the relevant command. |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
446 |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
447 Environment variables are expanded, see function `substitute-in-file-name'." |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
448 (if shell-dirtrackp |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
449 ;; We fail gracefully if we think the command will fail in the shell. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
450 (condition-case chdir-failure |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
451 (let ((start (progn (string-match "^[;\\s ]*" str) ; skip whitespace |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
452 (match-end 0))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
453 end cmd arg1) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
454 (while (string-match shell-command-regexp str start) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
455 (setq end (match-end 0) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
456 cmd (comint-arguments (substring str start end) 0 0) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
457 arg1 (comint-arguments (substring str start end) 1 1)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
458 (cond ((eq (string-match shell-popd-regexp cmd) 0) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
459 (shell-process-popd (substitute-in-file-name arg1))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
460 ((eq (string-match shell-pushd-regexp cmd) 0) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
461 (shell-process-pushd (substitute-in-file-name arg1))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
462 ((eq (string-match shell-cd-regexp cmd) 0) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
463 (shell-process-cd (substitute-in-file-name arg1)))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
464 (setq start (progn (string-match "[;\\s ]*" str end) ; skip again |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
465 (match-end 0))))) |
|
6189
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
466 (error "Couldn't cd")))) |
| 114 | 467 |
| 468 ;;; popd [+n] | |
| 469 (defun shell-process-popd (arg) | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
470 (let ((num (or (shell-extract-num arg) 0))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
471 (cond ((and num (= num 0) shell-dirstack) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
472 (cd (car shell-dirstack)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
473 (setq shell-dirstack (cdr shell-dirstack)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
474 (shell-dirstack-message)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
475 ((and num (> num 0) (<= num (length shell-dirstack))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
476 (let* ((ds (cons nil shell-dirstack)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
477 (cell (nthcdr (1- num) ds))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
478 (rplacd cell (cdr (cdr cell))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
479 (setq shell-dirstack (cdr ds)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
480 (shell-dirstack-message))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
481 (t |
|
6189
4ff931c18e4b
Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents:
6186
diff
changeset
|
482 (error "Couldn't popd"))))) |
| 114 | 483 |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
484 ;; Return DIR prefixed with comint-file-name-prefix as appropriate. |
|
8033
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
485 (defun shell-prefixed-directory-name (dir) |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
486 (if (= (length comint-file-name-prefix) 0) |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
487 dir |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
488 (if (file-name-absolute-p dir) |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
489 ;; The name is absolute, so prepend the prefix. |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
490 (concat comint-file-name-prefix dir) |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
491 ;; For a relative name we assume default-directory already has the prefix. |
|
bedead77e86f
(shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents:
7610
diff
changeset
|
492 (expand-file-name dir)))) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
493 |
| 114 | 494 ;;; cd [dir] |
| 495 (defun shell-process-cd (arg) | |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
496 (let ((new-dir (cond ((zerop (length arg)) (concat comint-file-name-prefix |
|
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
497 "~")) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
498 ((string-equal "-" arg) shell-last-dir) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
499 (t (shell-prefixed-directory-name arg))))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
500 (setq shell-last-dir default-directory) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
501 (cd new-dir) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
502 (shell-dirstack-message))) |
| 114 | 503 |
| 504 ;;; pushd [+n | dir] | |
| 505 (defun shell-process-pushd (arg) | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
506 (let ((num (shell-extract-num arg))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
507 (cond ((zerop (length arg)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
508 ;; no arg -- swap pwd and car of stack unless shell-pushd-tohome |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
509 (cond (shell-pushd-tohome |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
510 (shell-process-pushd (concat comint-file-name-prefix "~"))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
511 (shell-dirstack |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
512 (let ((old default-directory)) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
513 (cd (car shell-dirstack)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
514 (setq shell-dirstack |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
515 (cons old (cdr shell-dirstack))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
516 (shell-dirstack-message))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
517 (t |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
518 (message "Directory stack empty.")))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
519 ((numberp num) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
520 ;; pushd +n |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
521 (cond ((> num (length shell-dirstack)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
522 (message "Directory stack not that deep.")) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
523 ((= num 0) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
524 (error (message "Couldn't cd."))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
525 (shell-pushd-dextract |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
526 (let ((dir (nth (1- num) shell-dirstack))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
527 (shell-process-popd arg) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
528 (shell-process-pushd default-directory) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
529 (cd dir) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
530 (shell-dirstack-message))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
531 (t |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
532 (let* ((ds (cons default-directory shell-dirstack)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
533 (dslen (length ds)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
534 (front (nthcdr num ds)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
535 (back (reverse (nthcdr (- dslen num) (reverse ds)))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
536 (new-ds (append front back))) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
537 (cd (car new-ds)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
538 (setq shell-dirstack (cdr new-ds)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
539 (shell-dirstack-message))))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
540 (t |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
541 ;; pushd <dir> |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
542 (let ((old-wd default-directory)) |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
543 (cd (shell-prefixed-directory-name arg)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
544 (if (or (null shell-pushd-dunique) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
545 (not (member old-wd shell-dirstack))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
546 (setq shell-dirstack (cons old-wd shell-dirstack))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
547 (shell-dirstack-message)))))) |
| 114 | 548 |
| 549 ;; If STR is of the form +n, for n>0, return n. Otherwise, nil. | |
| 550 (defun shell-extract-num (str) | |
| 551 (and (string-match "^\\+[1-9][0-9]*$" str) | |
| 552 (string-to-int str))) | |
| 553 | |
| 554 | |
| 555 (defun shell-dirtrack-toggle () | |
| 556 "Turn directory tracking on and off in a shell buffer." | |
| 557 (interactive) | |
| 558 (setq shell-dirtrackp (not shell-dirtrackp)) | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
559 (message "Directory tracking %s" (if shell-dirtrackp "ON" "OFF"))) |
| 114 | 560 |
| 561 ;;; For your typing convenience: | |
|
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2557
diff
changeset
|
562 (defalias 'dirtrack-toggle 'shell-dirtrack-toggle) |
| 114 | 563 |
| 564 | |
| 565 (defun shell-resync-dirs () | |
| 566 "Resync the buffer's idea of the current directory stack. | |
| 567 This command queries the shell with the command bound to | |
|
2609
af46e8faaa32
(shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents:
2573
diff
changeset
|
568 `shell-dirstack-query' (default \"dirs\"), reads the next |
| 114 | 569 line output and parses it to form the new directory stack. |
| 570 DON'T issue this command unless the buffer is at a shell prompt. | |
| 571 Also, note that if some other subprocess decides to do output | |
| 572 immediately after the query, its output will be taken as the | |
| 573 new directory stack -- you lose. If this happens, just do the | |
| 574 command again." | |
| 575 (interactive) | |
| 576 (let* ((proc (get-buffer-process (current-buffer))) | |
| 577 (pmark (process-mark proc))) | |
| 578 (goto-char pmark) | |
| 579 (insert shell-dirstack-query) (insert "\n") | |
| 580 (sit-for 0) ; force redisplay | |
| 581 (comint-send-string proc shell-dirstack-query) | |
| 582 (comint-send-string proc "\n") | |
| 583 (set-marker pmark (point)) | |
| 584 (let ((pt (point))) ; wait for 1 line | |
| 585 ;; This extra newline prevents the user's pending input from spoofing us. | |
| 586 (insert "\n") (backward-char 1) | |
| 587 (while (not (looking-at ".+\n")) | |
| 588 (accept-process-output proc) | |
| 589 (goto-char pt))) | |
| 590 (goto-char pmark) (delete-char 1) ; remove the extra newline | |
| 591 ;; That's the dirlist. grab it & parse it. | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
592 (let* ((dl (buffer-substring (match-beginning 0) (1- (match-end 0)))) |
| 114 | 593 (dl-len (length dl)) |
| 594 (ds '()) ; new dir stack | |
| 595 (i 0)) | |
| 596 (while (< i dl-len) | |
| 597 ;; regexp = optional whitespace, (non-whitespace), optional whitespace | |
| 598 (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir | |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
599 (setq ds (cons (concat comint-file-name-prefix |
|
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
600 (substring dl (match-beginning 1) |
|
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
601 (match-end 1))) |
| 114 | 602 ds)) |
| 603 (setq i (match-end 0))) | |
|
5474
239620e1795d
(shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents:
5335
diff
changeset
|
604 (let ((ds (nreverse ds))) |
| 114 | 605 (condition-case nil |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
606 (progn (cd (car ds)) |
| 114 | 607 (setq shell-dirstack (cdr ds)) |
| 608 (shell-dirstack-message)) | |
| 609 (error (message "Couldn't cd."))))))) | |
| 610 | |
| 611 ;;; For your typing convenience: | |
|
2571
b65cf676a09b
All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2557
diff
changeset
|
612 (defalias 'dirs 'shell-resync-dirs) |
| 114 | 613 |
| 614 | |
| 615 ;;; Show the current dirstack on the message line. | |
| 616 ;;; Pretty up dirs a bit by changing "/usr/jqr/foo" to "~/foo". | |
| 617 ;;; (This isn't necessary if the dirlisting is generated with a simple "dirs".) | |
| 618 ;;; All the commands that mung the buffer's dirstack finish by calling | |
| 619 ;;; this guy. | |
| 620 (defun shell-dirstack-message () | |
|
4679
ed9240986f40
(shell-dirstack-message): Recognize ~ by matching the expansion of "~" with
Roland McGrath <roland@gnu.org>
parents:
4677
diff
changeset
|
621 (let* ((msg "") |
|
ed9240986f40
(shell-dirstack-message): Recognize ~ by matching the expansion of "~" with
Roland McGrath <roland@gnu.org>
parents:
4677
diff
changeset
|
622 (ds (cons default-directory shell-dirstack)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
623 (home (expand-file-name (concat comint-file-name-prefix "~/"))) |
|
4679
ed9240986f40
(shell-dirstack-message): Recognize ~ by matching the expansion of "~" with
Roland McGrath <roland@gnu.org>
parents:
4677
diff
changeset
|
624 (homelen (length home))) |
| 114 | 625 (while ds |
| 626 (let ((dir (car ds))) | |
|
4679
ed9240986f40
(shell-dirstack-message): Recognize ~ by matching the expansion of "~" with
Roland McGrath <roland@gnu.org>
parents:
4677
diff
changeset
|
627 (and (>= (length dir) homelen) (string= home (substring dir 0 homelen)) |
|
ed9240986f40
(shell-dirstack-message): Recognize ~ by matching the expansion of "~" with
Roland McGrath <roland@gnu.org>
parents:
4677
diff
changeset
|
628 (setq dir (concat "~/" (substring dir homelen)))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
629 ;; Strip off comint-file-name-prefix if present. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
630 (and comint-file-name-prefix |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
631 (>= (length dir) (length comint-file-name-prefix)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
632 (string= comint-file-name-prefix |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
633 (substring dir 0 (length comint-file-name-prefix))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
634 (setq dir (substring dir (length comint-file-name-prefix))) |
|
4679
ed9240986f40
(shell-dirstack-message): Recognize ~ by matching the expansion of "~" with
Roland McGrath <roland@gnu.org>
parents:
4677
diff
changeset
|
635 (setcar ds dir)) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
636 (setq msg (concat msg (directory-file-name dir) " ")) |
| 114 | 637 (setq ds (cdr ds)))) |
| 638 (message msg))) | |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
639 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
640 (defun shell-forward-command (&optional arg) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
641 "Move forward across ARG shell command(s). Does not cross lines. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
642 See `shell-command-regexp'." |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
643 (interactive "p") |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
644 (let ((limit (save-excursion (end-of-line nil) (point)))) |
|
7377
027616e7b1e4
(shell-forward-command, shell-backward-command): Fix regexp.
Karl Heuer <kwzh@gnu.org>
parents:
7083
diff
changeset
|
645 (if (re-search-forward (concat shell-command-regexp "\\([;&|][\t ]*\\)+") |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
646 limit 'move arg) |
|
5335
abf0d4d01681
(shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents:
5285
diff
changeset
|
647 (skip-syntax-backward " ")))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
648 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
649 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
650 (defun shell-backward-command (&optional arg) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
651 "Move backward across ARG shell command(s). Does not cross lines. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
652 See `shell-command-regexp'." |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
653 (interactive "p") |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
654 (let ((limit (save-excursion (comint-bol nil) (point)))) |
|
5335
abf0d4d01681
(shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents:
5285
diff
changeset
|
655 (if (> limit (point)) |
|
abf0d4d01681
(shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents:
5285
diff
changeset
|
656 (save-excursion (beginning-of-line) (setq limit (point)))) |
|
abf0d4d01681
(shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents:
5285
diff
changeset
|
657 (skip-syntax-backward " " limit) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
658 (if (re-search-backward |
|
7377
027616e7b1e4
(shell-forward-command, shell-backward-command): Fix regexp.
Karl Heuer <kwzh@gnu.org>
parents:
7083
diff
changeset
|
659 (format "[;&|]+[\t ]*\\(%s\\)" shell-command-regexp) limit 'move arg) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
660 (progn (goto-char (match-beginning 1)) |
|
5335
abf0d4d01681
(shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents:
5285
diff
changeset
|
661 (skip-chars-forward ";&|"))))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
662 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
663 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
664 (defun shell-dynamic-complete-command () |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
665 "Dynamically complete the command at point. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
666 This function is similar to `comint-dynamic-complete-filename', except that it |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
667 searches `exec-path' (minus the trailing emacs library path) for completion |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
668 candidates. Note that this may not be the same as the shell's idea of the |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
669 path. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
670 |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
671 Completion is dependent on the value of `shell-completion-execonly', plus |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
672 those that effect file completion. See `shell-dynamic-complete-as-command'. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
673 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
674 Returns t if successful." |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
675 (interactive) |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
676 (let ((filename (comint-match-partial-filename))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
677 (if (and filename |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
678 (save-match-data (not (string-match "[~/]" filename))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
679 (eq (match-beginning 0) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
680 (save-excursion (shell-backward-command 1) (point)))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
681 (prog2 (message "Completing command name...") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
682 (shell-dynamic-complete-as-command))))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
683 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
684 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
685 (defun shell-dynamic-complete-as-command () |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
686 "Dynamically complete at point as a command. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
687 See `shell-dynamic-complete-filename'. Returns t if successful." |
|
6508
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
688 (let* ((filename (or (comint-match-partial-filename) "")) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
689 (pathnondir (file-name-nondirectory filename)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
690 (paths (cdr (reverse exec-path))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
691 (cwd (file-name-as-directory (expand-file-name default-directory))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
692 (ignored-extensions |
|
6295
59a6684e8057
(shell-dynamic-complete-as-command): Make ignored-extensions
Richard M. Stallman <rms@gnu.org>
parents:
6255
diff
changeset
|
693 (and comint-completion-fignore |
|
59a6684e8057
(shell-dynamic-complete-as-command): Make ignored-extensions
Richard M. Stallman <rms@gnu.org>
parents:
6255
diff
changeset
|
694 (mapconcat (function (lambda (x) (concat (regexp-quote x) "$"))) |
|
59a6684e8057
(shell-dynamic-complete-as-command): Make ignored-extensions
Richard M. Stallman <rms@gnu.org>
parents:
6255
diff
changeset
|
695 comint-completion-fignore "\\|"))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
696 (path "") (comps-in-path ()) (file "") (filepath "") (completions ())) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
697 ;; Go thru each path in the search path, finding completions. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
698 (while paths |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
699 (setq path (file-name-as-directory (comint-directory (or (car paths) "."))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
700 comps-in-path (and (file-accessible-directory-p path) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
701 (file-name-all-completions pathnondir path))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
702 ;; Go thru each completion found, to see whether it should be used. |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
703 (while comps-in-path |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
704 (setq file (car comps-in-path) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
705 filepath (concat path file)) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
706 (if (and (not (member file completions)) |
|
6885
3c007de39916
(shell-dynamic-complete-as-command): Don't match ignored-extensions if it's nil.
Karl Heuer <kwzh@gnu.org>
parents:
6508
diff
changeset
|
707 (not (and ignored-extensions |
|
3c007de39916
(shell-dynamic-complete-as-command): Don't match ignored-extensions if it's nil.
Karl Heuer <kwzh@gnu.org>
parents:
6508
diff
changeset
|
708 (string-match ignored-extensions file))) |
|
4871
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
709 (or (string-equal path cwd) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
710 (not (file-directory-p filepath))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
711 (or (null shell-completion-execonly) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
712 (file-executable-p filepath))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
713 (setq completions (cons file completions))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
714 (setq comps-in-path (cdr comps-in-path))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
715 (setq paths (cdr paths))) |
|
30a614eb52f7
(shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
4679
diff
changeset
|
716 ;; OK, we've got a list of completions. |
|
6508
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
717 (let ((success (let ((comint-completion-addsuffix nil)) |
|
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
718 (comint-dynamic-simple-complete pathnondir completions)))) |
|
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
719 (if (and (memq success '(sole shortest)) comint-completion-addsuffix |
|
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
720 (not (file-directory-p (comint-match-partial-filename)))) |
|
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
721 (insert " ")) |
|
965beb0c97d2
(shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents:
6295
diff
changeset
|
722 success))) |
|
6186
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
723 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
724 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
725 (defun shell-match-partial-variable () |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
726 "Return the variable at point, or nil if non is found." |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
727 (save-excursion |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
728 (let ((limit (point))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
729 (if (re-search-backward "[^A-Za-z0-9_{}]" nil 'move) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
730 (or (looking-at "\\$") (forward-char 1))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
731 ;; Anchor the search forwards. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
732 (if (or (eolp) (looking-at "[^A-Za-z0-9_{}$]")) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
733 nil |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
734 (re-search-forward "\\$?{?[A-Za-z0-9_]*}?" limit) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
735 (buffer-substring (match-beginning 0) (match-end 0)))))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
736 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
737 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
738 (defun shell-dynamic-complete-environment-variable () |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
739 "Dynamically complete the environment variable at point. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
740 Completes if after a variable, i.e., if it starts with a \"$\". |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
741 See `shell-dynamic-complete-as-environment-variable'. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
742 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
743 This function is similar to `comint-dynamic-complete-filename', except that it |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
744 searches `process-environment' for completion candidates. Note that this may |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
745 not be the same as the interpreter's idea of variable names. The main problem |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
746 with this type of completion is that `process-environment' is the environment |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
747 which Emacs started with. Emacs does not track changes to the environment made |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
748 by the interpreter. Perhaps it would be more accurate if this function was |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
749 called `shell-dynamic-complete-process-environment-variable'. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
750 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
751 Returns non-nil if successful." |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
752 (interactive) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
753 (let ((variable (shell-match-partial-variable))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
754 (if (and variable (string-match "^\\$" variable)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
755 (prog2 (message "Completing variable name...") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
756 (shell-dynamic-complete-as-environment-variable))))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
757 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
758 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
759 (defun shell-dynamic-complete-as-environment-variable () |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
760 "Dynamically complete at point as an environment variable. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
761 Used by `shell-dynamic-complete-environment-variable'. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
762 Uses `comint-dynamic-simple-complete'." |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
763 (let* ((var (or (shell-match-partial-variable) "")) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
764 (variable (substring var (or (string-match "[^$({]\\|$" var) 0))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
765 (variables (mapcar (function (lambda (x) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
766 (substring x 0 (string-match "=" x)))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
767 process-environment)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
768 (addsuffix comint-completion-addsuffix) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
769 (comint-completion-addsuffix nil) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
770 (success (comint-dynamic-simple-complete variable variables))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
771 (if (memq success '(sole shortest)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
772 (let* ((var (shell-match-partial-variable)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
773 (variable (substring var (string-match "[^$({]" var))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
774 (protection (cond ((string-match "{" var) "}") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
775 ((string-match "(" var) ")") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
776 (t ""))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
777 (suffix (cond ((null addsuffix) "") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
778 ((file-directory-p |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
779 (comint-directory (getenv variable))) "/") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
780 (t " ")))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
781 (insert protection suffix))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
782 success)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
783 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
784 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
785 (defun shell-replace-by-expanded-directory () |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
786 "Expand directory stack reference before point. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
787 Directory stack references are of the form \"=digit\" or \"=-\". |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
788 See `default-directory' and `shell-dirstack'. |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
789 |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
790 Returns t if successful." |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
791 (interactive) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
792 (if (comint-match-partial-filename) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
793 (save-excursion |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
794 (goto-char (match-beginning 0)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
795 (let ((stack (cons default-directory shell-dirstack)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
796 (index (cond ((looking-at "=-/?") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
797 (length shell-dirstack)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
798 ((looking-at "=\\([0-9]+\\)") |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
799 (string-to-number |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
800 (buffer-substring |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
801 (match-beginning 1) (match-end 1))))))) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
802 (cond ((null index) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
803 nil) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
804 ((>= index (length stack)) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
805 (error "Directory stack not that deep.")) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
806 (t |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
807 (replace-match (file-name-as-directory (nth index stack)) t t) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
808 (message "Directory item: %d" index) |
|
84df7a6f6240
(shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6155
diff
changeset
|
809 t)))))) |
| 252 | 810 |
|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
811 (provide 'shell) |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
812 |
|
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
252
diff
changeset
|
813 ;;; shell.el ends here |
