comparison lisp/modes/sh-script.el @ 189:489f57a838ef r20-3b21

Import from CVS: tag r20-3b21
author cvs
date Mon, 13 Aug 2007 09:57:07 +0200
parents 25f70ba0133c
children acd284d43ca1
comparison
equal deleted inserted replaced
188:e29a8e7498d9 189:489f57a838ef
48 ;; page 4: various other commands 48 ;; page 4: various other commands
49 49
50 (require 'executable) 50 (require 'executable)
51 51
52 (defgroup sh nil 52 (defgroup sh nil
53 "Shell programming utilities" 53 "Shell programming mode."
54 :group 'unix 54 :group 'unix
55 :group 'languages) 55 :group 'languages)
56
57 (defgroup sh-script nil
58 "Shell script mode"
59 :group 'sh
60 :prefix "sh-")
61 56
62 57
63 ;;; interpreter-mode-alist is not compatible between Emacs and XEmacs. 58 ;;; interpreter-mode-alist is not compatible between Emacs and XEmacs.
64 ;;; So fake it. 59 ;;; So fake it.
65 60
104 If it matches, mode MODE is selected.") 99 If it matches, mode MODE is selected.")
105 100
106 (defcustom sh-mode-hook nil 101 (defcustom sh-mode-hook nil
107 "*Hook run by `sh-mode'." 102 "*Hook run by `sh-mode'."
108 :type 'hook 103 :type 'hook
109 :group 'sh-script) 104 :group 'sh)
110 105
111 (defcustom sh-set-shell-hook nil 106 (defcustom sh-set-shell-hook nil
112 "*Hook run by `sh-set-shell'." 107 "*Hook run by `sh-set-shell'."
113 :type 'hook 108 :type 'hook
114 :group 'sh-script) 109 :group 'sh)
115 110
116 (defcustom sh-ancestor-alist 111 (defcustom sh-ancestor-alist
117 '((ash . sh) 112 '((ash . sh)
118 (bash . jsh) 113 (bash . jsh)
119 (dtksh . ksh) 114 (dtksh . ksh)
152 zsh Z Shell 147 zsh Z Shell
153 oash SCO OA (curses) Shell 148 oash SCO OA (curses) Shell
154 posix IEEE 1003.2 Shell Standard 149 posix IEEE 1003.2 Shell Standard
155 wsh ? Shell" 150 wsh ? Shell"
156 :type '(repeat (cons symbol symbol)) 151 :type '(repeat (cons symbol symbol))
157 :group 'sh-script) 152 :group 'sh)
158 153
159 154
160 (defcustom sh-alias-alist 155 (defcustom sh-alias-alist
161 ;; XEmacs: Linux is spelled `linux' 156 ;; XEmacs: Linux is spelled `linux'
162 (nconc (if (eq system-type 'linux) 157 (nconc (if (eq system-type 'linux)
167 (sh5 . sh))) 162 (sh5 . sh)))
168 "*Alist for transforming shell names to what they really are. 163 "*Alist for transforming shell names to what they really are.
169 Use this where the name of the executable doesn't correspond to the type of 164 Use this where the name of the executable doesn't correspond to the type of
170 shell it really is." 165 shell it really is."
171 :type '(repeat (cons symbol symbol)) 166 :type '(repeat (cons symbol symbol))
172 :group 'sh-script) 167 :group 'sh)
173 168
174 169
175 (defcustom sh-shell-file (or (getenv "SHELL") "/bin/sh") 170 (defcustom sh-shell-file (or (getenv "SHELL") "/bin/sh")
176 "*The executable file name for the shell being programmed." 171 "*The executable file name for the shell being programmed."
177 :type 'string 172 :type 'string
178 :group 'sh-script) 173 :group 'sh)
179 174
180 175
181 (defcustom sh-shell-arg 176 (defcustom sh-shell-arg
182 ;; bash does not need any options when run in a shell script, 177 ;; bash does not need any options when run in a shell script,
183 '((bash) 178 '((bash)
197 (choice (const :tag "No Arguments" nil) 192 (choice (const :tag "No Arguments" nil)
198 (string :tag "Arguments") 193 (string :tag "Arguments")
199 (cons :format "Evaluate: %v" 194 (cons :format "Evaluate: %v"
200 (const :format "" eval) 195 (const :format "" eval)
201 sexp)))) 196 sexp))))
202 :group 'sh-script) 197 :group 'sh)
203 198
204 (defvar sh-shell-variables nil 199 (defvar sh-shell-variables nil
205 "Alist of shell variable names that should be included in completion. 200 "Alist of shell variable names that should be included in completion.
206 These are used for completion in addition to all the variables named 201 These are used for completion in addition to all the variables named
207 in `process-environment'. Each element looks like (VAR . VAR), where 202 in `process-environment'. Each element looks like (VAR . VAR), where
348 '(shell-dynamic-complete-environment-variable 343 '(shell-dynamic-complete-environment-variable
349 shell-dynamic-complete-command 344 shell-dynamic-complete-command
350 comint-dynamic-complete-filename) 345 comint-dynamic-complete-filename)
351 "*Functions for doing TAB dynamic completion." 346 "*Functions for doing TAB dynamic completion."
352 :type '(repeat function) 347 :type '(repeat function)
353 :group 'sh-script) 348 :group 'sh)
354 349
355 350
356 (defcustom sh-require-final-newline 351 (defcustom sh-require-final-newline
357 '((csh . t) 352 '((csh . t)
358 (pdksh . t) 353 (pdksh . t)
363 :type '(repeat (cons (symbol :tag "Shell") 358 :type '(repeat (cons (symbol :tag "Shell")
364 (choice (const :tag "require" t) 359 (choice (const :tag "require" t)
365 (cons :format "Evaluate: %v" 360 (cons :format "Evaluate: %v"
366 (const :format "" eval) 361 (const :format "" eval)
367 sexp)))) 362 sexp))))
368 :group 'sh-script) 363 :group 'sh)
369 364
370 365
371 (defcustom sh-comment-prefix 366 (defcustom sh-comment-prefix
372 '((csh . "\\(^\\|[^$]\\|\\$[^{]\\)") 367 '((csh . "\\(^\\|[^$]\\|\\$[^{]\\)")
373 (rc eval identity csh) 368 (rc eval identity csh)
379 :type '(repeat (cons (symbol :tag "Shell") 374 :type '(repeat (cons (symbol :tag "Shell")
380 (choice regexp 375 (choice regexp
381 (cons :format "Evaluate: %v" 376 (cons :format "Evaluate: %v"
382 (const :format "" eval) 377 (const :format "" eval)
383 sexp)))) 378 sexp))))
384 :group 'sh-script) 379 :group 'sh)
385 380
386 381
387 (defcustom sh-assignment-regexp 382 (defcustom sh-assignment-regexp
388 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") 383 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=")
389 ;; actually spaces are only supported in let/(( ... )) 384 ;; actually spaces are only supported in let/(( ... ))
396 :type '(repeat (cons (symbol :tag "Shell") 391 :type '(repeat (cons (symbol :tag "Shell")
397 (choice regexp 392 (choice regexp
398 (cons :format "Evaluate: %v" 393 (cons :format "Evaluate: %v"
399 (const :format "" eval) 394 (const :format "" eval)
400 sexp)))) 395 sexp))))
401 :group 'sh-script) 396 :group 'sh)
402 397
403 398
404 (defcustom sh-indentation 4 399 (defcustom sh-indentation 4
405 "The width for further indentation in Shell-Script mode." 400 "The width for further indentation in Shell-Script mode."
406 :type 'integer 401 :type 'integer
407 :group 'sh-script) 402 :group 'sh)
408 403
409 404
410 (defcustom sh-remember-variable-min 3 405 (defcustom sh-remember-variable-min 3
411 "*Don't remember variables less than this length for completing reads." 406 "*Don't remember variables less than this length for completing reads."
412 :type 'integer 407 :type 'integer
413 :group 'sh-script) 408 :group 'sh)
414 409
415 410
416 (defvar sh-header-marker nil 411 (defvar sh-header-marker nil
417 "When non-`nil' is the end of header for prepending by \\[sh-execute-region]. 412 "When non-`nil' is the end of header for prepending by \\[sh-execute-region].
418 That command is also used for setting this variable.") 413 That command is also used for setting this variable.")
421 (defcustom sh-beginning-of-command 416 (defcustom sh-beginning-of-command
422 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)" 417 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)"
423 "*Regexp to determine the beginning of a shell command. 418 "*Regexp to determine the beginning of a shell command.
424 The actual command starts at the beginning of the second \\(grouping\\)." 419 The actual command starts at the beginning of the second \\(grouping\\)."
425 :type 'regexp 420 :type 'regexp
426 :group 'sh-script) 421 :group 'sh)
427 422
428 423
429 (defcustom sh-end-of-command 424 (defcustom sh-end-of-command
430 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)" 425 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)"
431 "*Regexp to determine the end of a shell command. 426 "*Regexp to determine the end of a shell command.
432 The actual command ends at the end of the first \\(grouping\\)." 427 The actual command ends at the end of the first \\(grouping\\)."
433 :type 'regexp 428 :type 'regexp
434 :group 'sh-script) 429 :group 'sh)
435 430
436 431
437 432
438 (defvar sh-here-document-word "EOF" 433 (defvar sh-here-document-word "EOF"
439 "Word to delimit here documents.") 434 "Word to delimit here documents.")
513 :type '(repeat (cons (symbol :tag "Shell") 508 :type '(repeat (cons (symbol :tag "Shell")
514 (choice (repeat string) 509 (choice (repeat string)
515 (cons :format "Evaluate: %v" 510 (cons :format "Evaluate: %v"
516 (const :format "" eval) 511 (const :format "" eval)
517 sexp)))) 512 sexp))))
518 :group 'sh-script) 513 :group 'sh)
519 514
520 515
521 516
522 (defcustom sh-leading-keywords 517 (defcustom sh-leading-keywords
523 '((csh "else") 518 '((csh "else")
534 :type '(repeat (cons (symbol :tag "Shell") 529 :type '(repeat (cons (symbol :tag "Shell")
535 (choice (repeat string) 530 (choice (repeat string)
536 (cons :format "Evaluate: %v" 531 (cons :format "Evaluate: %v"
537 (const :format "" eval) 532 (const :format "" eval)
538 sexp)))) 533 sexp))))
539 :group 'sh-script) 534 :group 'sh)
540 535
541 536
542 (defcustom sh-other-keywords 537 (defcustom sh-other-keywords
543 '((bash eval sh-append bourne 538 '((bash eval sh-append bourne
544 "bye" "logout") 539 "bye" "logout")
570 :type '(repeat (cons (symbol :tag "Shell") 565 :type '(repeat (cons (symbol :tag "Shell")
571 (choice (repeat string) 566 (choice (repeat string)
572 (cons :format "Evaluate: %v" 567 (cons :format "Evaluate: %v"
573 (const :format "" eval) 568 (const :format "" eval)
574 sexp)))) 569 sexp))))
575 :group 'sh-script) 570 :group 'sh)
576 571
577 572
578 573
579 (defvar sh-variables 574 (defvar sh-variables
580 '((bash eval sh-append sh 575 '((bash eval sh-append sh
1531 "Move point to successive ends of commands." 1526 "Move point to successive ends of commands."
1532 (interactive) 1527 (interactive)
1533 (if (re-search-forward sh-end-of-command nil t) 1528 (if (re-search-forward sh-end-of-command nil t)
1534 (goto-char (match-end 1)))) 1529 (goto-char (match-end 1))))
1535 1530
1536 (provide 'sh-script) 1531 (provide 'sh)
1537 ;; sh-script.el ends here 1532 ;; sh-script.el ends here
1538 1533