aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-06-13 18:25:46 +0000
committerStefan Monnier2007-06-13 18:25:46 +0000
commit4f3a33689b8fdb0d9535aa7d1a021f48c56844da (patch)
treee12e7d24bc68ec6e99207442fb0a22427fd9a286
parentb4c4ba4182036650b9f8293ee9b5175714bb532b (diff)
downloademacs-4f3a33689b8fdb0d9535aa7d1a021f48c56844da.tar.gz
emacs-4f3a33689b8fdb0d9535aa7d1a021f48c56844da.zip
Remove unneeded * from docstrings. Use [:alpha:] & [:alnum:] where applicable.
(sh-quoted-subshell): Rewrite to handle nested mixes of `...` and $(...). (sh-apply-quoted-subshell): Remove. (sh-font-lock-syntactic-keywords): Adjust call to sh-quoted-subshell.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/sh-script.el198
2 files changed, 97 insertions, 108 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9a8da25da01..69b07753cea 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12007-06-13 Stefan Monnier <monnier@iro.umontreal.ca> 12007-06-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/sh-script.el: Remove unneeded * from docstrings.
4 Use [:alpha:] and [:alnum:] where applicable.
5 (sh-quoted-subshell): Rewrite to correctly
6 handle nested mixes of `...` and $(...).
7 (sh-apply-quoted-subshell): Remove.
8 (sh-font-lock-syntactic-keywords): Adjust call to sh-quoted-subshell.
9
3 * vc-arch.el (vc-arch-command): Remove bzr. It's a different program. 10 * vc-arch.el (vc-arch-command): Remove bzr. It's a different program.
4 11
52007-06-12 Tom Tromey <tromey@redhat.com> 122007-06-12 Tom Tromey <tromey@redhat.com>
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 56b16eb3638..b29cf7fb141 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -235,7 +235,7 @@
235 (wsh . sh) 235 (wsh . sh)
236 (zsh . ksh88) 236 (zsh . ksh88)
237 (rpm . sh)) 237 (rpm . sh))
238 "*Alist showing the direct ancestor of various shells. 238 "Alist showing the direct ancestor of various shells.
239This is the basis for `sh-feature'. See also `sh-alias-alist'. 239This is the basis for `sh-feature'. See also `sh-alias-alist'.
240By default we have the following three hierarchies: 240By default we have the following three hierarchies:
241 241
@@ -270,7 +270,7 @@ sh Bourne Shell
270 '((ksh . ksh88) 270 '((ksh . ksh88)
271 (bash2 . bash) 271 (bash2 . bash)
272 (sh5 . sh))) 272 (sh5 . sh)))
273 "*Alist for transforming shell names to what they really are. 273 "Alist for transforming shell names to what they really are.
274Use this where the name of the executable doesn't correspond to the type of 274Use this where the name of the executable doesn't correspond to the type of
275shell it really is." 275shell it really is."
276 :type '(repeat (cons symbol symbol)) 276 :type '(repeat (cons symbol symbol))
@@ -296,7 +296,7 @@ shell it really is."
296 (file-name-sans-extension (downcase shell))))) 296 (file-name-sans-extension (downcase shell)))))
297 (getenv "SHELL") 297 (getenv "SHELL")
298 "/bin/sh") 298 "/bin/sh")
299 "*The executable file name for the shell being programmed." 299 "The executable file name for the shell being programmed."
300 :type 'string 300 :type 'string
301 :group 'sh-script) 301 :group 'sh-script)
302 302
@@ -315,7 +315,7 @@ shell it really is."
315 (wksh) 315 (wksh)
316 ;; -f means don't run .zshrc. 316 ;; -f means don't run .zshrc.
317 (zsh . "-f")) 317 (zsh . "-f"))
318 "*Single argument string for the magic number. See `sh-feature'." 318 "Single argument string for the magic number. See `sh-feature'."
319 :type '(repeat (cons (symbol :tag "Shell") 319 :type '(repeat (cons (symbol :tag "Shell")
320 (choice (const :tag "No Arguments" nil) 320 (choice (const :tag "No Arguments" nil)
321 (string :tag "Arguments") 321 (string :tag "Arguments")
@@ -324,8 +324,8 @@ shell it really is."
324 324
325(defcustom sh-imenu-generic-expression 325(defcustom sh-imenu-generic-expression
326 `((sh 326 `((sh
327 . ((nil "^\\s-*\\(function\\s-+\\)?\\([A-Za-z_][A-Za-z_0-9]+\\)\\s-*()" 2)))) 327 . ((nil "^\\s-*\\(function\\s-+\\)?\\([[:alpha:]_][[:alnum:]_]+\\)\\s-*()" 2))))
328 "*Alist of regular expressions for recognizing shell function definitions. 328 "Alist of regular expressions for recognizing shell function definitions.
329See `sh-feature' and `imenu-generic-expression'." 329See `sh-feature' and `imenu-generic-expression'."
330 :type '(alist :key-type (symbol :tag "Shell") 330 :type '(alist :key-type (symbol :tag "Shell")
331 :value-type (alist :key-type (choice :tag "Title" 331 :value-type (alist :key-type (choice :tag "Title"
@@ -501,7 +501,7 @@ This is buffer-local in every such buffer.")
501 '(shell-dynamic-complete-environment-variable 501 '(shell-dynamic-complete-environment-variable
502 shell-dynamic-complete-command 502 shell-dynamic-complete-command
503 comint-dynamic-complete-filename) 503 comint-dynamic-complete-filename)
504 "*Functions for doing TAB dynamic completion." 504 "Functions for doing TAB dynamic completion."
505 :type '(repeat function) 505 :type '(repeat function)
506 :group 'sh-script) 506 :group 'sh-script)
507 507
@@ -509,7 +509,7 @@ This is buffer-local in every such buffer.")
509(defcustom sh-require-final-newline 509(defcustom sh-require-final-newline
510 '((csh . t) 510 '((csh . t)
511 (pdksh . t)) 511 (pdksh . t))
512 "*Value of `require-final-newline' in Shell-Script mode buffers. 512 "Value of `require-final-newline' in Shell-Script mode buffers.
513\(SHELL . t) means use the value of `mode-require-final-newline' for SHELL. 513\(SHELL . t) means use the value of `mode-require-final-newline' for SHELL.
514See `sh-feature'." 514See `sh-feature'."
515 :type '(repeat (cons (symbol :tag "Shell") 515 :type '(repeat (cons (symbol :tag "Shell")
@@ -519,12 +519,12 @@ See `sh-feature'."
519 519
520 520
521(defcustom sh-assignment-regexp 521(defcustom sh-assignment-regexp
522 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") 522 '((csh . "\\<\\([[:alnum:]_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=")
523 ;; actually spaces are only supported in let/(( ... )) 523 ;; actually spaces are only supported in let/(( ... ))
524 (ksh88 . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*\\([-+*/%&|~^]\\|<<\\|>>\\)?=") 524 (ksh88 . "\\<\\([[:alnum:]_]+\\)\\(\\[.+\\]\\)?[ \t]*\\([-+*/%&|~^]\\|<<\\|>>\\)?=")
525 (rc . "\\<\\([a-zA-Z0-9_*]+\\)[ \t]*=") 525 (rc . "\\<\\([[:alnum:]_*]+\\)[ \t]*=")
526 (sh . "\\<\\([a-zA-Z0-9_]+\\)=")) 526 (sh . "\\<\\([[:alnum:]_]+\\)="))
527 "*Regexp for the variable name and what may follow in an assignment. 527 "Regexp for the variable name and what may follow in an assignment.
528First grouping matches the variable name. This is upto and including the `=' 528First grouping matches the variable name. This is upto and including the `='
529sign. See `sh-feature'." 529sign. See `sh-feature'."
530 :type '(repeat (cons (symbol :tag "Shell") 530 :type '(repeat (cons (symbol :tag "Shell")
@@ -540,7 +540,7 @@ sign. See `sh-feature'."
540 540
541 541
542(defcustom sh-remember-variable-min 3 542(defcustom sh-remember-variable-min 3
543 "*Don't remember variables less than this length for completing reads." 543 "Don't remember variables less than this length for completing reads."
544 :type 'integer 544 :type 'integer
545 :group 'sh-script) 545 :group 'sh-script)
546 546
@@ -551,16 +551,16 @@ That command is also used for setting this variable.")
551 551
552 552
553(defcustom sh-beginning-of-command 553(defcustom sh-beginning-of-command
554 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)" 554 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~[:alnum:]:]\\)"
555 "*Regexp to determine the beginning of a shell command. 555 "Regexp to determine the beginning of a shell command.
556The actual command starts at the beginning of the second \\(grouping\\)." 556The actual command starts at the beginning of the second \\(grouping\\)."
557 :type 'regexp 557 :type 'regexp
558 :group 'sh-script) 558 :group 'sh-script)
559 559
560 560
561(defcustom sh-end-of-command 561(defcustom sh-end-of-command
562 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)" 562 "\\([/~[:alnum:]:]\\)[ \t]*\\([;#)}`|&]\\|$\\)"
563 "*Regexp to determine the end of a shell command. 563 "Regexp to determine the end of a shell command.
564The actual command ends at the end of the first \\(grouping\\)." 564The actual command ends at the end of the first \\(grouping\\)."
565 :type 'regexp 565 :type 'regexp
566 :group 'sh-script) 566 :group 'sh-script)
@@ -647,6 +647,7 @@ removed when closing the here document."
647 (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait") 647 (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait")
648 648
649 (wksh sh-append ksh88 649 (wksh sh-append ksh88
650 ;; FIXME: This looks too much like a regexp. --Stef
650 "Xt[A-Z][A-Za-z]*") 651 "Xt[A-Z][A-Za-z]*")
651 652
652 (zsh sh-append ksh88 653 (zsh sh-append ksh88
@@ -656,7 +657,7 @@ removed when closing the here document."
656 "readonly" "rehash" "sched" "setopt" "source" "suspend" "true" 657 "readonly" "rehash" "sched" "setopt" "source" "suspend" "true"
657 "ttyctl" "type" "unfunction" "unhash" "unlimit" "unsetopt" "vared" 658 "ttyctl" "type" "unfunction" "unhash" "unlimit" "unsetopt" "vared"
658 "which")) 659 "which"))
659 "*List of all shell builtins for completing read and fontification. 660 "List of all shell builtins for completing read and fontification.
660Note that on some systems not all builtins are available or some are 661Note that on some systems not all builtins are available or some are
661implemented as aliases. See `sh-feature'." 662implemented as aliases. See `sh-feature'."
662 :type '(repeat (cons (symbol :tag "Shell") 663 :type '(repeat (cons (symbol :tag "Shell")
@@ -677,7 +678,7 @@ implemented as aliases. See `sh-feature'."
677 (rc "else") 678 (rc "else")
678 679
679 (sh "!" "do" "elif" "else" "if" "then" "trap" "type" "until" "while")) 680 (sh "!" "do" "elif" "else" "if" "then" "trap" "type" "until" "while"))
680 "*List of keywords that may be immediately followed by a builtin or keyword. 681 "List of keywords that may be immediately followed by a builtin or keyword.
681Given some confusion between keywords and builtins depending on shell and 682Given some confusion between keywords and builtins depending on shell and
682system, the distinction here has been based on whether they influence the 683system, the distinction here has been based on whether they influence the
683flow of control or syntax. See `sh-feature'." 684flow of control or syntax. See `sh-feature'."
@@ -716,7 +717,7 @@ flow of control or syntax. See `sh-feature'."
716 717
717 (zsh sh-append bash 718 (zsh sh-append bash
718 "select")) 719 "select"))
719 "*List of keywords not in `sh-leading-keywords'. 720 "List of keywords not in `sh-leading-keywords'.
720See `sh-feature'." 721See `sh-feature'."
721 :type '(repeat (cons (symbol :tag "Shell") 722 :type '(repeat (cons (symbol :tag "Shell")
722 (choice (repeat string) 723 (choice (repeat string)
@@ -837,18 +838,18 @@ See `sh-feature'.")
837 838
838(defvar sh-font-lock-keywords-var 839(defvar sh-font-lock-keywords-var
839 '((csh sh-append shell 840 '((csh sh-append shell
840 ("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1 841 ("\\${?[#?]?\\([[:alpha:]_][[:alnum:]_]*\\|0\\)" 1
841 font-lock-variable-name-face)) 842 font-lock-variable-name-face))
842 843
843 (es sh-append executable-font-lock-keywords 844 (es sh-append executable-font-lock-keywords
844 ("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1 845 ("\\$#?\\([[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\)" 1
845 font-lock-variable-name-face)) 846 font-lock-variable-name-face))
846 847
847 (rc sh-append es) 848 (rc sh-append es)
848 (bash sh-append shell ("\\$(\\(\\sw+\\)" (1 'sh-quoted-exec t) )) 849 (bash sh-append shell ("\\$(\\(\\sw+\\)" (1 'sh-quoted-exec t) ))
849 (sh sh-append shell 850 (sh sh-append shell
850 ;; Variable names. 851 ;; Variable names.
851 ("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|[-#?@!]\\)" 2 852 ("\\$\\({#?\\)?\\([[:alpha:]_][[:alnum:]_]*\\|[-#?@!]\\)" 2
852 font-lock-variable-name-face) 853 font-lock-variable-name-face)
853 ;; Function names. 854 ;; Function names.
854 ("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face) 855 ("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face)
@@ -861,8 +862,8 @@ See `sh-feature'.")
861 (shell 862 (shell
862 ;; Using font-lock-string-face here confuses sh-get-indent-info. 863 ;; Using font-lock-string-face here confuses sh-get-indent-info.
863 ("\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\\\)$" 3 'sh-escaped-newline) 864 ("\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\\\)$" 3 'sh-escaped-newline)
864 ("\\\\[^A-Za-z0-9]" 0 font-lock-string-face) 865 ("\\\\[^[:alnum:]]" 0 font-lock-string-face)
865 ("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1 866 ("\\${?\\([[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[$*_]\\)" 1
866 font-lock-variable-name-face)) 867 font-lock-variable-name-face))
867 (rpm sh-append rpm2 868 (rpm sh-append rpm2
868 ("%{?\\(\\sw+\\)" 1 font-lock-keyword-face)) 869 ("%{?\\(\\sw+\\)" 1 font-lock-keyword-face))
@@ -991,46 +992,38 @@ subshells can nest."
991 (eq ?\" (nth 3 (syntax-ppss)))) 992 (eq ?\" (nth 3 (syntax-ppss))))
992 ;; bingo we have a $( or a ` inside a "" 993 ;; bingo we have a $( or a ` inside a ""
993 (let ((char (char-after (point))) 994 (let ((char (char-after (point)))
994 (continue t) 995 ;; `state' can be: double-quote, backquote, code.
995 (pos (point)) 996 (state (if (eq (char-before) ?`) 'backquote 'code))
996 (data nil) ;; value to put into match-data (and return) 997 ;; Stacked states in the context.
997 (last nil) ;; last char seen 998 (states '(double-quote)))
998 (bq (equal (match-string 1) "`")) ;; ` state flip-flop 999 (while (and state (progn (skip-chars-forward "^'\\\"`$()" limit)
999 (seen nil) ;; list of important positions 1000 (< (point) limit)))
1000 (nest 1)) ;; subshell nesting level 1001 ;; unescape " inside a $( ... ) construct.
1001 (while (and continue char (<= pos limit)) 1002 (case (char-after)
1002 ;; unescaped " inside a $( ... ) construct. 1003 (?\' (skip-chars-forward "^'" limit))
1003 ;; state machine time... 1004 (?\\ (forward-char 1))
1004 ;; \ => ignore next char; 1005 (?\" (case state
1005 ;; ` => increase or decrease nesting level based on bq flag 1006 (double-quote (setq state (pop states)))
1006 ;; ) [where nesting > 0] => decrease nesting 1007 (t (push state states) (setq state 'double-quote)))
1007 ;; ( [where nesting > 0] => increase nesting 1008 (if state (put-text-property (point) (1+ (point))
1008 ;; ( [preceeded by $ ] => increase nesting 1009 'syntax-table '(1))))
1009 ;; " [nesting <= 0 ] => terminate, we're done. 1010 (?\` (case state
1010 ;; " [nesting > 0 ] => remember this, it's not a proper " 1011 (backquote (setq state (pop states)))
1011 ;; FIXME: don't count parens that appear within quotes. 1012 (t (push state states) (setq state 'backquote))))
1012 (cond 1013 (?\$ (if (not (eq (char-after (1+ (point))) ?\())
1013 ((eq ?\\ last) nil) 1014 nil
1014 ((eq ?\` char) (setq nest (+ nest (if bq -1 1)) bq (not bq))) 1015 (case state
1015 ((and (> nest 0) (eq ?\) char)) (setq nest (1- nest))) 1016 (t (push state states) (setq state 'code)))))
1016 ((and (eq ?$ last) (eq ?\( char)) (setq nest (1+ nest))) 1017 (?\( (case state
1017 ((and (> nest 0) (eq ?\( char)) (setq nest (1+ nest))) 1018 (double-quote nil)
1018 ((eq char ?\") 1019 (t (push state states) (setq state 'code))))
1019 (if (>= 0 nest) (setq continue nil) (push pos seen)))) 1020 (?\) (case state
1020 ;;(message "POS: %d [%d]" pos nest) 1021 (double-quote nil)
1021 (setq last char 1022 (t (setq state (pop states)))))
1022 pos (1+ pos) 1023 (t (error "Internal error in sh-quoted-subshell")))
1023 char (char-after pos)) ) 1024 (forward-char 1)))
1024 ;; FIXME: why construct a costly match data to pass to 1025 t))
1025 ;; sh-apply-quoted-subshell rather than apply the highlight 1026
1026 ;; directly here? -- Stef
1027 (when seen
1028 ;;(message "SEEN: %S" seen)
1029 (setq data (list (current-buffer)))
1030 (dolist(P seen)
1031 (setq data (cons P (cons (1+ P) data))))
1032 (store-match-data data))
1033 data) ))
1034 1027
1035(defun sh-is-quoted-p (pos) 1028(defun sh-is-quoted-p (pos)
1036 (and (eq (char-before pos) ?\\) 1029 (and (eq (char-before pos) ?\\)
@@ -1075,17 +1068,6 @@ subshells can nest."
1075 (goto-char limit) 1068 (goto-char limit)
1076 nil) 1069 nil)
1077 1070
1078(defun sh-apply-quoted-subshell ()
1079 "Apply the `sh-st-punc' syntax to all the matches in `match-data'.
1080This is used to flag quote characters in subshell constructs inside strings
1081\(which should therefore not be treated as normal quote characters\)"
1082 (let ((m (match-data)) a b)
1083 (while m
1084 (setq a (car m)
1085 b (cadr m)
1086 m (cddr m))
1087 (put-text-property a b 'syntax-table sh-st-punc))) sh-st-punc)
1088
1089(defconst sh-font-lock-syntactic-keywords 1071(defconst sh-font-lock-syntactic-keywords
1090 ;; A `#' begins a comment when it is unquoted and at the beginning of a 1072 ;; A `#' begins a comment when it is unquoted and at the beginning of a
1091 ;; word. In the shell, words are separated by metacharacters. 1073 ;; word. In the shell, words are separated by metacharacters.
@@ -1112,8 +1094,7 @@ This is used to flag quote characters in subshell constructs inside strings
1112 (")" 0 (sh-font-lock-paren (match-beginning 0))) 1094 (")" 0 (sh-font-lock-paren (match-beginning 0)))
1113 ;; highlight (possibly nested) subshells inside "" quoted regions correctly. 1095 ;; highlight (possibly nested) subshells inside "" quoted regions correctly.
1114 ;; This should be at the very end because it uses syntax-ppss. 1096 ;; This should be at the very end because it uses syntax-ppss.
1115 (sh-quoted-subshell 1097 (sh-quoted-subshell)))
1116 (1 (sh-apply-quoted-subshell) t t))))
1117 1098
1118(defun sh-font-lock-syntactic-face-function (state) 1099(defun sh-font-lock-syntactic-face-function (state)
1119 (let ((q (nth 3 state))) 1100 (let ((q (nth 3 state)))
@@ -1134,17 +1115,17 @@ and command `sh-reset-indent-vars-to-global-values'."
1134 1115
1135 1116
1136(defcustom sh-set-shell-hook nil 1117(defcustom sh-set-shell-hook nil
1137 "*Hook run by `sh-set-shell'." 1118 "Hook run by `sh-set-shell'."
1138 :type 'hook 1119 :type 'hook
1139 :group 'sh-script) 1120 :group 'sh-script)
1140 1121
1141(defcustom sh-mode-hook nil 1122(defcustom sh-mode-hook nil
1142 "*Hook run by `sh-mode'." 1123 "Hook run by `sh-mode'."
1143 :type 'hook 1124 :type 'hook
1144 :group 'sh-script) 1125 :group 'sh-script)
1145 1126
1146(defcustom sh-learn-basic-offset nil 1127(defcustom sh-learn-basic-offset nil
1147 "*When `sh-guess-basic-offset' should learn `sh-basic-offset'. 1128 "When `sh-guess-basic-offset' should learn `sh-basic-offset'.
1148 1129
1149nil mean: never. 1130nil mean: never.
1150t means: only if there seems to be an obvious value. 1131t means: only if there seems to be an obvious value.
@@ -1156,7 +1137,7 @@ Anything else means: whenever we have a \"good guess\" as to the value."
1156 :group 'sh-indentation) 1137 :group 'sh-indentation)
1157 1138
1158(defcustom sh-popup-occur-buffer nil 1139(defcustom sh-popup-occur-buffer nil
1159 "*Controls when `sh-learn-buffer-indent' pops the `*indent*' buffer. 1140 "Controls when `sh-learn-buffer-indent' pops the `*indent*' buffer.
1160If t it is always shown. If nil, it is shown only when there 1141If t it is always shown. If nil, it is shown only when there
1161are conflicts." 1142are conflicts."
1162 :type '(choice 1143 :type '(choice
@@ -1165,7 +1146,7 @@ are conflicts."
1165 :group 'sh-indentation) 1146 :group 'sh-indentation)
1166 1147
1167(defcustom sh-blink t 1148(defcustom sh-blink t
1168 "*If non-nil, `sh-show-indent' shows the line indentation is relative to. 1149 "If non-nil, `sh-show-indent' shows the line indentation is relative to.
1169The position on the line is not necessarily meaningful. 1150The position on the line is not necessarily meaningful.
1170In some cases the line will be the matching keyword, but this is not 1151In some cases the line will be the matching keyword, but this is not
1171always the case." 1152always the case."
@@ -1173,7 +1154,7 @@ always the case."
1173 :group 'sh-indentation) 1154 :group 'sh-indentation)
1174 1155
1175(defcustom sh-first-lines-indent 0 1156(defcustom sh-first-lines-indent 0
1176 "*The indentation of the first non-blank non-comment line. 1157 "The indentation of the first non-blank non-comment line.
1177Usually 0 meaning first column. 1158Usually 0 meaning first column.
1178Can be set to a number, or to nil which means leave it as is." 1159Can be set to a number, or to nil which means leave it as is."
1179 :type '(choice 1160 :type '(choice
@@ -1184,13 +1165,13 @@ Can be set to a number, or to nil which means leave it as is."
1184 1165
1185 1166
1186(defcustom sh-basic-offset 4 1167(defcustom sh-basic-offset 4
1187 "*The default indentation increment. 1168 "The default indentation increment.
1188This value is used for the `+' and `-' symbols in an indentation variable." 1169This value is used for the `+' and `-' symbols in an indentation variable."
1189 :type 'integer 1170 :type 'integer
1190 :group 'sh-indentation) 1171 :group 'sh-indentation)
1191 1172
1192(defcustom sh-indent-comment nil 1173(defcustom sh-indent-comment nil
1193 "*How a comment line is to be indented. 1174 "How a comment line is to be indented.
1194nil means leave it as it is; 1175nil means leave it as it is;
1195t means indent it as a normal line, aligning it to previous non-blank 1176t means indent it as a normal line, aligning it to previous non-blank
1196 non-comment line; 1177 non-comment line;
@@ -1229,7 +1210,7 @@ a number means align to that column, e.g. 0 means fist column."
1229 :menu-tag "/ Indent left half sh-basic-offset"))) 1210 :menu-tag "/ Indent left half sh-basic-offset")))
1230 1211
1231(defcustom sh-indent-for-else 0 1212(defcustom sh-indent-for-else 0
1232 "*How much to indent an `else' relative to its `if'. Usually 0." 1213 "How much to indent an `else' relative to its `if'. Usually 0."
1233 :type `(choice 1214 :type `(choice
1234 (integer :menu-tag "A number (positive=>indent right)" 1215 (integer :menu-tag "A number (positive=>indent right)"
1235 :tag "A number") 1216 :tag "A number")
@@ -1245,41 +1226,41 @@ a number means align to that column, e.g. 0 means fist column."
1245 sh-symbol-list)) 1226 sh-symbol-list))
1246 1227
1247(defcustom sh-indent-for-fi 0 1228(defcustom sh-indent-for-fi 0
1248 "*How much to indent a `fi' relative to its `if'. Usually 0." 1229 "How much to indent a `fi' relative to its `if'. Usually 0."
1249 :type `(choice ,@ sh-number-or-symbol-list ) 1230 :type `(choice ,@ sh-number-or-symbol-list )
1250 :group 'sh-indentation) 1231 :group 'sh-indentation)
1251 1232
1252(defcustom sh-indent-for-done 0 1233(defcustom sh-indent-for-done 0
1253 "*How much to indent a `done' relative to its matching stmt. Usually 0." 1234 "How much to indent a `done' relative to its matching stmt. Usually 0."
1254 :type `(choice ,@ sh-number-or-symbol-list ) 1235 :type `(choice ,@ sh-number-or-symbol-list )
1255 :group 'sh-indentation) 1236 :group 'sh-indentation)
1256 1237
1257(defcustom sh-indent-after-else '+ 1238(defcustom sh-indent-after-else '+
1258 "*How much to indent a statement after an `else' statement." 1239 "How much to indent a statement after an `else' statement."
1259 :type `(choice ,@ sh-number-or-symbol-list ) 1240 :type `(choice ,@ sh-number-or-symbol-list )
1260 :group 'sh-indentation) 1241 :group 'sh-indentation)
1261 1242
1262(defcustom sh-indent-after-if '+ 1243(defcustom sh-indent-after-if '+
1263 "*How much to indent a statement after an `if' statement. 1244 "How much to indent a statement after an `if' statement.
1264This includes lines after `else' and `elif' statements, too, but 1245This includes lines after `else' and `elif' statements, too, but
1265does not affect the `else', `elif' or `fi' statements themselves." 1246does not affect the `else', `elif' or `fi' statements themselves."
1266 :type `(choice ,@ sh-number-or-symbol-list ) 1247 :type `(choice ,@ sh-number-or-symbol-list )
1267 :group 'sh-indentation) 1248 :group 'sh-indentation)
1268 1249
1269(defcustom sh-indent-for-then 0 1250(defcustom sh-indent-for-then 0
1270 "*How much to indent a `then' relative to its `if'." 1251 "How much to indent a `then' relative to its `if'."
1271 :type `(choice ,@ sh-number-or-symbol-list ) 1252 :type `(choice ,@ sh-number-or-symbol-list )
1272 :group 'sh-indentation) 1253 :group 'sh-indentation)
1273 1254
1274(defcustom sh-indent-for-do 0 1255(defcustom sh-indent-for-do 0
1275 "*How much to indent a `do' statement. 1256 "How much to indent a `do' statement.
1276This is relative to the statement before the `do', typically a 1257This is relative to the statement before the `do', typically a
1277`while', `until', `for', `repeat' or `select' statement." 1258`while', `until', `for', `repeat' or `select' statement."
1278 :type `(choice ,@ sh-number-or-symbol-list) 1259 :type `(choice ,@ sh-number-or-symbol-list)
1279 :group 'sh-indentation) 1260 :group 'sh-indentation)
1280 1261
1281(defcustom sh-indent-after-do '+ 1262(defcustom sh-indent-after-do '+
1282 "*How much to indent a line after a `do' statement. 1263 "How much to indent a line after a `do' statement.
1283This is used when the `do' is the first word of the line. 1264This is used when the `do' is the first word of the line.
1284This is relative to the statement before the `do', typically a 1265This is relative to the statement before the `do', typically a
1285`while', `until', `for', `repeat' or `select' statement." 1266`while', `until', `for', `repeat' or `select' statement."
@@ -1287,7 +1268,7 @@ This is relative to the statement before the `do', typically a
1287 :group 'sh-indentation) 1268 :group 'sh-indentation)
1288 1269
1289(defcustom sh-indent-after-loop-construct '+ 1270(defcustom sh-indent-after-loop-construct '+
1290 "*How much to indent a statement after a loop construct. 1271 "How much to indent a statement after a loop construct.
1291 1272
1292This variable is used when the keyword `do' is on the same line as the 1273This variable is used when the keyword `do' is on the same line as the
1293loop statement (e.g., `until', `while' or `for'). 1274loop statement (e.g., `until', `while' or `for').
@@ -1297,7 +1278,7 @@ If the `do' is on a line by itself, then `sh-indent-after-do' is used instead."
1297 1278
1298 1279
1299(defcustom sh-indent-after-done 0 1280(defcustom sh-indent-after-done 0
1300 "*How much to indent a statement after a `done' keyword. 1281 "How much to indent a statement after a `done' keyword.
1301Normally this is 0, which aligns the `done' to the matching 1282Normally this is 0, which aligns the `done' to the matching
1302looping construct line. 1283looping construct line.
1303Setting it non-zero allows you to have the `do' statement on a line 1284Setting it non-zero allows you to have the `do' statement on a line
@@ -1306,55 +1287,55 @@ by itself and align the done under to do."
1306 :group 'sh-indentation) 1287 :group 'sh-indentation)
1307 1288
1308(defcustom sh-indent-for-case-label '+ 1289(defcustom sh-indent-for-case-label '+
1309 "*How much to indent a case label statement. 1290 "How much to indent a case label statement.
1310This is relative to the line containing the `case' statement." 1291This is relative to the line containing the `case' statement."
1311 :type `(choice ,@ sh-number-or-symbol-list) 1292 :type `(choice ,@ sh-number-or-symbol-list)
1312 :group 'sh-indentation) 1293 :group 'sh-indentation)
1313 1294
1314(defcustom sh-indent-for-case-alt '++ 1295(defcustom sh-indent-for-case-alt '++
1315 "*How much to indent statements after the case label. 1296 "How much to indent statements after the case label.
1316This is relative to the line containing the `case' statement." 1297This is relative to the line containing the `case' statement."
1317 :type `(choice ,@ sh-number-or-symbol-list) 1298 :type `(choice ,@ sh-number-or-symbol-list)
1318 :group 'sh-indentation) 1299 :group 'sh-indentation)
1319 1300
1320 1301
1321(defcustom sh-indent-for-continuation '+ 1302(defcustom sh-indent-for-continuation '+
1322 "*How much to indent for a continuation statement." 1303 "How much to indent for a continuation statement."
1323 :type `(choice ,@ sh-number-or-symbol-list) 1304 :type `(choice ,@ sh-number-or-symbol-list)
1324 :group 'sh-indentation) 1305 :group 'sh-indentation)
1325 1306
1326(defcustom sh-indent-after-open '+ 1307(defcustom sh-indent-after-open '+
1327 "*How much to indent after a line with an opening parenthesis or brace. 1308 "How much to indent after a line with an opening parenthesis or brace.
1328For an open paren after a function, `sh-indent-after-function' is used." 1309For an open paren after a function, `sh-indent-after-function' is used."
1329 :type `(choice ,@ sh-number-or-symbol-list) 1310 :type `(choice ,@ sh-number-or-symbol-list)
1330 :group 'sh-indentation) 1311 :group 'sh-indentation)
1331 1312
1332(defcustom sh-indent-after-function '+ 1313(defcustom sh-indent-after-function '+
1333 "*How much to indent after a function line." 1314 "How much to indent after a function line."
1334 :type `(choice ,@ sh-number-or-symbol-list) 1315 :type `(choice ,@ sh-number-or-symbol-list)
1335 :group 'sh-indentation) 1316 :group 'sh-indentation)
1336 1317
1337;; These 2 are for the rc shell: 1318;; These 2 are for the rc shell:
1338 1319
1339(defcustom sh-indent-after-switch '+ 1320(defcustom sh-indent-after-switch '+
1340 "*How much to indent a `case' statement relative to the `switch' statement. 1321 "How much to indent a `case' statement relative to the `switch' statement.
1341This is for the rc shell." 1322This is for the rc shell."
1342 :type `(choice ,@ sh-number-or-symbol-list) 1323 :type `(choice ,@ sh-number-or-symbol-list)
1343 :group 'sh-indentation) 1324 :group 'sh-indentation)
1344 1325
1345(defcustom sh-indent-after-case '+ 1326(defcustom sh-indent-after-case '+
1346 "*How much to indent a statement relative to the `case' statement. 1327 "How much to indent a statement relative to the `case' statement.
1347This is for the rc shell." 1328This is for the rc shell."
1348 :type `(choice ,@ sh-number-or-symbol-list) 1329 :type `(choice ,@ sh-number-or-symbol-list)
1349 :group 'sh-indentation) 1330 :group 'sh-indentation)
1350 1331
1351(defcustom sh-backslash-column 48 1332(defcustom sh-backslash-column 48
1352 "*Column in which `sh-backslash-region' inserts backslashes." 1333 "Column in which `sh-backslash-region' inserts backslashes."
1353 :type 'integer 1334 :type 'integer
1354 :group 'sh) 1335 :group 'sh)
1355 1336
1356(defcustom sh-backslash-align t 1337(defcustom sh-backslash-align t
1357 "*If non-nil, `sh-backslash-region' will align backslashes." 1338 "If non-nil, `sh-backslash-region' will align backslashes."
1358 :type 'boolean 1339 :type 'boolean
1359 :group 'sh) 1340 :group 'sh)
1360 1341
@@ -1364,7 +1345,7 @@ This is for the rc shell."
1364 "Make a regexp which matches WORD as a word. 1345 "Make a regexp which matches WORD as a word.
1365This specifically excludes an occurrence of WORD followed by 1346This specifically excludes an occurrence of WORD followed by
1366punctuation characters like '-'." 1347punctuation characters like '-'."
1367 (concat word "\\([^-a-z0-9_]\\|$\\)")) 1348 (concat word "\\([^-[:alnum:]_]\\|$\\)"))
1368 1349
1369(defconst sh-re-done (sh-mkword-regexpr "done")) 1350(defconst sh-re-done (sh-mkword-regexpr "done"))
1370 1351
@@ -2251,6 +2232,7 @@ STRING This is ignored for the purposes of calculating
2251 (setq align-point (point)))) 2232 (setq align-point (point))))
2252 (or (bobp) 2233 (or (bobp)
2253 (forward-char -1)) 2234 (forward-char -1))
2235 ;; FIXME: This charset looks too much like a regexp. --Stef
2254 (skip-chars-forward "[a-z0-9]*?") 2236 (skip-chars-forward "[a-z0-9]*?")
2255 ) 2237 )
2256 ((string-match "[])}]" x) 2238 ((string-match "[])}]" x)
@@ -2459,7 +2441,7 @@ we go to the end of the previous line and do not check for continuations."
2459 (if (looking-at "[\"'`]") 2441 (if (looking-at "[\"'`]")
2460 (sh-safe-forward-sexp) 2442 (sh-safe-forward-sexp)
2461 ;; (> (skip-chars-forward "^ \t\n\"'`") 0) 2443 ;; (> (skip-chars-forward "^ \t\n\"'`") 0)
2462 (> (skip-chars-forward "-_a-zA-Z$0-9") 0) 2444 (> (skip-chars-forward "-_$[:alnum:]") 0)
2463 )) 2445 ))
2464 (buffer-substring start (point)) 2446 (buffer-substring start (point))
2465 )) 2447 ))