Mercurial > emacs
comparison lisp/progmodes/sh-script.el @ 17407:ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 12 Apr 1997 02:51:38 +0000 |
parents | 9f345ed0683e |
children | c4258189ad2c |
comparison
equal
deleted
inserted
replaced
17406:672954f25d25 | 17407:ae0ba78d6c07 |
---|---|
1 ;;; sh-script.el --- shell-script editing commands for Emacs | 1 ;;; sh-script.el --- shell-script editing commands for Emacs |
2 | 2 |
3 ;; Copyright (C) 1993, 1994, 1995, 1996 by Free Software Foundation, Inc. | 3 ;; Copyright (C) 1993, 94, 95, 96, 1997 by Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 | 5 ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 |
6 ;; Version: 2.0e | 6 ;; Version: 2.0e |
7 ;; Maintainer: FSF | 7 ;; Maintainer: FSF |
8 ;; Keywords: languages, unix | 8 ;; Keywords: languages, unix |
51 "*Hook run by `sh-mode'.") | 51 "*Hook run by `sh-mode'.") |
52 | 52 |
53 (defvar sh-set-shell-hook nil | 53 (defvar sh-set-shell-hook nil |
54 "*Hook run by `sh-set-shell'.") | 54 "*Hook run by `sh-set-shell'.") |
55 | 55 |
56 (defvar sh-ancestor-alist | 56 (defgroup sh nil |
57 "Shell programming utilities" | |
58 :group 'unix | |
59 :group 'languages) | |
60 | |
61 (defgroup sh-script nil | |
62 "Shell script mode" | |
63 :group 'sh | |
64 :prefix "sh-") | |
65 | |
66 | |
67 (defcustom sh-ancestor-alist | |
57 '((ash . sh) | 68 '((ash . sh) |
58 (bash . jsh) | 69 (bash . jsh) |
59 (dtksh . ksh) | 70 (dtksh . ksh) |
60 (es . rc) | 71 (es . rc) |
61 (itcsh . tcsh) | 72 (itcsh . tcsh) |
90 pdksh Public Domain Korn Shell | 101 pdksh Public Domain Korn Shell |
91 wksh Window Korn Shell | 102 wksh Window Korn Shell |
92 zsh Z Shell | 103 zsh Z Shell |
93 oash SCO OA (curses) Shell | 104 oash SCO OA (curses) Shell |
94 posix IEEE 1003.2 Shell Standard | 105 posix IEEE 1003.2 Shell Standard |
95 wsh ? Shell") | 106 wsh ? Shell" |
96 | 107 :type '(repeat (cons symbol symbol)) |
97 | 108 :group 'sh-script) |
98 (defvar sh-alias-alist | 109 |
110 | |
111 (defcustom sh-alias-alist | |
99 (nconc (if (eq system-type 'gnu/linux) | 112 (nconc (if (eq system-type 'gnu/linux) |
100 '((csh . tcsh) | 113 '((csh . tcsh) |
101 (ksh . pdksh))) | 114 (ksh . pdksh))) |
102 ;; for the time being | 115 ;; for the time being |
103 '((ksh . ksh88) | 116 '((ksh . ksh88) |
104 (sh5 . sh))) | 117 (sh5 . sh))) |
105 "*Alist for transforming shell names to what they really are. | 118 "*Alist for transforming shell names to what they really are. |
106 Use this where the name of the executable doesn't correspond to the type of | 119 Use this where the name of the executable doesn't correspond to the type of |
107 shell it really is.") | 120 shell it really is." |
108 | 121 :type '(repeat (cons symbol symbol)) |
109 | 122 :group 'sh-script) |
110 (defvar sh-shell-file | 123 |
124 | |
125 (defcustom sh-shell-file | |
111 (or | 126 (or |
112 ;; On MSDOS and Windows, collapse $SHELL to lower-case and remove | 127 ;; On MSDOS and Windows, collapse $SHELL to lower-case and remove |
113 ;; the executable extension, so comparisons with the list of | 128 ;; the executable extension, so comparisons with the list of |
114 ;; known shells work. | 129 ;; known shells work. |
115 (and (memq system-type '(ms-dos windows-nt)) | 130 (and (memq system-type '(ms-dos windows-nt)) |
116 (file-name-sans-extension (downcase (getenv "SHELL")))) | 131 (file-name-sans-extension (downcase (getenv "SHELL")))) |
117 (getenv "SHELL") | 132 (getenv "SHELL") |
118 "/bin/sh") | 133 "/bin/sh") |
119 "*The executable file name for the shell being programmed.") | 134 "*The executable file name for the shell being programmed." |
120 | 135 :type 'string |
121 | 136 :group 'sh-script) |
122 (defvar sh-shell-arg | 137 |
138 | |
139 (defcustom sh-shell-arg | |
123 ;; bash does not need any options when run in a shell script, | 140 ;; bash does not need any options when run in a shell script, |
124 '((bash) | 141 '((bash) |
125 (csh . "-f") | 142 (csh . "-f") |
126 (pdksh) | 143 (pdksh) |
127 ;; Bill_Mann@praxisint.com says -p with ksh can do harm. | 144 ;; Bill_Mann@praxisint.com says -p with ksh can do harm. |
131 ;; Someone proposed -motif, but we don't want to encourage | 148 ;; Someone proposed -motif, but we don't want to encourage |
132 ;; use of a non-free widget set. | 149 ;; use of a non-free widget set. |
133 (wksh) | 150 (wksh) |
134 ;; -f means don't run .zshrc. | 151 ;; -f means don't run .zshrc. |
135 (zsh . "-f")) | 152 (zsh . "-f")) |
136 "*Single argument string for the magic number. See `sh-feature'.") | 153 "*Single argument string for the magic number. See `sh-feature'." |
154 :type '(repeat (cons (symbol :tag "Shell") | |
155 (choice (const :tag "No Arguments" nil) | |
156 (string :tag "Arguments") | |
157 (cons :format "Evaluate: %v" | |
158 (const :format "" eval) | |
159 sexp)))) | |
160 :group 'sh-script) | |
137 | 161 |
138 (defvar sh-shell-variables nil | 162 (defvar sh-shell-variables nil |
139 "Alist of shell variable names that should be included in completion. | 163 "Alist of shell variable names that should be included in completion. |
140 These are used for completion in addition to all the variables named | 164 These are used for completion in addition to all the variables named |
141 in `process-environment'. Each element looks like (VAR . VAR), where | 165 in `process-environment'. Each element looks like (VAR . VAR), where |
272 map) | 296 map) |
273 "Keymap used in Shell-Script mode.") | 297 "Keymap used in Shell-Script mode.") |
274 | 298 |
275 | 299 |
276 | 300 |
277 (defvar sh-dynamic-complete-functions | 301 (defcustom sh-dynamic-complete-functions |
278 '(shell-dynamic-complete-environment-variable | 302 '(shell-dynamic-complete-environment-variable |
279 shell-dynamic-complete-command | 303 shell-dynamic-complete-command |
280 comint-dynamic-complete-filename) | 304 comint-dynamic-complete-filename) |
281 "*Functions for doing TAB dynamic completion.") | 305 "*Functions for doing TAB dynamic completion." |
282 | 306 :type '(repeat function) |
283 | 307 :group 'sh-script) |
284 (defvar sh-require-final-newline | 308 |
309 | |
310 (defcustom sh-require-final-newline | |
285 '((csh . t) | 311 '((csh . t) |
286 (pdksh . t) | 312 (pdksh . t) |
287 (rc eval . require-final-newline) | 313 (rc eval . require-final-newline) |
288 (sh eval . require-final-newline)) | 314 (sh eval . require-final-newline)) |
289 "*Value of `require-final-newline' in Shell-Script mode buffers. | 315 "*Value of `require-final-newline' in Shell-Script mode buffers. |
290 See `sh-feature'.") | 316 See `sh-feature'." |
291 | 317 :type '(repeat (cons (symbol :tag "Shell") |
292 | 318 (choice (const :tag "require" t) |
293 (defvar sh-assignment-regexp | 319 (cons :format "Evaluate: %v" |
320 (const :format "" eval) | |
321 sexp)))) | |
322 :group 'sh-script) | |
323 | |
324 | |
325 (defcustom sh-assignment-prefix | |
294 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") | 326 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") |
295 ;; actually spaces are only supported in let/(( ... )) | 327 ;; actually spaces are only supported in let/(( ... )) |
296 (ksh88 . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*\\([-+*/%&|~^]\\|<<\\|>>\\)?=") | 328 (ksh88 . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*\\([-+*/%&|~^]\\|<<\\|>>\\)?=") |
297 (rc . "\\<\\([a-zA-Z0-9_*]+\\)[ \t]*=") | 329 (rc . "\\<\\([a-zA-Z0-9_*]+\\)[ \t]*=") |
298 (sh . "\\<\\([a-zA-Z0-9_]+\\)=")) | 330 (sh . "\\<\\([a-zA-Z0-9_]+\\)=")) |
299 "*Regexp for the variable name and what may follow in an assignment. | 331 "*Regexp for the variable name and what may follow in an assignment. |
300 First grouping matches the variable name. This is upto and including the `=' | 332 First grouping matches the variable name. This is upto and including the `=' |
301 sign. See `sh-feature'.") | 333 sign. See `sh-feature'." |
302 | 334 :type '(repeat (cons (symbol :tag "Shell") |
303 | 335 (choice regexp |
304 (defvar sh-indentation 4 | 336 (cons :format "Evaluate: %v" |
305 "The width for further indentation in Shell-Script mode.") | 337 (const :format "" eval) |
306 | 338 sexp)))) |
307 | 339 :group 'sh-script) |
308 (defvar sh-remember-variable-min 3 | 340 |
309 "*Don't remember variables less than this length for completing reads.") | 341 |
342 (defcustom sh-indentation 4 | |
343 "The width for further indentation in Shell-Script mode." | |
344 :type 'integer | |
345 :group 'sh-script) | |
346 | |
347 | |
348 (defcustom sh-remember-variable-min 3 | |
349 "*Don't remember variables less than this length for completing reads." | |
350 :type 'integer | |
351 :group 'sh-script) | |
310 | 352 |
311 | 353 |
312 (defvar sh-header-marker nil | 354 (defvar sh-header-marker nil |
313 "When non-`nil' is the end of header for prepending by \\[sh-execute-region]. | 355 "When non-`nil' is the end of header for prepending by \\[sh-execute-region]. |
314 That command is also used for setting this variable.") | 356 That command is also used for setting this variable.") |
315 | 357 |
316 | 358 |
317 (defvar sh-beginning-of-command | 359 (defcustom sh-beginning-of-command |
318 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)" | 360 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)" |
319 "*Regexp to determine the beginning of a shell command. | 361 "*Regexp to determine the beginning of a shell command. |
320 The actual command starts at the beginning of the second \\(grouping\\).") | 362 The actual command starts at the beginning of the second \\(grouping\\)." |
321 | 363 :type 'regexp |
322 | 364 :group 'sh-script) |
323 (defvar sh-end-of-command | 365 |
366 | |
367 (defcustom sh-end-of-command | |
324 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)" | 368 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)" |
325 "*Regexp to determine the end of a shell command. | 369 "*Regexp to determine the end of a shell command. |
326 The actual command ends at the end of the first \\(grouping\\).") | 370 The actual command ends at the end of the first \\(grouping\\)." |
371 :type 'regexp | |
372 :group 'sh-script) | |
327 | 373 |
328 | 374 |
329 | 375 |
330 (defvar sh-here-document-word "EOF" | 376 (defvar sh-here-document-word "EOF" |
331 "Word to delimit here documents.") | 377 "Word to delimit here documents.") |
334 '((sh "[ ]" . 3) | 380 '((sh "[ ]" . 3) |
335 (ksh88 "[[ ]]" . 4)) | 381 (ksh88 "[[ ]]" . 4)) |
336 "Initial input in Bourne if, while and until skeletons. See `sh-feature'.") | 382 "Initial input in Bourne if, while and until skeletons. See `sh-feature'.") |
337 | 383 |
338 | 384 |
339 (defvar sh-builtins | 385 ;; customized this out of sheer bravado. not for the faint of heart. |
386 ;; but it *did* have an asterisk in the docstring! | |
387 (defcustom sh-builtins | |
340 '((bash eval sh-append posix | 388 '((bash eval sh-append posix |
341 "alias" "bg" "bind" "builtin" "declare" "dirs" "enable" "fc" "fg" | 389 "alias" "bg" "bind" "builtin" "declare" "dirs" "enable" "fc" "fg" |
342 "help" "history" "jobs" "kill" "let" "local" "popd" "pushd" "source" | 390 "help" "history" "jobs" "kill" "let" "local" "popd" "pushd" "source" |
343 "suspend" "typeset" "unalias") | 391 "suspend" "typeset" "unalias") |
344 | 392 |
397 "readonly" "rehash" "sched" "setopt" "source" "suspend" "true" | 445 "readonly" "rehash" "sched" "setopt" "source" "suspend" "true" |
398 "ttyctl" "type" "unfunction" "unhash" "unlimit" "unsetopt" "vared" | 446 "ttyctl" "type" "unfunction" "unhash" "unlimit" "unsetopt" "vared" |
399 "which")) | 447 "which")) |
400 "*List of all shell builtins for completing read and fontification. | 448 "*List of all shell builtins for completing read and fontification. |
401 Note that on some systems not all builtins are available or some are | 449 Note that on some systems not all builtins are available or some are |
402 implemented as aliases. See `sh-feature'.") | 450 implemented as aliases. See `sh-feature'." |
403 | 451 :type '(repeat (cons (symbol :tag "Shell") |
404 | 452 (choice (repeat string) |
405 | 453 (cons :format "Evaluate: %v" |
406 (defvar sh-leading-keywords | 454 (const :format "" eval) |
455 sexp)))) | |
456 :group 'sh-script) | |
457 | |
458 | |
459 | |
460 (defcustom sh-leading-keywords | |
407 '((csh "else") | 461 '((csh "else") |
408 | 462 |
409 (es "true" "unwind-protect" "whatis") | 463 (es "true" "unwind-protect" "whatis") |
410 | 464 |
411 (rc "else") | 465 (rc "else") |
412 | 466 |
413 (sh "do" "elif" "else" "if" "then" "trap" "type" "until" "while")) | 467 (sh "do" "elif" "else" "if" "then" "trap" "type" "until" "while")) |
414 "*List of keywords that may be immediately followed by a builtin or keyword. | 468 "*List of keywords that may be immediately followed by a builtin or keyword. |
415 Given some confusion between keywords and builtins depending on shell and | 469 Given some confusion between keywords and builtins depending on shell and |
416 system, the distinction here has been based on whether they influence the | 470 system, the distinction here has been based on whether they influence the |
417 flow of control or syntax. See `sh-feature'.") | 471 flow of control or syntax. See `sh-feature'." |
418 | 472 :type '(repeat (cons (symbol :tag "Shell") |
419 | 473 (choice (repeat string) |
420 (defvar sh-other-keywords | 474 (cons :format "Evaluate: %v" |
475 (const :format "" eval) | |
476 sexp)))) | |
477 :group 'sh-script) | |
478 | |
479 | |
480 (defcustom sh-other-keywords | |
421 '((bash eval sh-append bourne | 481 '((bash eval sh-append bourne |
422 "bye" "logout") | 482 "bye" "logout") |
423 | 483 |
424 ;; The next entry is only used for defining the others | 484 ;; The next entry is only used for defining the others |
425 (bourne eval sh-append sh | 485 (bourne eval sh-append sh |
445 (shell "break" "case" "continue" "exec" "exit") | 505 (shell "break" "case" "continue" "exec" "exit") |
446 | 506 |
447 (zsh eval sh-append bash | 507 (zsh eval sh-append bash |
448 "select")) | 508 "select")) |
449 "*List of keywords not in `sh-leading-keywords'. | 509 "*List of keywords not in `sh-leading-keywords'. |
450 See `sh-feature'.") | 510 See `sh-feature'." |
511 :type '(repeat (cons (symbol :tag "Shell") | |
512 (choice (repeat string) | |
513 (cons :format "Evaluate: %v" | |
514 (const :format "" eval) | |
515 sexp)))) | |
516 :group 'sh-script) | |
451 | 517 |
452 | 518 |
453 | 519 |
454 (defvar sh-variables | 520 (defvar sh-variables |
455 '((bash eval sh-append sh | 521 '((bash eval sh-append sh |