comparison lisp/comint/shell.el @ 134:34a5b81f86ba r20-2b1

Import from CVS: tag r20-2b1
author cvs
date Mon, 13 Aug 2007 09:30:11 +0200
parents 360340f9fd5f
children 43dd3413c7c7
comparison
equal deleted inserted replaced
133:b27e67717092 134:34a5b81f86ba
108 108
109 ;;; Code: 109 ;;; Code:
110 110
111 (require 'comint) 111 (require 'comint)
112 112
113 (defgroup shell nil
114 "Running shell from within Emacs buffers"
115 :group 'processes
116 :group 'unix)
117
118 (defgroup shell-directories nil
119 "Directory support in shell mode"
120 :group 'shell)
121
122 (defgroup shell-faces nil
123 "Faces in shell buffers"
124 :group 'shell)
125
113 ;;;###autoload 126 ;;;###autoload
114 (defvar shell-prompt-pattern (purecopy "^[^#$%>\n]*[#$%>] *") 127 (defvar shell-prompt-pattern (purecopy "^[^#$%>\n]*[#$%>] *")
115 "Regexp to match prompts in the inferior shell. 128 "Regexp to match prompts in the inferior shell.
116 Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. 129 Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well.
117 This variable is used to initialise `comint-prompt-regexp' in the 130 This variable is used to initialise `comint-prompt-regexp' in the
121 shell-mode may become confused trying to distinguish prompt from input 134 shell-mode may become confused trying to distinguish prompt from input
122 on lines which don't start with a prompt. 135 on lines which don't start with a prompt.
123 136
124 This is a fine thing to set in your `.emacs' file.") 137 This is a fine thing to set in your `.emacs' file.")
125 138
126 (defvar shell-completion-fignore nil 139 (defcustom shell-completion-fignore nil
127 "*List of suffixes to be disregarded during file/command completion. 140 "*List of suffixes to be disregarded during file/command completion.
128 This variable is used to initialize `comint-completion-fignore' in the shell 141 This variable is used to initialize `comint-completion-fignore' in the shell
129 buffer. The default is nil, for compatibility with most shells. 142 buffer. The default is nil, for compatibility with most shells.
130 Some people like (\"~\" \"#\" \"%\"). 143 Some people like (\"~\" \"#\" \"%\").
131 144
132 This is a fine thing to set in your `.emacs' file.") 145 This is a fine thing to set in your `.emacs' file."
146 :type '(repeat (string :tag "Suffix"))
147 :group 'shell)
133 148
134 ;jwz: turned this off; it's way too broken. 149 ;jwz: turned this off; it's way too broken.
135 (defvar shell-delimiter-argument-list nil ;'(?\| ?& ?< ?> ?\( ?\) ?\; 150 (defvar shell-delimiter-argument-list nil ;'(?\| ?& ?< ?> ?\( ?\) ?\;
136 "List of characters to recognise as separate arguments. 151 "List of characters to recognise as separate arguments.
137 This variable is used to initialize `comint-delimiter-argument-list' in the 152 This variable is used to initialize `comint-delimiter-argument-list' in the
158 This variable is used to initialise `comint-dynamic-complete-functions' in the 173 This variable is used to initialise `comint-dynamic-complete-functions' in the
159 shell buffer. 174 shell buffer.
160 175
161 This is a fine thing to set in your `.emacs' file.") 176 This is a fine thing to set in your `.emacs' file.")
162 177
163 (defvar shell-command-regexp "[^;&|\n]+" 178 (defcustom shell-command-regexp "[^;&|\n]+"
164 "*Regexp to match a single command within a pipeline. 179 "*Regexp to match a single command within a pipeline.
165 This is used for directory tracking and does not do a perfect job.") 180 This is used for directory tracking and does not do a perfect job."
166 181 :type 'regexp
167 (defvar shell-completion-execonly t 182 :group 'shell)
183
184 (defcustom shell-completion-execonly t
168 "*If non-nil, use executable files only for completion candidates. 185 "*If non-nil, use executable files only for completion candidates.
169 This mirrors the optional behavior of tcsh. 186 This mirrors the optional behavior of tcsh.
170 187
171 Detecting executability of files may slow command completion considerably.") 188 Detecting executability of files may slow command completion considerably."
172 189 :type 'boolean
173 (defvar shell-multiple-shells nil 190 :group 'shell)
174 "*If non-nil, each time shell mode is invoked, a new shell is made") 191
175 192 (defcustom shell-multiple-shells nil
176 (defvar shell-popd-regexp "popd" 193 "*If non-nil, each time shell mode is invoked, a new shell is made"
177 "*Regexp to match subshell commands equivalent to popd.") 194 :type 'boolean
178 195 :group 'shell)
179 (defvar shell-pushd-regexp "pushd" 196
180 "*Regexp to match subshell commands equivalent to pushd.") 197 (defcustom shell-popd-regexp "popd"
181 198 "*Regexp to match subshell commands equivalent to popd."
182 (defvar shell-pushd-tohome nil 199 :type 'regexp
200 :group 'shell-directories)
201
202 (defcustom shell-pushd-regexp "pushd"
203 "*Regexp to match subshell commands equivalent to pushd."
204 :type 'regexp
205 :group 'shell-directories)
206
207 (defcustom shell-pushd-tohome nil
183 "*If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd). 208 "*If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd).
184 This mirrors the optional behavior of tcsh.") 209 This mirrors the optional behavior of tcsh."
185 210 :type 'boolean
186 (defvar shell-pushd-dextract nil 211 :group 'shell-directories)
212
213 (defcustom shell-pushd-dextract nil
187 "*If non-nil, make \"pushd +n\" pop the nth dir to the stack top. 214 "*If non-nil, make \"pushd +n\" pop the nth dir to the stack top.
188 This mirrors the optional behavior of tcsh.") 215 This mirrors the optional behavior of tcsh."
189 216 :type 'boolean
190 (defvar shell-pushd-dunique nil 217 :group 'shell-directories)
218
219 (defcustom shell-pushd-dunique nil
191 "*If non-nil, make pushd only add unique directories to the stack. 220 "*If non-nil, make pushd only add unique directories to the stack.
192 This mirrors the optional behavior of tcsh.") 221 This mirrors the optional behavior of tcsh."
193 222 :type 'boolean
194 (defvar shell-cd-regexp "cd" 223 :group 'shell-directories)
195 "*Regexp to match subshell commands equivalent to cd.") 224
196 225 (defcustom shell-cd-regexp "cd"
197 (defvar explicit-shell-file-name nil 226 "*Regexp to match subshell commands equivalent to cd."
198 "*If non-nil, is file name to use for explicitly requested inferior shell.") 227 :type 'regexp
199 228 :group 'shell-directories)
200 (defvar explicit-csh-args 229
230 (defcustom explicit-shell-file-name nil
231 "*If non-nil, is file name to use for explicitly requested inferior shell."
232 :type '(choice (const :tag "None" nil) file)
233 :group 'shell)
234
235 (defcustom explicit-csh-args
201 (if (eq system-type 'hpux) 236 (if (eq system-type 'hpux)
202 ;; -T persuades HP's csh not to think it is smarter 237 ;; -T persuades HP's csh not to think it is smarter
203 ;; than us about what terminal modes to use. 238 ;; than us about what terminal modes to use.
204 '("-i" "-T") 239 '("-i" "-T")
205 '("-i")) 240 '("-i"))
206 "*Args passed to inferior shell by M-x shell, if the shell is csh. 241 "*Args passed to inferior shell by M-x shell, if the shell is csh.
207 Value is a list of strings, which may be nil.") 242 Value is a list of strings, which may be nil."
208 243 :type '(repeat (string :tag "Argument"))
209 (defvar shell-input-autoexpand 'history 244 :group 'shell)
245
246 (defcustom shell-input-autoexpand 'history
210 "*If non-nil, expand input command history references on completion. 247 "*If non-nil, expand input command history references on completion.
211 This mirrors the optional behavior of tcsh (its autoexpand and histlit). 248 This mirrors the optional behavior of tcsh (its autoexpand and histlit).
212 249
213 If the value is `input', then the expansion is seen on input. 250 If the value is `input', then the expansion is seen on input.
214 If the value is `history', then the expansion is only when inserting 251 If the value is `history', then the expansion is only when inserting
215 into the buffer's input ring. See also `comint-magic-space' and 252 into the buffer's input ring. See also `comint-magic-space' and
216 `comint-dynamic-complete'. 253 `comint-dynamic-complete'.
217 254
218 This variable supplies a default for `comint-input-autoexpand', 255 This variable supplies a default for `comint-input-autoexpand',
219 for Shell mode only.") 256 for Shell mode only."
257 :type '(choice (const nil) (const input) (const history))
258 :type 'shell)
220 259
221 (defvar shell-dirstack nil 260 (defvar shell-dirstack nil
222 "List of directories saved by pushd in this buffer's shell. 261 "List of directories saved by pushd in this buffer's shell.
223 Thus, this does not include the shell's current directory.") 262 Thus, this does not include the shell's current directory.")
224 263
245 ;; don't like this binding. Another possibility is C-c C-s 284 ;; don't like this binding. Another possibility is C-c C-s
246 ;; but that's way awkward. 285 ;; but that's way awkward.
247 (define-key map "\M-\C-m" 'shell-resync-dirs) 286 (define-key map "\M-\C-m" 'shell-resync-dirs)
248 (setq shell-mode-map map))) 287 (setq shell-mode-map map)))
249 288
250 (defvar shell-mode-hook nil 289 (defcustom shell-mode-hook nil
251 "*Hook for customising Shell mode.") 290 "*Hook for customising Shell mode."
291 :type 'hook
292 :group 'shell)
252 293
253 294
254 ;; font-locking 295 ;; font-locking
255 (defvar shell-prompt-face 'shell-prompt-face 296 (defcustom shell-prompt-face 'shell-prompt-face
256 "Face for shell prompts.") 297 "Face for shell prompts."
257 (defvar shell-option-face 'shell-option-face 298 :type 'face
258 "Face for command line options.") 299 :group 'shell-faces)
259 (defvar shell-output-face 'shell-output-face 300 (defcustom shell-option-face 'shell-option-face
260 "Face for generic shell output.") 301 "Face for command line options."
261 (defvar shell-output-2-face 'shell-output-2-face 302 :type 'face
262 "Face for grep-like output.") 303 :group 'shell-faces)
263 (defvar shell-output-3-face 'shell-output-3-face 304 (defcustom shell-output-face 'shell-output-face
264 "Face for [N] output where N is a number.") 305 "Face for generic shell output."
306 :type 'face
307 :group 'shell-faces)
308 (defcustom shell-output-2-face 'shell-output-2-face
309 "Face for grep-like output."
310 :type 'face
311 :group 'shell-faces)
312 (defcustom shell-output-3-face 'shell-output-3-face
313 "Face for [N] output where N is a number."
314 :type 'face
315 :group 'shell-faces)
265 316
266 (make-face shell-prompt-face) 317 (make-face shell-prompt-face)
267 (make-face shell-option-face) 318 (make-face shell-option-face)
268 (make-face shell-output-face) 319 (make-face shell-output-face)
269 (make-face shell-output-2-face) 320 (make-face shell-output-2-face)