annotate lisp/shell.el @ 6177:ac2ef13dca1b

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