annotate lisp/shell.el @ 111580:bd93bfc2fc83

* lisp/progmodes/python.el (run-python): Explain why we remove the current directory from sys.path. Suggested by Eric Hanchrow <erich@cozi.com>.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 17 Nov 2010 10:00:16 -0500
parents adbfcf85c8eb
children 280ee0988e1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38409
153f1b1f2efd Emacs lisp coding convention fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 35659
diff changeset
1 ;;; shell.el --- specialized comint.el for running the shell
6887
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
2
111429
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 111416
diff changeset
3 ;; Copyright (C) 1988, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002,
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 111416
diff changeset
4 ;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 111416
diff changeset
5 ;; Free Software Foundation, Inc.
844
bf829a2d63b4 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
6
38409
153f1b1f2efd Emacs lisp coding convention fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 35659
diff changeset
7 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 24967
diff changeset
8 ;; Simon Marshall <simon@gnu.org>
81695
8f00c712c722 On request of the authors, remove their addresses for
David Kastrup <dak@gnu.org>
parents: 81340
diff changeset
9 ;; Maintainer: FSF <emacs-devel@gnu.org>
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
10 ;; Keywords: processes
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
11
6887
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
12 ;; This file is part of GNU Emacs.
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
13
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93587
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
6887
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93587
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93587
diff changeset
17 ;; (at your option) any later version.
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
18
6887
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
22 ;; GNU General Public License for more details.
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
23
6887
9888d3b32db3 (shell-mode-map): Fix menu bar options.
Karl Heuer <kwzh@gnu.org>
parents: 6885
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93587
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
26
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
27 ;;; Commentary:
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
28
46159
bd315b9fa3f0 Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 46073
diff changeset
29 ;; This file defines a shell-in-a-buffer package (shell mode) built on
bd315b9fa3f0 Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 46073
diff changeset
30 ;; top of comint mode. This is actually cmushell with things renamed
bd315b9fa3f0 Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 46073
diff changeset
31 ;; to replace its counterpart in Emacs 18. cmushell is more
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
32 ;; featureful, robust, and uniform than the Emacs 18 version.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
33
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
34 ;; Since this mode is built on top of the general command-interpreter-in-
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
35 ;; a-buffer mode (comint mode), it shares a common base functionality,
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
36 ;; and a common set of bindings, with all modes derived from comint mode.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
37 ;; This makes these modes easier to use.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
38
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
39 ;; For documentation on the functionality provided by comint mode, and
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
40 ;; the hooks available for customising it, see the file comint.el.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
41 ;; For further information on shell mode, see the comments below.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
42
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
43 ;; Needs fixin:
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
44 ;; When sending text from a source file to a subprocess, the process-mark can
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
45 ;; move off the window, so you can lose sight of the process interactions.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
46 ;; Maybe I should ensure the process mark is in the window when I send
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
47 ;; text to the process? Switch selectable?
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
48
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
49 ;; YOUR .EMACS FILE
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
50 ;;=============================================================================
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
51 ;; Some suggestions for your .emacs file.
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
52 ;;
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
53 ;; ;; Define M-# to run some strange command:
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
54 ;; (eval-after-load "shell"
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
55 ;; '(define-key shell-mode-map "\M-#" 'shells-dynamic-spell))
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
56
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
57 ;; Brief Command Documentation:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
58 ;;============================================================================
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
59 ;; Comint Mode Commands: (common to shell and all comint-derived modes)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
60 ;;
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
61 ;; m-p comint-previous-input Cycle backwards in input history
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
62 ;; m-n comint-next-input Cycle forwards
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
63 ;; m-r comint-previous-matching-input Previous input matching a regexp
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
64 ;; m-s comint-next-matching-input Next input that matches
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
65 ;; m-c-l comint-show-output Show last batch of process output
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
66 ;; return comint-send-input
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
67 ;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
68 ;; c-c c-a comint-bol Beginning of line; skip prompt
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
69 ;; c-c c-u comint-kill-input ^u
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
70 ;; c-c c-w backward-kill-word ^w
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
71 ;; c-c c-c comint-interrupt-subjob ^c
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
72 ;; c-c c-z comint-stop-subjob ^z
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
73 ;; c-c c-\ comint-quit-subjob ^\
110695
515d80e174ba Remove some functions, variables and aliases obsolete since at least 21.1.
Glenn Morris <rgm@gnu.org>
parents: 108968
diff changeset
74 ;; c-c c-o comint-delete-output Delete last batch of process output
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
75 ;; c-c c-r comint-show-output Show last batch of process output
24738
b84d9bdd06b1 Comment fix.
Karl Heuer <kwzh@gnu.org>
parents: 24069
diff changeset
76 ;; c-c c-l comint-dynamic-list-input-ring List input history
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
77 ;; send-invisible Read line w/o echo & send to proc
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
78 ;; comint-continue-subjob Useful if you accidentally suspend
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
79 ;; top-level job
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
80 ;; comint-mode-hook is the comint mode hook.
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
81
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
82 ;; Shell Mode Commands:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
83 ;; shell Fires up the shell process
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
84 ;; tab comint-dynamic-complete Complete filename/command/history
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
85 ;; m-? comint-dynamic-list-filename-completions
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
86 ;; List completions in help buffer
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
87 ;; m-c-f shell-forward-command Forward a shell command
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
88 ;; m-c-b shell-backward-command Backward a shell command
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
89 ;; dirs Resync the buffer's dir stack
85709
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
90 ;; shell-dirtrack-mode Turn dir tracking on/off
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
91 ;; comint-strip-ctrl-m Remove trailing ^Ms from output
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
92 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
93 ;; The shell mode hook is shell-mode-hook
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
94 ;; comint-prompt-regexp is initialised to shell-prompt-pattern, for backwards
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
95 ;; compatibility.
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
96
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
97 ;; Read the rest of this file for more information.
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
98
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
99 ;;; Code:
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
100
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
101 (require 'comint)
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
102
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
103 ;;; Customization and Buffer Variables
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12323
diff changeset
104
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
105 (defgroup shell nil
64021
6c90c8ae9e80 (shell): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63507
diff changeset
106 "Running shell from within Emacs buffers."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
107 :group 'processes
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
108 :group 'unix)
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
109
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
110 (defgroup shell-directories nil
64021
6c90c8ae9e80 (shell): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63507
diff changeset
111 "Directory support in shell mode."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
112 :group 'shell)
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
113
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
114 (defgroup shell-faces nil
64021
6c90c8ae9e80 (shell): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63507
diff changeset
115 "Faces in shell buffers."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
116 :group 'shell)
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
117
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
118 ;;;###autoload
105870
26baacb565b0 * textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105798
diff changeset
119 (defcustom shell-dumb-shell-regexp (purecopy "cmd\\(proxy\\)?\\.exe")
35643
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
120 "Regexp to match shells that don't save their command history, and
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
121 don't handle the backslash as a quote character. For shells that
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
122 match this regexp, Emacs will write out the command history when the
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
123 shell finishes, and won't remove backslashes when it unquotes shell
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
124 arguments."
31617
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
125 :type 'regexp
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
126 :group 'shell)
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
127
23744
e7128c62a0b4 (shell-prompt-pattern): Add defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 23480
diff changeset
128 (defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *"
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
129 "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
130 Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well.
63507
e5299a8016cb (shell-prompt-pattern, shell-dynamic-complete-functions, shell-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
131 This variable is used to initialize `comint-prompt-regexp' in the
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
132 shell buffer.
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
133
61876
c157250db02c (shell-prompt-pattern): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 53402
diff changeset
134 If `comint-use-prompt-regexp' is nil, then this variable is only used
c157250db02c (shell-prompt-pattern): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 53402
diff changeset
135 to determine paragraph boundaries. See Info node `Shell Prompts' for
c157250db02c (shell-prompt-pattern): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 53402
diff changeset
136 how Shell mode treats paragraphs.
30641
297909766bad (shell-prompt-pattern): Doc change.
Miles Bader <miles@gnu.org>
parents: 25278
diff changeset
137
4131
c9a0f06110bd * shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents: 3418
diff changeset
138 The pattern should probably not match more than one line. If it does,
14476
63540fa43674 Resync directories properly for the ksh.
Simon Marshall <simon@gnu.org>
parents: 14329
diff changeset
139 Shell mode may become confused trying to distinguish prompt from input
4131
c9a0f06110bd * shell.el (shell-process-pushd): Fix syntax error in
Jim Blandy <jimb@redhat.com>
parents: 3418
diff changeset
140 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
141
23744
e7128c62a0b4 (shell-prompt-pattern): Add defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 23480
diff changeset
142 This is a fine thing to set in your `.emacs' file."
e7128c62a0b4 (shell-prompt-pattern): Add defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 23480
diff changeset
143 :type 'regexp
e7128c62a0b4 (shell-prompt-pattern): Add defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 23480
diff changeset
144 :group 'shell)
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
145
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
146 (defcustom shell-completion-fignore nil
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
147 "List of suffixes to be disregarded during file/command completion.
6255
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
148 This variable is used to initialize `comint-completion-fignore' in the shell
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
149 buffer. The default is nil, for compatibility with most shells.
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
150 Some people like (\"~\" \"#\" \"%\").
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
151
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
152 This is a fine thing to set in your `.emacs' file."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
153 :type '(repeat (string :tag "Suffix"))
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
154 :group 'shell)
6255
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
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 '(?\| ?& ?< ?> ?\( ?\) ?\;)
63507
e5299a8016cb (shell-prompt-pattern, shell-dynamic-complete-functions, shell-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
157 "List of characters to recognize 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
15655
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
159 shell buffer. The value may depend on the operating system or shell.
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
160
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
161 This is a fine thing to set in your `.emacs' file.")
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
162
15818
574ec5119c7a (shell-file-name-chars): Was shell-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 15655
diff changeset
163 (defvar shell-file-name-chars
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 48105
diff changeset
164 (if (memq system-type '(ms-dos windows-nt cygwin))
21621
56d8224fe691 (shell-file-name-chars): Add ',' and ':'.
Geoff Voelker <voelker@cs.washington.edu>
parents: 20971
diff changeset
165 "~/A-Za-z0-9_^$!#%&{}@`'.,:()-"
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
166 "[]~/A-Za-z0-9+@:_.$#%,={}-")
15818
574ec5119c7a (shell-file-name-chars): Was shell-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 15655
diff changeset
167 "String of characters valid in a file name.
574ec5119c7a (shell-file-name-chars): Was shell-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 15655
diff changeset
168 This variable is used to initialize `comint-file-name-chars' in the
15655
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
169 shell buffer. The value may depend on the operating system or shell.
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
170
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
171 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
172
11186
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
173 (defvar shell-file-name-quote-list
15655
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
174 (if (memq system-type '(ms-dos windows-nt))
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
175 nil
97761
3971edd65203 (shell-file-name-quote-list): Quote `$'.
Chong Yidong <cyd@stupidchicken.com>
parents: 96940
diff changeset
176 (append shell-delimiter-argument-list '(?\s ?$ ?\* ?\! ?\" ?\' ?\` ?\# ?\\)))
11186
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
177 "List of characters to quote when in a file name.
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
178 This variable is used to initialize `comint-file-name-quote-list' in the
15655
f2f66323f14a Bind shell-file-name-quote-list and shell-file-name-regexp specially for MSDOG.
Simon Marshall <simon@gnu.org>
parents: 15370
diff changeset
179 shell buffer. The value may depend on the operating system or shell.
11186
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
180
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
181 This is a fine thing to set in your `.emacs' file.")
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
182
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
183 (defvar shell-dynamic-complete-functions
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
184 '(comint-replace-by-expanded-history
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
185 shell-dynamic-complete-environment-variable
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
186 shell-dynamic-complete-command
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
187 shell-replace-by-expanded-directory
96940
99669ed07fd2 (shell-dynamic-complete-functions): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
188 shell-dynamic-complete-filename
99669ed07fd2 (shell-dynamic-complete-functions): Use
Chong Yidong <cyd@stupidchicken.com>
parents: 94678
diff changeset
189 comint-dynamic-complete-filename)
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
190 "List of functions called to perform completion.
63507
e5299a8016cb (shell-prompt-pattern, shell-dynamic-complete-functions, shell-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
191 This variable is used to initialize `comint-dynamic-complete-functions' in the
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
192 shell buffer.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
193
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
194 This is a fine thing to set in your `.emacs' file.")
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
195
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
196 (defcustom shell-command-regexp "[^;&|\n]+"
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
197 "Regexp to match a single command within a pipeline.
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
198 This is used for directory tracking and does not do a perfect job."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
199 :type 'regexp
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
200 :group 'shell)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
201
51554
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
202 (defcustom shell-command-separator-regexp "[;&|\n \t]*"
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
203 "Regexp to match a single command within a pipeline.
51554
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
204 This is used for directory tracking and does not do a perfect job."
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
205 :type 'regexp
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
206 :group 'shell)
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
207
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
208 (defcustom shell-completion-execonly t
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
209 "If non-nil, use executable files only for completion candidates.
4938
dfb65242faf4 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4871
diff changeset
210 This mirrors the optional behavior of tcsh.
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
211
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
212 Detecting executability of files may slow command completion considerably."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
213 :type 'boolean
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
214 :group 'shell)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
215
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
216 (defcustom shell-popd-regexp "popd"
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
217 "Regexp to match subshell commands equivalent to popd."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
218 :type 'regexp
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
219 :group 'shell-directories)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
220
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
221 (defcustom shell-pushd-regexp "pushd"
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
222 "Regexp to match subshell commands equivalent to pushd."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
223 :type 'regexp
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
224 :group 'shell-directories)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
225
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
226 (defcustom shell-pushd-tohome nil
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
227 "If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd).
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
228 This mirrors the optional behavior of tcsh."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
229 :type 'boolean
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
230 :group 'shell-directories)
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
231
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
232 (defcustom shell-pushd-dextract nil
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
233 "If non-nil, make \"pushd +n\" pop the nth dir to the stack top.
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
234 This mirrors the optional behavior of tcsh."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
235 :type 'boolean
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
236 :group 'shell-directories)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
237
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
238 (defcustom shell-pushd-dunique nil
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
239 "If non-nil, make pushd only add unique directories to the stack.
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
240 This mirrors the optional behavior of tcsh."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
241 :type 'boolean
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
242 :group 'shell-directories)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
243
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
244 (defcustom shell-cd-regexp "cd"
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
245 "Regexp to match subshell commands equivalent to cd."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
246 :type 'regexp
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
247 :group 'shell-directories)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
248
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
249 (defcustom shell-chdrive-regexp
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
250 (if (memq system-type '(ms-dos windows-nt))
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
251 ; NetWare allows the five chars between upper and lower alphabetics.
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
252 "[]a-zA-Z^_`\\[\\\\]:"
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
253 nil)
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
254 "If non-nil, is regexp used to track drive changes."
19829
4344b744de2f (shell-chdrive-regexp): Likewise.
Richard M. Stallman <rms@gnu.org>
parents: 19476
diff changeset
255 :type '(choice regexp
4344b744de2f (shell-chdrive-regexp): Likewise.
Richard M. Stallman <rms@gnu.org>
parents: 19476
diff changeset
256 (const nil))
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
257 :group 'shell-directories)
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
258
24069
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
259 (defcustom shell-dirtrack-verbose t
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
260 "If non-nil, show the directory stack following directory change.
85709
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
261 This is effective only if directory tracking is enabled.
85787
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
262 The `dirtrack' package provides an alternative implementation of this feature -
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
263 see the function `dirtrack-mode'."
24069
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
264 :type 'boolean
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
265 :group 'shell-directories)
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
266
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
267 (defcustom explicit-shell-file-name nil
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
268 "If non-nil, is file name to use for explicitly requested inferior shell."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
269 :type '(choice (const :tag "None" nil) file)
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
270 :group 'shell)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
271
73305
2b23d84b802a (explicit-csh-args, explicit-bash-args): Add comment
Kim F. Storm <storm@cua.dk>
parents: 72621
diff changeset
272 ;; Note: There are no explicit references to the variable `explicit-csh-args'.
2b23d84b802a (explicit-csh-args, explicit-bash-args): Add comment
Kim F. Storm <storm@cua.dk>
parents: 72621
diff changeset
273 ;; It is used implicitly by M-x shell when the shell is `csh'.
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
274 (defcustom explicit-csh-args
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
275 (if (eq system-type 'hpux)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
276 ;; -T persuades HP's csh not to think it is smarter
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
277 ;; than us about what terminal modes to use.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
278 '("-i" "-T")
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
279 '("-i"))
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
280 "Args passed to inferior shell by \\[shell], if the shell is csh.
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
281 Value is a list of strings, which may be nil."
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
282 :type '(repeat (string :tag "Argument"))
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
283 :group 'shell)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
284
73305
2b23d84b802a (explicit-csh-args, explicit-bash-args): Add comment
Kim F. Storm <storm@cua.dk>
parents: 72621
diff changeset
285 ;; Note: There are no explicit references to the variable `explicit-bash-args'.
2b23d84b802a (explicit-csh-args, explicit-bash-args): Add comment
Kim F. Storm <storm@cua.dk>
parents: 72621
diff changeset
286 ;; It is used implicitly by M-x shell when the interactive shell is `bash'.
46073
58a34a457ab8 (explicit-bash-args): New user option.
Andreas Schwab <schwab@suse.de>
parents: 45285
diff changeset
287 (defcustom explicit-bash-args
48105
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
288 (let* ((prog (or (and (boundp 'explicit-shell-file-name) explicit-shell-file-name)
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
289 (getenv "ESHELL") shell-file-name))
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
290 (name (file-name-nondirectory prog)))
73308
194b79b77de3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 73305
diff changeset
291 ;; Tell bash not to use readline, except for bash 1.x which
194b79b77de3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 73305
diff changeset
292 ;; doesn't grook --noediting. Bash 1.x has -nolineediting, but
194b79b77de3 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 73305
diff changeset
293 ;; process-send-eof cannot terminate bash if we use it.
48105
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
294 (if (and (not purify-flag)
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
295 (equal name "bash")
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
296 (file-executable-p prog)
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
297 (string-match "bad option"
73379
b6d2149f9903 2006-10-15 Lennart Borgman <lennart.borgman.073@student.lu.se>
Kim F. Storm <storm@cua.dk>
parents: 73308
diff changeset
298 (shell-command-to-string
b6d2149f9903 2006-10-15 Lennart Borgman <lennart.borgman.073@student.lu.se>
Kim F. Storm <storm@cua.dk>
parents: 73308
diff changeset
299 (concat (shell-quote-argument prog)
b6d2149f9903 2006-10-15 Lennart Borgman <lennart.borgman.073@student.lu.se>
Kim F. Storm <storm@cua.dk>
parents: 73308
diff changeset
300 " --noediting"))))
48105
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
301 '("-i")
5fbd632e1109 (explicit-bash-args): Bash 1.x doesn't grook
Kim F. Storm <storm@cua.dk>
parents: 48016
diff changeset
302 '("--noediting" "-i")))
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
303 "Args passed to inferior shell by \\[shell], if the shell is bash.
46073
58a34a457ab8 (explicit-bash-args): New user option.
Andreas Schwab <schwab@suse.de>
parents: 45285
diff changeset
304 Value is a list of strings, which may be nil."
58a34a457ab8 (explicit-bash-args): New user option.
Andreas Schwab <schwab@suse.de>
parents: 45285
diff changeset
305 :type '(repeat (string :tag "Argument"))
58a34a457ab8 (explicit-bash-args): New user option.
Andreas Schwab <schwab@suse.de>
parents: 45285
diff changeset
306 :group 'shell)
58a34a457ab8 (explicit-bash-args): New user option.
Andreas Schwab <schwab@suse.de>
parents: 45285
diff changeset
307
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
308 (defcustom shell-input-autoexpand 'history
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
309 "If non-nil, expand input command history references on completion.
5538
9d84549e89b4 (shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 5474
diff changeset
310 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
311
9d84549e89b4 (shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 5474
diff changeset
312 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
313 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
314 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
315 `comint-dynamic-complete'.
9d84549e89b4 (shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 5474
diff changeset
316
9d84549e89b4 (shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 5474
diff changeset
317 This variable supplies a default for `comint-input-autoexpand',
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
318 for Shell mode only."
23274
0c30ca946dba (shell-input-autoexpand): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents: 23219
diff changeset
319 :type '(choice (const :tag "off" nil)
0c30ca946dba (shell-input-autoexpand): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents: 23219
diff changeset
320 (const input)
0c30ca946dba (shell-input-autoexpand): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents: 23219
diff changeset
321 (const history)
0c30ca946dba (shell-input-autoexpand): Fix customize type.
Andreas Schwab <schwab@suse.de>
parents: 23219
diff changeset
322 (const :tag "on" t))
23480
2046e6b0bc8e (shell-input-autoexpand): Fix customization group.
Richard M. Stallman <rms@gnu.org>
parents: 23274
diff changeset
323 :group 'shell)
5538
9d84549e89b4 (shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 5474
diff changeset
324
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
325 (defvar shell-dirstack nil
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
326 "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
327 Thus, this does not include the shell's current directory.")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
328
6152
34d9a0aa80d1 (shell-dirtrackp): Variable definition added.
Richard M. Stallman <rms@gnu.org>
parents: 6150
diff changeset
329 (defvar shell-dirtrackp t
34d9a0aa80d1 (shell-dirtrackp): Variable definition added.
Richard M. Stallman <rms@gnu.org>
parents: 6150
diff changeset
330 "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
331
2351
bb1ff4e31fb6 Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1801
diff changeset
332 (defvar shell-last-dir nil
bb1ff4e31fb6 Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1801
diff changeset
333 "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
334
7083
9630c48595d8 (shell-dirstack-query): Defaults to nil.
Richard M. Stallman <rms@gnu.org>
parents: 6887
diff changeset
335 (defvar shell-dirstack-query nil
76294
24e13e715a20 (shell-dirstack-query): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 75347
diff changeset
336 "Command used by `shell-resync-dirs' to query the shell.")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
337
110909
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
338 (defvar shell-mode-map
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
339 (let ((map (nconc (make-sparse-keymap) comint-mode-map)))
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
340 (define-key map "\C-c\C-f" 'shell-forward-command)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
341 (define-key map "\C-c\C-b" 'shell-backward-command)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
342 (define-key map "\t" 'comint-dynamic-complete)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
343 (define-key map (kbd "M-RET") 'shell-resync-dirs)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
344 (define-key map "\M-?" 'comint-dynamic-list-filename-completions)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
345 (define-key map [menu-bar completion]
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
346 (cons "Complete"
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
347 (copy-keymap (lookup-key comint-mode-map [menu-bar completion]))))
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
348 (define-key-after (lookup-key map [menu-bar completion])
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
349 [complete-env-variable] '("Complete Env. Variable Name" .
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
350 shell-dynamic-complete-environment-variable)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
351 'complete-file)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
352 (define-key-after (lookup-key map [menu-bar completion])
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
353 [expand-directory] '("Expand Directory Reference" .
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
354 shell-replace-by-expanded-directory)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
355 'complete-expand)
cc035ccb9275 Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110695
diff changeset
356 map))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
357
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
358 (defcustom shell-mode-hook '()
105170
f8ba8d6fd250 Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
359 "Hook for customizing Shell mode."
17428
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
360 :type 'hook
653c0e2e1b31 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16877
diff changeset
361 :group 'shell)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
362
9383
c4fa081b416e (shell-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 9244
diff changeset
363 (defvar shell-font-lock-keywords
31037
7c81a282d217 (shell-font-lock-keywords): Remove prompt highlighting, since this is
Miles Bader <miles@gnu.org>
parents: 30641
diff changeset
364 '(("[ \t]\\([+-][^ \t\n]+\\)" 1 font-lock-comment-face)
17497
3ee027d263c6 Use EVAL form for shell-prompt-pattern.
Simon Marshall <simon@gnu.org>
parents: 17428
diff changeset
365 ("^[^ \t\n]+:.*" . font-lock-string-face)
3ee027d263c6 Use EVAL form for shell-prompt-pattern.
Simon Marshall <simon@gnu.org>
parents: 17428
diff changeset
366 ("^\\[[1-9][0-9]*\\]" . font-lock-string-face))
9383
c4fa081b416e (shell-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 9244
diff changeset
367 "Additional expressions to highlight in Shell mode.")
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
368
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
369 ;;; Basic Procedures
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
370
17646
0dcc993f06e4 (shell-mode): Add a mode-class property.
Richard M. Stallman <rms@gnu.org>
parents: 17497
diff changeset
371 (put 'shell-mode 'mode-class 'special)
0dcc993f06e4 (shell-mode): Add a mode-class property.
Richard M. Stallman <rms@gnu.org>
parents: 17497
diff changeset
372
33706
8c460ceb4916 (shell-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32943
diff changeset
373 (define-derived-mode shell-mode comint-mode "Shell"
71144
2f86f394f7bc (shell-mode): Use shell-mode-map in docstring.
Luc Teirlinck <teirllm@auburn.edu>
parents: 70978
diff changeset
374 "Major mode for interacting with an inferior shell.\\<shell-mode-map>
10831
94811e4b2a06 Added shell-truncate-buffer function to restrict buffer size to
Simon Marshall <simon@gnu.org>
parents: 10791
diff changeset
375 \\[comint-send-input] after the end of the process' output sends the text from
94811e4b2a06 Added shell-truncate-buffer function to restrict buffer size to
Simon Marshall <simon@gnu.org>
parents: 10791
diff changeset
376 the end of process to the end of the current line.
94811e4b2a06 Added shell-truncate-buffer function to restrict buffer size to
Simon Marshall <simon@gnu.org>
parents: 10791
diff changeset
377 \\[comint-send-input] before end of process output copies the current line minus the prompt to
94811e4b2a06 Added shell-truncate-buffer function to restrict buffer size to
Simon Marshall <simon@gnu.org>
parents: 10791
diff changeset
378 the end of the buffer and sends it (\\[comint-copy-old-input] just copies the current line).
10377
2123413a483e Doc fixes (simon's email address and shell-mode)
Simon Marshall <simon@gnu.org>
parents: 10019
diff changeset
379 \\[send-invisible] reads a line of text without echoing it, and sends it to
6508
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
380 the shell. This is useful for entering passwords. Or, add the function
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
381 `comint-watch-for-password-prompt' to `comint-output-filter-functions'.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
382
10377
2123413a483e Doc fixes (simon's email address and shell-mode)
Simon Marshall <simon@gnu.org>
parents: 10019
diff changeset
383 If you want to make multiple shell buffers, rename the `*shell*' buffer
2123413a483e Doc fixes (simon's email address and shell-mode)
Simon Marshall <simon@gnu.org>
parents: 10019
diff changeset
384 using \\[rename-buffer] or \\[rename-uniquely] and start a new shell.
2123413a483e Doc fixes (simon's email address and shell-mode)
Simon Marshall <simon@gnu.org>
parents: 10019
diff changeset
385
10831
94811e4b2a06 Added shell-truncate-buffer function to restrict buffer size to
Simon Marshall <simon@gnu.org>
parents: 10791
diff changeset
386 If you want to make shell buffers limited in length, add the function
10832
32d4c4ca1ff8 Moved buffer truncation functionality to comint.el.
Simon Marshall <simon@gnu.org>
parents: 10831
diff changeset
387 `comint-truncate-buffer' to `comint-output-filter-functions'.
10831
94811e4b2a06 Added shell-truncate-buffer function to restrict buffer size to
Simon Marshall <simon@gnu.org>
parents: 10791
diff changeset
388
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
389 If you accidentally suspend your process, use \\[comint-continue-subjob]
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
390 to continue it.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
391
10377
2123413a483e Doc fixes (simon's email address and shell-mode)
Simon Marshall <simon@gnu.org>
parents: 10019
diff changeset
392 `cd', `pushd' and `popd' commands given to the shell are watched by Emacs to
2123413a483e Doc fixes (simon's email address and shell-mode)
Simon Marshall <simon@gnu.org>
parents: 10019
diff changeset
393 keep this buffer's default directory the same as the shell's working directory.
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
394 While directory tracking is enabled, the shell's working directory is displayed
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
395 by \\[list-buffers] or \\[mouse-buffer-menu] in the `File' field.
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
396 \\[dirs] queries the shell and resyncs Emacs' idea of what the current
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
397 directory stack is.
85709
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
398 \\[shell-dirtrack-mode] turns directory tracking on and off.
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
399 \(The `dirtrack' package provides an alternative implementation of this
85787
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
400 feature - see the function `dirtrack-mode'.)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
401
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
402 \\{shell-mode-map}
2609
af46e8faaa32 (shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents: 2573
diff changeset
403 Customization: Entry to this mode runs the hooks on `comint-mode-hook' and
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
404 `shell-mode-hook' (in that order). Before each input, the hooks on
6189
4ff931c18e4b Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents: 6186
diff changeset
405 `comint-input-filter-functions' are run. After each shell output, the hooks
4ff931c18e4b Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents: 6186
diff changeset
406 on `comint-output-filter-functions' are run.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
407
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
408 Variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp'
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
409 and `shell-popd-regexp' are used to match their respective commands,
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
410 while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique'
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
411 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
412
6255
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
413 Variables `comint-completion-autolist', `comint-completion-addsuffix',
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
414 `comint-completion-recexact' and `comint-completion-fignore' control the
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
415 behavior of file name, command name and variable name completion. Variable
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
416 `shell-completion-execonly' controls the behavior of command name completion.
63507
e5299a8016cb (shell-prompt-pattern, shell-dynamic-complete-functions, shell-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
417 Variable `shell-completion-fignore' is used to initialize the value of
6255
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
418 `comint-completion-fignore'.
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
419
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
420 Variables `comint-input-ring-file-name' and `comint-input-autoexpand' control
65199
23741bfb23af (shell-mode, shell-resync-dirs): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 64762
diff changeset
421 the initialization of the input ring history, and history expansion.
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
422
6189
4ff931c18e4b Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents: 6186
diff changeset
423 Variables `comint-output-filter-functions', a hook, and
6255
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
424 `comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output'
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
425 control whether input and output cause the window to scroll to the end of the
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
426 buffer."
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
427 (setq comint-prompt-regexp shell-prompt-pattern)
6255
277d9ace9f5d (shell-completion-fignore): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6189
diff changeset
428 (setq comint-completion-fignore shell-completion-fignore)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
429 (setq comint-delimiter-argument-list shell-delimiter-argument-list)
15818
574ec5119c7a (shell-file-name-chars): Was shell-file-name-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 15655
diff changeset
430 (setq comint-file-name-chars shell-file-name-chars)
11186
54a20705cf02 Set comint-file-name-quote-list to new shell-file-name-quote-list.
Simon Marshall <simon@gnu.org>
parents: 11154
diff changeset
431 (setq comint-file-name-quote-list shell-file-name-quote-list)
71664
dd41b3cb7611 (shell-mode): Only change the buffer-local value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71144
diff changeset
432 (set (make-local-variable 'comint-dynamic-complete-functions)
dd41b3cb7611 (shell-mode): Only change the buffer-local value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71144
diff changeset
433 shell-dynamic-complete-functions)
61876
c157250db02c (shell-prompt-pattern): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 53402
diff changeset
434 (set (make-local-variable 'paragraph-separate) "\\'")
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
435 (make-local-variable 'paragraph-start)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
436 (setq paragraph-start comint-prompt-regexp)
9485
2685c7803c18 * shell.el: (shell-font-lock-keywords): Add `\n' to [^] regexps.
Simon Marshall <simon@gnu.org>
parents: 9383
diff changeset
437 (make-local-variable 'font-lock-defaults)
2685c7803c18 * shell.el: (shell-font-lock-keywords): Add `\n' to [^] regexps.
Simon Marshall <simon@gnu.org>
parents: 9383
diff changeset
438 (setq font-lock-defaults '(shell-font-lock-keywords t))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
439 (make-local-variable 'shell-dirstack)
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
440 (setq shell-dirstack nil)
19469
41215527a262 Make shell-last-dir buffer-local.
Simon Marshall <simon@gnu.org>
parents: 19121
diff changeset
441 (make-local-variable 'shell-last-dir)
2351
bb1ff4e31fb6 Brent Benson's patch to support `cd -'.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1801
diff changeset
442 (setq shell-last-dir nil)
5538
9d84549e89b4 (shell-input-autoexpand): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 5474
diff changeset
443 (setq comint-input-autoexpand shell-input-autoexpand)
105196
d991506f9286 * menu-bar.el (list-buffers-directory): Add docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 105170
diff changeset
444 (shell-dirtrack-mode 1)
18878
f39ae9c61a45 (shell-mode): Do set list-files-directory locally.
Richard M. Stallman <rms@gnu.org>
parents: 18805
diff changeset
445 ;; This is not really correct, since the shell buffer does not really
f39ae9c61a45 (shell-mode): Do set list-files-directory locally.
Richard M. Stallman <rms@gnu.org>
parents: 18805
diff changeset
446 ;; edit this directory. But it is useful in the buffer list and menus.
f39ae9c61a45 (shell-mode): Do set list-files-directory locally.
Richard M. Stallman <rms@gnu.org>
parents: 18805
diff changeset
447 (setq list-buffers-directory (expand-file-name default-directory))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
448 ;; shell-dependent assignments.
45285
dc0eece6818b (shell-mode): Use (ring-empty-p rather than (zerop (ring-length.
Francesco Potortì <pot@gnu.org>
parents: 45284
diff changeset
449 (when (ring-empty-p comint-input-ring)
44374
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
450 (let ((shell (file-name-nondirectory (car
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
451 (process-command (get-buffer-process (current-buffer)))))))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
452 (setq comint-input-ring-file-name
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
453 (or (getenv "HISTFILE")
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
454 (cond ((string-equal shell "bash") "~/.bash_history")
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
455 ((string-equal shell "ksh") "~/.sh_history")
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
456 (t "~/.history"))))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
457 (if (or (equal comint-input-ring-file-name "")
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
458 (equal (file-truename comint-input-ring-file-name)
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
459 (file-truename "/dev/null")))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
460 (setq comint-input-ring-file-name nil))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
461 ;; Arrange to write out the input ring on exit, if the shell doesn't
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
462 ;; do this itself.
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
463 (if (and comint-input-ring-file-name
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
464 (string-match shell-dumb-shell-regexp shell))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
465 (set-process-sentinel (get-buffer-process (current-buffer))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
466 #'shell-write-history-on-exit))
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
467 (setq shell-dirstack-query
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
468 (cond ((string-equal shell "sh") "pwd")
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
469 ((string-equal shell "ksh") "echo $PWD ~-")
51482
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
470 (t "dirs")))
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
471 ;; Bypass a bug in certain versions of bash.
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
472 (when (string-equal shell "bash")
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
473 (add-hook 'comint-output-filter-functions
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
474 'shell-filter-ctrl-a-ctrl-b nil t)))
111518
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
475 (when shell-dir-cookie-re
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
476 ;; Watch for magic cookies in the output to track the current dir.
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
477 (add-hook 'comint-output-filter-functions
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
478 'shell-dir-cookie-watcher nil t))
44374
2472e2446b55 (shell-mode): Don't reinit comint-input-ring if that was already done.
Richard M. Stallman <rms@gnu.org>
parents: 43844
diff changeset
479 (comint-read-input-ring t)))
31617
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
480
51482
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
481 (defun shell-filter-ctrl-a-ctrl-b (string)
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
482 "Remove `^A' and `^B' characters from comint output.
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
483
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
484 Bash uses these characters as internal quoting characters in its
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
485 prompt. Due to a bug in some bash versions (including 2.03,
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
486 2.04, and 2.05b), they may erroneously show up when bash is
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
487 started with the `--noediting' option and Select Graphic
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
488 Rendition (SGR) control sequences (formerly known as ANSI escape
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
489 sequences) are used to color the prompt.
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
490
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
491 This function can be put on `comint-output-filter-functions'.
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
492 The argument STRING is ignored."
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
493 (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
494 (save-excursion
72621
82f0fddf878e (shell-filter-ctrl-a-ctrl-b): Check if `comint-last-output-start' is
Juri Linkov <juri@jurta.org>
parents: 71664
diff changeset
495 (goto-char (or (and (markerp comint-last-output-start)
82f0fddf878e (shell-filter-ctrl-a-ctrl-b): Check if `comint-last-output-start' is
Juri Linkov <juri@jurta.org>
parents: 71664
diff changeset
496 (marker-position comint-last-output-start))
82f0fddf878e (shell-filter-ctrl-a-ctrl-b): Check if `comint-last-output-start' is
Juri Linkov <juri@jurta.org>
parents: 71664
diff changeset
497 (point-min)))
51482
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
498 (while (re-search-forward "[\C-a\C-b]" pmark t)
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
499 (replace-match "")))))
8eb767cf7295 (shell-mode): Put `shell-filter-ctrl-a-ctrl-b' on
Lute Kamstra <lute@gnu.org>
parents: 49549
diff changeset
500
31617
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
501 (defun shell-write-history-on-exit (process event)
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
502 "Called when the shell process is stopped.
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
503
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
504 Writes the input history to a history file
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
505 `comint-input-ring-file-name' using `comint-write-input-ring'
31617
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
506 and inserts a short message in the shell buffer.
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
507
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
508 This function is a sentinel watching the shell interpreter process.
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
509 Sentinels will always get the two parameters PROCESS and EVENT."
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
510 ;; Write history.
3ed336667dbc (shell-write-history-on-exit): New function.
Andrew Innes <andrewi@gnu.org>
parents: 31037
diff changeset
511 (comint-write-input-ring)
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
512 (let ((buf (process-buffer process)))
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
513 (when (buffer-live-p buf)
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
514 (with-current-buffer buf
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
515 (insert (format "\nProcess %s %s\n" process event))))))
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
516
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
517 ;;;###autoload
32943
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
518 (defun shell (&optional buffer)
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
519 "Run an inferior shell, with I/O through BUFFER (which defaults to `*shell*').
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
520 Interactively, a prefix arg means to prompt for BUFFER.
82765
a8c46cf3e7aa * comint.el (comint-exec-1): Raise an error if
Michael Albinus <michael.albinus@gmx.de>
parents: 82140
diff changeset
521 If `default-directory' is a remote file name, it is also prompted
a8c46cf3e7aa * comint.el (comint-exec-1): Raise an error if
Michael Albinus <michael.albinus@gmx.de>
parents: 82140
diff changeset
522 to change if called with a prefix arg.
a8c46cf3e7aa * comint.el (comint-exec-1): Raise an error if
Michael Albinus <michael.albinus@gmx.de>
parents: 82140
diff changeset
523
32943
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
524 If BUFFER exists but shell process is not running, make new shell.
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
525 If BUFFER exists and shell process is running, just switch to BUFFER.
2609
af46e8faaa32 (shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents: 2573
diff changeset
526 Program used comes from variable `explicit-shell-file-name',
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
527 or (if that is nil) from the ESHELL environment variable,
74648
5afa3802aa64 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 74646
diff changeset
528 or (if that is nil) from `shell-file-name'.
74446
cc077225d97f (shell): Search the start file in ~/.emacs.d as `init_SHELLNAME.sh' instead.
Juanma Barranquero <lekktu@gmail.com>
parents: 74442
diff changeset
529 If a file `~/.emacs_SHELLNAME' exists, or `~/.emacs.d/init_SHELLNAME.sh',
74646
984d68f669d4 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 74446
diff changeset
530 it is given as initial input (but this may be lost, due to a timing
984d68f669d4 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 74446
diff changeset
531 error, if the shell discards input when it starts up).
1076
8a936037cedc entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 925
diff changeset
532 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
533 and controlling the subjobs of the shell. See `shell-mode'.
8a936037cedc entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 925
diff changeset
534 See also the variable `shell-prompt-pattern'.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
535
19121
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
536 To specify a coding system for converting non-ASCII characters
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
537 in the input and output to the shell, use \\[universal-coding-system-argument]
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
538 before \\[shell]. You can also specify this with \\[set-buffer-process-coding-system]
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
539 in the shell buffer, after you start the shell.
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
540 The default comes from `process-coding-system-alist' and
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
541 `default-process-coding-system'.
8fe7aa3f4ca2 (shell): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18878
diff changeset
542
252
1ef0a9b58e63 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 114
diff changeset
543 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
544 such as `explicit-csh-args'. If that symbol is a variable,
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
545 its value is used as a list of arguments when invoking the shell.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
546 Otherwise, one argument `-i' is passed to the shell.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
547
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
548 \(Type \\[describe-mode] in the shell buffer for a list of commands.)"
32943
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
549 (interactive
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
550 (list
a0120c3e98f7 (shell): Add BUFFER argument.
Miles Bader <miles@gnu.org>
parents: 31617
diff changeset
551 (and current-prefix-arg
83753
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
552 (prog1
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
553 (read-buffer "Shell buffer: "
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
554 (generate-new-buffer-name "*shell*"))
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
555 (if (file-remote-p default-directory)
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
556 ;; It must be possible to declare a local default-directory.
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
557 (setq default-directory
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
558 (expand-file-name
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
559 (read-file-name
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
560 "Default directory: " default-directory default-directory
63012e03e1d4 (shell): Return correct value from interactive spec.
Andreas Schwab <schwab@suse.de>
parents: 82765
diff changeset
561 t nil 'file-directory-p))))))))
106439
f2a95599cf8c * shell.el (shell): Require ansi-color (Bug#5113).
Chong Yidong <cyd@stupidchicken.com>
parents: 105870
diff changeset
562 (require 'ansi-color)
41777
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
563 (setq buffer (get-buffer-create (or buffer "*shell*")))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
564 ;; Pop to buffer, so that the buffer's window will be correctly set
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
565 ;; when we call comint (so that comint sets the COLUMNS env var properly).
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
566 (pop-to-buffer buffer)
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
567 (unless (comint-check-proc buffer)
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
568 (let* ((prog (or explicit-shell-file-name
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
569 (getenv "ESHELL") shell-file-name))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
570 (name (file-name-nondirectory prog))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
571 (startfile (concat "~/.emacs_" name))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
572 (xargs-name (intern-soft (concat "explicit-" name "-args"))))
74446
cc077225d97f (shell): Search the start file in ~/.emacs.d as `init_SHELLNAME.sh' instead.
Juanma Barranquero <lekktu@gmail.com>
parents: 74442
diff changeset
573 (unless (file-exists-p startfile)
81340
b612fb999814 (shell): Use user-emacs-directory.
Chong Yidong <cyd@stupidchicken.com>
parents: 76294
diff changeset
574 (setq startfile (concat user-emacs-directory "init_" name ".sh")))
41777
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
575 (apply 'make-comint-in-buffer "shell" buffer prog
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
576 (if (file-exists-p startfile) startfile)
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
577 (if (and xargs-name (boundp xargs-name))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
578 (symbol-value xargs-name)
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
579 '("-i")))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
580 (shell-mode)))
ca6dfcb53a03 (shell): Use shell-file-name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38409
diff changeset
581 buffer)
10975
5abad4aec8e0 (shell): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 10878
diff changeset
582
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
583 ;; Don't do this when shell.el is loaded, only while dumping.
105798
0ad1fc06bfc8 * puresize.h (BASE_PURESIZE): Increase to 1470000.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105196
diff changeset
584 ;;;###autoload (add-hook 'same-window-buffer-names (purecopy "*shell*"))
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
585
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
586 ;;; Directory tracking
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
587 ;;
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
588 ;; This code provides the shell mode input sentinel
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
589 ;; SHELL-DIRECTORY-TRACKER
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
590 ;; that tracks cd, pushd, and popd commands issued to the shell, and
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
591 ;; changes the current directory of the shell buffer accordingly.
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
592 ;;
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
593 ;; This is basically a fragile hack, although it's more accurate than
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
594 ;; the version in Emacs 18's shell.el. It has the following failings:
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
595 ;; 1. It doesn't know about the cdpath shell variable.
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
596 ;; 2. It cannot infallibly deal with command sequences, though it does well
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
597 ;; with these and with ignoring commands forked in another shell with ()s.
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
598 ;; 3. More generally, any complex command is going to throw it. Otherwise,
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
599 ;; you'd have to build an entire shell interpreter in Emacs Lisp. Failing
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
600 ;; that, there's no way to catch shell commands where cd's are buried
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
601 ;; inside conditional expressions, aliases, and so forth.
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
602 ;;
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
603 ;; The whole approach is a crock. Shell aliases mess it up. File sourcing
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
604 ;; messes it up. You run other processes under the shell; these each have
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
605 ;; separate working directories, and some have commands for manipulating
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
606 ;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
607 ;; commands that do *not* affect the current w.d. at all, but look like they
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
608 ;; do (e.g., the cd command in ftp). In shells that allow you job
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
609 ;; control, you can switch between jobs, all having different w.d.'s. So
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
610 ;; simply saying %3 can shift your w.d..
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
611 ;;
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
612 ;; The solution is to relax, not stress out about it, and settle for
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
613 ;; a hack that works pretty well in typical circumstances. Remember
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
614 ;; that a half-assed solution is more in keeping with the spirit of Unix,
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
615 ;; anyway. Blech.
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
616 ;;
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
617 ;; One good hack not implemented here for users of programmable shells
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
618 ;; is to program up the shell w.d. manipulation commands to output
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
619 ;; a coded command sequence to the tty. Something like
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
620 ;; ESC | <cwd> |
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
621 ;; where <cwd> is the new current working directory. Then trash the
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
622 ;; directory tracking machinery currently used in this package, and
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
623 ;; replace it with a process filter that watches for and strips out
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
624 ;; these messages.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
625
111518
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
626 (defcustom shell-dir-cookie-re nil
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
627 "Regexp matching your prompt, including some part of the current directory.
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
628 If your prompt includes the current directory or the last few elements of it,
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
629 set this to a pattern that matches your prompt and whose subgroup 1 matches
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
630 the directory part of it.
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
631 This is used by `shell-dir-cookie-watcher' to try and use this info
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
632 to track your current directory. It can be used instead of or in addition
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
633 to `dirtrack-mode'."
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
634 :type '(choice (const nil) regexp))
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
635
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
636 (defun shell-dir-cookie-watcher (text)
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
637 ;; This is fragile: the TEXT could be split into several chunks and we'd
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
638 ;; miss it. Oh well. It's a best effort anyway. I'd expect that it's
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
639 ;; rather unusual to have the prompt split into several packets, but
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
640 ;; I'm sure Murphy will prove me wrong.
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
641 (when (and shell-dir-cookie-re (string-match shell-dir-cookie-re text))
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
642 (let ((dir (match-string 1 text)))
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
643 (cond
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
644 ((file-name-absolute-p dir) (shell-cd dir))
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
645 ;; Let's try and see if it seems to be up or down from where we were.
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
646 ((string-match "\\`\\(.*\\)\\(?:/.*\\)?\n\\(.*/\\)\\1\\(?:/.*\\)?\\'"
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
647 (setq text (concat dir "\n" default-directory)))
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
648 (shell-cd (concat (match-string 2 text) dir)))))))
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
649
adbfcf85c8eb * lisp/shell.el (shell-dir-cookie-re): New custom variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
650
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
651 (defun shell-directory-tracker (str)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
652 "Tracks cd, pushd and popd commands issued to the shell.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
653 This function is called on each input passed to the shell.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
654 It watches for cd, pushd and popd commands and sets the buffer's
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
655 default directory to track these commands.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
656
85709
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
657 You may toggle this tracking on and off with \\[shell-dirtrack-mode].
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
658 If Emacs gets confused, you can resync with the shell with \\[dirs].
85787
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
659 \(The `dirtrack' package provides an alternative implementation of this
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
660 feature - see the function `dirtrack-mode'.)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
661
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
662 See variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp',
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
663 and `shell-popd-regexp', while `shell-pushd-tohome', `shell-pushd-dextract',
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
664 and `shell-pushd-dunique' 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
665
2609
af46e8faaa32 (shell-prompt-pattern): Undo last change.
Richard M. Stallman <rms@gnu.org>
parents: 2573
diff changeset
666 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
667 (if shell-dirtrackp
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
668 ;; 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
669 (condition-case chdir-failure
51554
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
670 (let ((start (progn (string-match
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
671 (concat "^" shell-command-separator-regexp)
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
672 str) ; skip whitespace
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
673 (match-end 0)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
674 end cmd arg1)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
675 (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
676 (setq end (match-end 0)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
677 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
678 arg1 (comint-arguments (substring str start end) 1 1))
24967
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
679 (if arg1
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
680 (setq arg1 (shell-unquote-argument arg1)))
12323
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
681 (cond ((string-match (concat "\\`\\(" shell-popd-regexp
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
682 "\\)\\($\\|[ \t]\\)")
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
683 cmd)
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
684 (shell-process-popd (comint-substitute-in-file-name arg1)))
12323
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
685 ((string-match (concat "\\`\\(" shell-pushd-regexp
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
686 "\\)\\($\\|[ \t]\\)")
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
687 cmd)
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
688 (shell-process-pushd (comint-substitute-in-file-name arg1)))
12323
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
689 ((string-match (concat "\\`\\(" shell-cd-regexp
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
690 "\\)\\($\\|[ \t]\\)")
a48a0352b344 (shell-directory-tracker): Check for terminator after
Karl Heuer <kwzh@gnu.org>
parents: 12213
diff changeset
691 cmd)
15370
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
692 (shell-process-cd (comint-substitute-in-file-name arg1)))
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
693 ((and shell-chdrive-regexp
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
694 (string-match (concat "\\`\\(" shell-chdrive-regexp
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
695 "\\)\\($\\|[ \t]\\)")
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
696 cmd))
b75fc8f3b376 (shell-directory-tracker): Use comint-substitute-in-file-name to
Richard M. Stallman <rms@gnu.org>
parents: 15327
diff changeset
697 (shell-process-cd (comint-substitute-in-file-name cmd))))
51554
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
698 (setq start (progn (string-match shell-command-separator-regexp
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
699 str end)
8cf86bc95fe5 (shell-command-separator-regexp): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 51519
diff changeset
700 ;; skip again
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
701 (match-end 0)))))
6189
4ff931c18e4b Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents: 6186
diff changeset
702 (error "Couldn't cd"))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
703
24967
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
704 (defun shell-unquote-argument (string)
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
705 "Remove all kinds of shell quoting from STRING."
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
706 (save-match-data
35643
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
707 (let ((idx 0) next inside
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
708 (quote-chars
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
709 (if (string-match shell-dumb-shell-regexp
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
710 (file-name-nondirectory
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
711 (car (process-command (get-buffer-process (current-buffer))))))
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
712 "['`\"]"
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
713 "[\\'`\"]")))
24967
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
714 (while (and (< idx (length string))
35643
cafc43e2ccfd (shell-unquote-argument): If the shell is one of the
Eli Zaretskii <eliz@gnu.org>
parents: 33706
diff changeset
715 (setq next (string-match quote-chars string next)))
24967
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
716 (cond ((= (aref string next) ?\\)
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
717 (setq string (replace-match "" nil nil string))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
718 (setq next (1+ next)))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
719 ((and inside (= (aref string next) inside))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
720 (setq string (replace-match "" nil nil string))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
721 (setq inside nil))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
722 (inside
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
723 (setq next (1+ next)))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
724 (t
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
725 (setq inside (aref string next))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
726 (setq string (replace-match "" nil nil string)))))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
727 string)))
03990f1d9e2d (shell-unquote-argument): New function.
Karl Heuer <kwzh@gnu.org>
parents: 24738
diff changeset
728
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
729 ;; popd [+n]
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
730 (defun shell-process-popd (arg)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
731 (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
732 (cond ((and num (= num 0) shell-dirstack)
111416
7a88e72dff57 * shell.el (shell-process-popd): Made aware of comint-file-name-prefix.
Michael Albinus <michael.albinus@gmx.de>
parents: 110909
diff changeset
733 (shell-cd (shell-prefixed-directory-name (car shell-dirstack)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
734 (setq shell-dirstack (cdr shell-dirstack))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
735 (shell-dirstack-message))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
736 ((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
737 (let* ((ds (cons nil shell-dirstack))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
738 (cell (nthcdr (1- num) ds)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
739 (rplacd cell (cdr (cdr cell)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
740 (setq shell-dirstack (cdr ds))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
741 (shell-dirstack-message)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
742 (t
6189
4ff931c18e4b Rename comint-input-filter-functions and
Richard M. Stallman <rms@gnu.org>
parents: 6186
diff changeset
743 (error "Couldn't popd")))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
744
5474
239620e1795d (shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents: 5335
diff changeset
745 ;; Return DIR prefixed with comint-file-name-prefix as appropriate.
8033
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
746 (defun shell-prefixed-directory-name (dir)
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
747 (if (= (length comint-file-name-prefix) 0)
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
748 dir
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
749 (if (file-name-absolute-p dir)
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
750 ;; The name is absolute, so prepend the prefix.
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
751 (concat comint-file-name-prefix dir)
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
752 ;; For relative name we assume default-directory already has the prefix.
8033
bedead77e86f (shell-prefixed-directory-name): Do nothing if
Richard M. Stallman <rms@gnu.org>
parents: 7610
diff changeset
753 (expand-file-name dir))))
5474
239620e1795d (shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents: 5335
diff changeset
754
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
755 ;; cd [dir]
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
756 (defun shell-process-cd (arg)
5474
239620e1795d (shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents: 5335
diff changeset
757 (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
758 "~"))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
759 ((string-equal "-" arg) shell-last-dir)
5474
239620e1795d (shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents: 5335
diff changeset
760 (t (shell-prefixed-directory-name arg)))))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
761 (setq shell-last-dir default-directory)
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
762 (shell-cd new-dir)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
763 (shell-dirstack-message)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
764
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
765 ;; pushd [+n | dir]
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
766 (defun shell-process-pushd (arg)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
767 (let ((num (shell-extract-num arg)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
768 (cond ((zerop (length arg))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
769 ;; 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
770 (cond (shell-pushd-tohome
5474
239620e1795d (shell-cd): Function removed.
Roland McGrath <roland@gnu.org>
parents: 5335
diff changeset
771 (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
772 (shell-dirstack
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
773 (let ((old default-directory))
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
774 (shell-cd (car shell-dirstack))
14476
63540fa43674 Resync directories properly for the ksh.
Simon Marshall <simon@gnu.org>
parents: 14329
diff changeset
775 (setq shell-dirstack (cons old (cdr shell-dirstack)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
776 (shell-dirstack-message)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
777 (t
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
778 (message "Directory stack empty."))))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
779 ((numberp num)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
780 ;; pushd +n
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
781 (cond ((> num (length shell-dirstack))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
782 (message "Directory stack not that deep."))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
783 ((= num 0)
38409
153f1b1f2efd Emacs lisp coding convention fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 35659
diff changeset
784 (error (message "Couldn't cd")))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
785 (shell-pushd-dextract
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
786 (let ((dir (nth (1- num) shell-dirstack)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
787 (shell-process-popd arg)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
788 (shell-process-pushd default-directory)
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
789 (shell-cd dir)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
790 (shell-dirstack-message)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
791 (t
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
792 (let* ((ds (cons default-directory shell-dirstack))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
793 (dslen (length ds))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
794 (front (nthcdr num ds))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
795 (back (reverse (nthcdr (- dslen num) (reverse ds))))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
796 (new-ds (append front back)))
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
797 (shell-cd (car new-ds))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
798 (setq shell-dirstack (cdr new-ds))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
799 (shell-dirstack-message)))))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
800 (t
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
801 ;; pushd <dir>
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
802 (let ((old-wd default-directory))
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
803 (shell-cd (shell-prefixed-directory-name arg))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
804 (if (or (null shell-pushd-dunique)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
805 (not (member old-wd shell-dirstack)))
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
806 (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
807 (shell-dirstack-message))))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
808
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
809 ;; 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
810 (defun shell-extract-num (str)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
811 (and (string-match "^\\+[1-9][0-9]*$" str)
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 61876
diff changeset
812 (string-to-number str)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
813
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
814 (defvaralias 'shell-dirtrack-mode 'shell-dirtrackp)
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
815 (define-minor-mode shell-dirtrack-mode
85787
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
816 "Turn directory tracking on and off in a shell buffer.
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
817 The `dirtrack' package provides an alternative implementation of this
7dd3117fb9a3 (shell-dirtrack-verbose, shell-mode, shell-directory-tracker)
Glenn Morris <rgm@gnu.org>
parents: 85709
diff changeset
818 feature - see the function `dirtrack-mode'."
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
819 nil nil nil
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
820 (setq list-buffers-directory (if shell-dirtrack-mode default-directory))
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
821 (if shell-dirtrack-mode
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
822 (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t)
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
823 (remove-hook 'comint-input-filter-functions 'shell-directory-tracker t)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
824
85709
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
825 (define-obsolete-function-alias 'shell-dirtrack-toggle 'shell-dirtrack-mode
2dabdbde81e8 (shell-dirtrack-verbose, shell-directory-tracker): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 84531
diff changeset
826 "23.1")
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
827
10791
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
828 (defun shell-cd (dir)
1d1db37a4bb7 Change all `cd's to `shell-cd's, where `shell-cd' changes the value of
Simon Marshall <simon@gnu.org>
parents: 10657
diff changeset
829 "Do normal `cd' to DIR, and set `list-buffers-directory'."
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
830 (cd dir)
10878
9556a4d578f2 Make sure shell-cd sets list-buffers-directory to a directory ending with `/'.
Simon Marshall <simon@gnu.org>
parents: 10832
diff changeset
831 (if shell-dirtrackp
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
832 (setq list-buffers-directory default-directory)))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
833
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
834 (defun shell-resync-dirs ()
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
835 "Resync the buffer's idea of the current directory stack.
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
836 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
837 `shell-dirstack-query' (default \"dirs\"), reads the next
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
838 line output and parses it to form the new directory stack.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
839 DON'T issue this command unless the buffer is at a shell prompt.
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
840 Also, note that if some other subprocess decides to do output
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
841 immediately after the query, its output will be taken as the
65199
23741bfb23af (shell-mode, shell-resync-dirs): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 64762
diff changeset
842 new directory stack -- you lose. If this happens, just do the
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
843 command again."
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
844 (interactive)
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
845 (let* ((proc (get-buffer-process (current-buffer)))
78770
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
846 (pmark (process-mark proc))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
847 (started-at-pmark (= (point) (marker-position pmark))))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
848 (save-excursion
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
849 (goto-char pmark)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
850 ;; If the process echoes commands, don't insert a fake command in
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
851 ;; the buffer or it will appear twice.
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
852 (unless comint-process-echoes
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
853 (insert shell-dirstack-query) (insert "\n"))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
854 (sit-for 0) ; force redisplay
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
855 (comint-send-string proc shell-dirstack-query)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
856 (comint-send-string proc "\n")
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
857 (set-marker pmark (point))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
858 (let ((pt (point))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
859 (regexp
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
860 (concat
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
861 (if comint-process-echoes
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
862 ;; Skip command echo if the process echoes
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
863 (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)")
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
864 "\\(\\)")
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
865 "\\(.+\n\\)")))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
866 ;; This extra newline prevents the user's pending input from spoofing us.
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
867 (insert "\n") (backward-char 1)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
868 ;; Wait for one line.
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
869 (while (not (looking-at regexp))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
870 (accept-process-output proc)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
871 (goto-char pt)))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
872 (goto-char pmark) (delete-char 1) ; remove the extra newline
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
873 ;; That's the dirlist. grab it & parse it.
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
874 (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2))))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
875 (dl-len (length dl))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
876 (ds '()) ; new dir stack
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
877 (i 0))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
878 (while (< i dl-len)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
879 ;; regexp = optional whitespace, (non-whitespace), optional whitespace
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
880 (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
881 (setq ds (cons (concat comint-file-name-prefix
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
882 (substring dl (match-beginning 1)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
883 (match-end 1)))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
884 ds))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
885 (setq i (match-end 0)))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
886 (let ((ds (nreverse ds)))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
887 (condition-case nil
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
888 (progn (shell-cd (car ds))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
889 (setq shell-dirstack (cdr ds)
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
890 shell-last-dir (car shell-dirstack))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
891 (shell-dirstack-message))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
892 (error (message "Couldn't cd"))))))
6db70c3a1837 Chris Moore <dooglus at gmail.com>
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
893 (if started-at-pmark (goto-char (marker-position pmark)))))
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
894
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
895 ;; For your typing convenience:
2571
b65cf676a09b All fsets changed to defaliases.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2557
diff changeset
896 (defalias 'dirs 'shell-resync-dirs)
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
897
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
898
70691
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
899 ;; Show the current dirstack on the message line.
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
900 ;; Pretty up dirs a bit by changing "/usr/jqr/foo" to "~/foo".
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
901 ;; (This isn't necessary if the dirlisting is generated with a simple "dirs".)
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
902 ;; All the commands that mung the buffer's dirstack finish by calling
a69f2db3d3ae (shell-dirtrack-mode): Make it into a proper minor mode, so
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 69758
diff changeset
903 ;; this guy.
114
899728e6052a Initial revision
David Lawrence <tale@gnu.org>
parents:
diff changeset
904 (defun shell-dirstack-message ()
24069
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
905 (when shell-dirtrack-verbose
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
906 (let* ((msg "")
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
907 (ds (cons default-directory shell-dirstack))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
908 (home (expand-file-name (concat comint-file-name-prefix "~/")))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
909 (homelen (length home)))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
910 (while ds
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
911 (let ((dir (car ds)))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
912 (and (>= (length dir) homelen)
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
913 (string= home (substring dir 0 homelen))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
914 (setq dir (concat "~/" (substring dir homelen))))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
915 ;; Strip off comint-file-name-prefix if present.
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
916 (and comint-file-name-prefix
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
917 (>= (length dir) (length comint-file-name-prefix))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
918 (string= comint-file-name-prefix
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
919 (substring dir 0 (length comint-file-name-prefix)))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
920 (setq dir (substring dir (length comint-file-name-prefix)))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
921 (setcar ds dir))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
922 (setq msg (concat msg (directory-file-name dir) " "))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
923 (setq ds (cdr ds))))
8d500ceed9d1 * shell.el (shell-dirtrack-verbose): New custom variable.
Simon Marshall <simon@gnu.org>
parents: 23744
diff changeset
924 (message "%s" msg))))
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
925
19476
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
926 ;; This was mostly copied from shell-resync-dirs.
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
927 (defun shell-snarf-envar (var)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
928 "Return as a string the shell's value of environment variable VAR."
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
929 (let* ((cmd (format "printenv '%s'\n" var))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
930 (proc (get-buffer-process (current-buffer)))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
931 (pmark (process-mark proc)))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
932 (goto-char pmark)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
933 (insert cmd)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
934 (sit-for 0) ; force redisplay
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
935 (comint-send-string proc cmd)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
936 (set-marker pmark (point))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
937 (let ((pt (point))) ; wait for 1 line
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
938 ;; This extra newline prevents the user's pending input from spoofing us.
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
939 (insert "\n") (backward-char 1)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
940 (while (not (looking-at ".+\n"))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
941 (accept-process-output proc)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
942 (goto-char pt)))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
943 (goto-char pmark) (delete-char 1) ; remove the extra newline
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
944 (buffer-substring (match-beginning 0) (1- (match-end 0)))))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
945
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
946 (defun shell-copy-environment-variable (variable)
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
947 "Copy the environment variable VARIABLE from the subshell to Emacs.
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
948 This command reads the value of the specified environment variable
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
949 in the shell, and sets the same environment variable in Emacs
22636
f15c3c6ad8ae (shell-copy-environment-variable): Fix doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 21621
diff changeset
950 \(what `getenv' in Emacs would return) to that value.
19476
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
951 That value will affect any new subprocesses that you subsequently start
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
952 from Emacs."
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
953 (interactive (list (read-envvar-name "\
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
954 Copy Shell environment variable to Emacs: ")))
4ae9466b064e (shell-snarf-envar, shell-copy-environment-variable): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 19469
diff changeset
955 (setenv variable (shell-snarf-envar variable)))
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
956
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
957 (defun shell-forward-command (&optional arg)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
958 "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
959 See `shell-command-regexp'."
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
960 (interactive "p")
111429
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 111416
diff changeset
961 (let ((limit (line-end-position)))
7377
027616e7b1e4 (shell-forward-command, shell-backward-command): Fix regexp.
Karl Heuer <kwzh@gnu.org>
parents: 7083
diff changeset
962 (if (re-search-forward (concat shell-command-regexp "\\([;&|][\t ]*\\)+")
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
963 limit 'move arg)
5335
abf0d4d01681 (shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents: 5285
diff changeset
964 (skip-syntax-backward " "))))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
965
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
966
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
967 (defun shell-backward-command (&optional arg)
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
968 "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
969 See `shell-command-regexp'."
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
970 (interactive "p")
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
971 (let ((limit (save-excursion (comint-bol nil) (point))))
30641
297909766bad (shell-prompt-pattern): Doc change.
Miles Bader <miles@gnu.org>
parents: 25278
diff changeset
972 (when (> limit (point))
297909766bad (shell-prompt-pattern): Doc change.
Miles Bader <miles@gnu.org>
parents: 25278
diff changeset
973 (setq limit (line-beginning-position)))
5335
abf0d4d01681 (shell-backward-command): If comint-bol moves forward,
Richard M. Stallman <rms@gnu.org>
parents: 5285
diff changeset
974 (skip-syntax-backward " " limit)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
975 (if (re-search-backward
7377
027616e7b1e4 (shell-forward-command, shell-backward-command): Fix regexp.
Karl Heuer <kwzh@gnu.org>
parents: 7083
diff changeset
976 (format "[;&|]+[\t ]*\\(%s\\)" shell-command-regexp) limit 'move arg)
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
977 (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
978 (skip-chars-forward ";&|")))))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
979
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
980 (defun shell-dynamic-complete-command ()
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
981 "Dynamically complete the command at point.
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
982 This function is similar to `comint-dynamic-complete-filename', except that it
69758
2b93f40e4545 (shell-directory-tracker, shell-dynamic-complete-command): Doc fixes.
Eli Zaretskii <eliz@gnu.org>
parents: 68651
diff changeset
983 searches `exec-path' (minus the trailing Emacs library path) for completion
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
984 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
985 path.
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
986
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
987 Completion is dependent on the value of `shell-completion-execonly', plus
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
988 those that effect file completion. See `shell-dynamic-complete-as-command'.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
989
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
990 Returns t if successful."
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
991 (interactive)
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
992 (let ((filename (comint-match-partial-filename)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
993 (if (and filename
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
994 (save-match-data (not (string-match "[~/]" filename)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
995 (eq (match-beginning 0)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
996 (save-excursion (shell-backward-command 1) (point))))
93133
503666735e0c (shell-dynamic-complete-command)
Juri Linkov <juri@jurta.org>
parents: 87649
diff changeset
997 (prog2 (unless (window-minibuffer-p (selected-window))
503666735e0c (shell-dynamic-complete-command)
Juri Linkov <juri@jurta.org>
parents: 87649
diff changeset
998 (message "Completing command name..."))
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
999 (shell-dynamic-complete-as-command)))))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1000
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1001
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1002 (defun shell-dynamic-complete-as-command ()
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1003 "Dynamically complete at point as a command.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1004 See `shell-dynamic-complete-filename'. Returns t if successful."
6508
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
1005 (let* ((filename (or (comint-match-partial-filename) ""))
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1006 (filenondir (file-name-nondirectory filename))
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1007 (path-dirs (cdr (reverse exec-path)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
1008 (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
1009 (ignored-extensions
6295
59a6684e8057 (shell-dynamic-complete-as-command): Make ignored-extensions
Richard M. Stallman <rms@gnu.org>
parents: 6255
diff changeset
1010 (and comint-completion-fignore
59a6684e8057 (shell-dynamic-complete-as-command): Make ignored-extensions
Richard M. Stallman <rms@gnu.org>
parents: 6255
diff changeset
1011 (mapconcat (function (lambda (x) (concat (regexp-quote x) "$")))
59a6684e8057 (shell-dynamic-complete-as-command): Make ignored-extensions
Richard M. Stallman <rms@gnu.org>
parents: 6255
diff changeset
1012 comint-completion-fignore "\\|")))
63507
e5299a8016cb (shell-prompt-pattern, shell-dynamic-complete-functions, shell-mode,
Juanma Barranquero <lekktu@gmail.com>
parents: 62402
diff changeset
1013 (dir "") (comps-in-dir ())
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1014 (file "") (abs-file-name "") (completions ()))
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1015 ;; Go thru each dir in the search path, finding completions.
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1016 (while path-dirs
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1017 (setq dir (file-name-as-directory (comint-directory (or (car path-dirs) ".")))
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1018 comps-in-dir (and (file-accessible-directory-p dir)
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1019 (file-name-all-completions filenondir dir)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
1020 ;; Go thru each completion found, to see whether it should be used.
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1021 (while comps-in-dir
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1022 (setq file (car comps-in-dir)
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1023 abs-file-name (concat dir file))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
1024 (if (and (not (member file completions))
6885
3c007de39916 (shell-dynamic-complete-as-command): Don't match ignored-extensions if it's nil.
Karl Heuer <kwzh@gnu.org>
parents: 6508
diff changeset
1025 (not (and ignored-extensions
3c007de39916 (shell-dynamic-complete-as-command): Don't match ignored-extensions if it's nil.
Karl Heuer <kwzh@gnu.org>
parents: 6508
diff changeset
1026 (string-match ignored-extensions file)))
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1027 (or (string-equal dir cwd)
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1028 (not (file-directory-p abs-file-name)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
1029 (or (null shell-completion-execonly)
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1030 (file-executable-p abs-file-name)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
1031 (setq completions (cons file completions)))
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1032 (setq comps-in-dir (cdr comps-in-dir)))
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1033 (setq path-dirs (cdr path-dirs)))
4871
30a614eb52f7 (shell-after-partial-filename): Renamed from
Richard M. Stallman <rms@gnu.org>
parents: 4679
diff changeset
1034 ;; OK, we've got a list of completions.
6508
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
1035 (let ((success (let ((comint-completion-addsuffix nil))
53402
7e645ea92195 (shell-file-name-chars): Add [].
Richard M. Stallman <rms@gnu.org>
parents: 53273
diff changeset
1036 (comint-dynamic-simple-complete filenondir completions))))
6508
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
1037 (if (and (memq success '(sole shortest)) comint-completion-addsuffix
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
1038 (not (file-directory-p (comint-match-partial-filename))))
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
1039 (insert " "))
965beb0c97d2 (shell-strip-ctrl-m): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6295
diff changeset
1040 success)))
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1041
93587
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1042 (defun shell-dynamic-complete-filename ()
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1043 "Dynamically complete the filename at point.
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1044 This completes only if point is at a suitable position for a
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1045 filename argument."
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1046 (interactive)
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1047 (let ((opoint (point))
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1048 (beg (comint-line-beginning-position)))
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1049 (when (save-excursion
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1050 (goto-char (if (re-search-backward "[;|&]" beg t)
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1051 (match-end 0)
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1052 beg))
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1053 (re-search-forward "[^ \t][ \t]" opoint t))
f4738cb320e1 (shell-dynamic-complete-filename): New fun.
Chong Yidong <cyd@stupidchicken.com>
parents: 93133
diff changeset
1054 (comint-dynamic-complete-as-filename))))
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1055
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1056 (defun shell-match-partial-variable ()
15327
2c508f2c884d (shell-match-partial-variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 14476
diff changeset
1057 "Return the shell variable at point, or nil if none is found."
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1058 (save-excursion
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1059 (let ((limit (point)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1060 (if (re-search-backward "[^A-Za-z0-9_{}]" nil 'move)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1061 (or (looking-at "\\$") (forward-char 1)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1062 ;; Anchor the search forwards.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1063 (if (or (eolp) (looking-at "[^A-Za-z0-9_{}$]"))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1064 nil
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1065 (re-search-forward "\\$?{?[A-Za-z0-9_]*}?" limit)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1066 (buffer-substring (match-beginning 0) (match-end 0))))))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1067
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1068 (defun shell-dynamic-complete-environment-variable ()
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1069 "Dynamically complete the environment variable at point.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1070 Completes if after a variable, i.e., if it starts with a \"$\".
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1071 See `shell-dynamic-complete-as-environment-variable'.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1072
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1073 This function is similar to `comint-dynamic-complete-filename', except that it
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1074 searches `process-environment' for completion candidates. Note that this may
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1075 not be the same as the interpreter's idea of variable names. The main problem
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1076 with this type of completion is that `process-environment' is the environment
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1077 which Emacs started with. Emacs does not track changes to the environment made
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1078 by the interpreter. Perhaps it would be more accurate if this function was
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1079 called `shell-dynamic-complete-process-environment-variable'.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1080
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1081 Returns non-nil if successful."
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1082 (interactive)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1083 (let ((variable (shell-match-partial-variable)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1084 (if (and variable (string-match "^\\$" variable))
93133
503666735e0c (shell-dynamic-complete-command)
Juri Linkov <juri@jurta.org>
parents: 87649
diff changeset
1085 (prog2 (unless (window-minibuffer-p (selected-window))
503666735e0c (shell-dynamic-complete-command)
Juri Linkov <juri@jurta.org>
parents: 87649
diff changeset
1086 (message "Completing variable name..."))
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1087 (shell-dynamic-complete-as-environment-variable)))))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1088
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1089
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1090 (defun shell-dynamic-complete-as-environment-variable ()
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1091 "Dynamically complete at point as an environment variable.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1092 Used by `shell-dynamic-complete-environment-variable'.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1093 Uses `comint-dynamic-simple-complete'."
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1094 (let* ((var (or (shell-match-partial-variable) ""))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1095 (variable (substring var (or (string-match "[^$({]\\|$" var) 0)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1096 (variables (mapcar (function (lambda (x)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1097 (substring x 0 (string-match "=" x))))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1098 process-environment))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1099 (addsuffix comint-completion-addsuffix)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1100 (comint-completion-addsuffix nil)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1101 (success (comint-dynamic-simple-complete variable variables)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1102 (if (memq success '(sole shortest))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1103 (let* ((var (shell-match-partial-variable))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1104 (variable (substring var (string-match "[^$({]" var)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1105 (protection (cond ((string-match "{" var) "}")
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1106 ((string-match "(" var) ")")
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1107 (t "")))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1108 (suffix (cond ((null addsuffix) "")
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1109 ((file-directory-p
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1110 (comint-directory (getenv variable))) "/")
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1111 (t " "))))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1112 (insert protection suffix)))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1113 success))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1114
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1115
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1116 (defun shell-replace-by-expanded-directory ()
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1117 "Expand directory stack reference before point.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1118 Directory stack references are of the form \"=digit\" or \"=-\".
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1119 See `default-directory' and `shell-dirstack'.
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1120
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1121 Returns t if successful."
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1122 (interactive)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1123 (if (comint-match-partial-filename)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1124 (save-excursion
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1125 (goto-char (match-beginning 0))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1126 (let ((stack (cons default-directory shell-dirstack))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1127 (index (cond ((looking-at "=-/?")
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1128 (length shell-dirstack))
45214
793403e94381 (shell-replace-by-expanded-directory):
Richard M. Stallman <rms@gnu.org>
parents: 44374
diff changeset
1129 ((looking-at "=\\([0-9]+\\)/?")
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1130 (string-to-number
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1131 (buffer-substring
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1132 (match-beginning 1) (match-end 1)))))))
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1133 (cond ((null index)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1134 nil)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1135 ((>= index (length stack))
38409
153f1b1f2efd Emacs lisp coding convention fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 35659
diff changeset
1136 (error "Directory stack not that deep"))
6186
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1137 (t
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1138 (replace-match (file-name-as-directory (nth index stack)) t t)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1139 (message "Directory item: %d" index)
84df7a6f6240 (shell-dynamic-complete-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6155
diff changeset
1140 t))))))
35659
aa45cec8f927 shell-write-history-on-exit: make sure the error message goes to the right buffer
Sam Steingold <sds@gnu.org>
parents: 35643
diff changeset
1141
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
1142 (provide 'shell)
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
1143
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 252
diff changeset
1144 ;;; shell.el ends here