(defvar sh-mode-syntax-table
- '((csh eval identity sh)
- (sh eval sh-mode-syntax-table ()
- ;; #'s meanings depend on context which can't be expressed here
- ;; ?\# "<"
- ;; ?\^l ">#"
- ;; ?\n ">#"
+ '((sh eval sh-mode-syntax-table ()
+ ?\# "<"
+ ?\^l ">#"
+ ?\n ">#"
?\" "\"\""
?\' "\"'"
- ?\` ".`"
- ?$ "_"
+ ?\` "\"`"
+ ?$ "\\" ; `escape' so $# doesn't start a comment
?! "_"
?% "_"
?: "_"
?. "_"
?^ "_"
?~ "_")
- (rc eval sh-mode-syntax-table sh
- ?\" "_"
- ?\` "."))
+ (csh eval identity sh)
+ (rc eval identity sh))
"Syntax-table used in Shell-Script mode. See `sh-feature'.")
See `sh-feature'.")
-(defvar sh-comment-prefix
- '((csh . "\\(^\\|[^$]\\|\\$[^{]\\)")
- (rc eval identity csh)
- (sh . "\\(^\\|[ \t|&;()]\\)"))
- "*Regexp matching what may come before a comment `#'.
-This must contain one \\(grouping\\) since it is the basis for fontifying
-comments as well as for `comment-start-skip'.
-See `sh-feature'.")
-
-
(defvar sh-assignment-regexp
'((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=")
;; actually spaces are only supported in let/(( ... ))
(defvar sh-font-lock-keywords-2 ()
"*Yet more rules for highlighting shell scripts. See `sh-feature'.")
-(defvar sh-font-lock-keywords-only t
- "*Value of `font-lock-keywords-only' for highlighting shell scripts.
-Default value is `t' because Emacs' syntax is not expressive enough to
-detect that $# does not start a comment. Thus comments are fontified by
-regexp which means that a single apostrophe in a comment turns everything
-upto the next one or end of buffer into a string.")
\f
;; mode-command and utility functions
paragraph-start (concat page-delimiter "\\|$")
paragraph-separate paragraph-start
comment-start "# "
- comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*")
+ comment-start-skip "#+[\t ]*"
comint-dynamic-complete-functions sh-dynamic-complete-functions
;; we can't look if previous line ended with `\'
comint-prompt-regexp "^[ \t]*"
`((sh-font-lock-keywords
sh-font-lock-keywords-1
sh-font-lock-keywords-2)
- ,sh-font-lock-keywords-only
- nil
+ nil nil
((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")))
skeleton-pair-alist '((?` _ ?`))
skeleton-pair-filter 'sh-quoted-p
skeleton-filter 'sh-feature
skeleton-newline-indent-rigidly t)
(save-excursion
- ;; parse or insert magic number for exec() and set all variables depending
- ;; on the shell thus determined
+ ;; Parse or insert magic number for exec, and set all variables depending
+ ;; on the shell thus determined.
(goto-char (point-min))
(and (zerop (buffer-size))
(not buffer-read-only)
This adds rules for comments and assignments."
(sh-feature sh-font-lock-keywords
(lambda (list)
- `((,(concat (sh-feature sh-comment-prefix) "\\(#.*\\)")
- 2 font-lock-comment-face t)
- (,(sh-feature sh-assignment-regexp)
+ `((,(sh-feature sh-assignment-regexp)
1 font-lock-variable-name-face)
,@keywords
,@list))))
;;; local-abbrev-table (sh-feature sh-abbrevs)
font-lock-keywords nil ; force resetting
font-lock-syntax-table nil
- comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*")
+ comment-start-skip "#+[\t ]*"
mode-line-process (format "[%s]" sh-shell)
sh-shell-variables nil
sh-shell-variables-initialized nil