Mercurial > emacs
comparison lisp/progmodes/sh-script.el @ 36631:d5345decc9a4
(sh-st-symbol): New symbol.
(sh-font-lock-syntactic-keywords): Use it and fix bogus comment regexp.
(sh-mode): Remove `make-local-variable' for unused var
`font-lock-unfontify-region-function'.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 07 Mar 2001 15:34:43 +0000 |
parents | f4733aab37df |
children | f9dbfb08ed11 |
comparison
equal
deleted
inserted
replaced
36630:b5a48e84e696 | 36631:d5345decc9a4 |
---|---|
812 "Gaudy level highlighting for Shell Script modes.") | 812 "Gaudy level highlighting for Shell Script modes.") |
813 | 813 |
814 ;; These are used for the syntax table stuff (derived from cperl-mode). | 814 ;; These are used for the syntax table stuff (derived from cperl-mode). |
815 ;; Note: parse-sexp-lookup-properties must be set to t for it to work. | 815 ;; Note: parse-sexp-lookup-properties must be set to t for it to work. |
816 (defconst sh-st-punc (string-to-syntax ".")) | 816 (defconst sh-st-punc (string-to-syntax ".")) |
817 (defconst sh-st-symbol (string-to-syntax "_")) | |
817 (defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string | 818 (defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string |
818 | 819 |
819 (defun sh-font-lock-heredoc (start string quoted) | 820 (defun sh-font-lock-heredoc (start string quoted) |
820 "Determine the syntax of the \\n after a <<HEREDOC." | 821 "Determine the syntax of the \\n after a <<HEREDOC." |
821 (unless (sh-in-comment-or-string start) | 822 (unless (sh-in-comment-or-string start) |
865 (backward-char 1) t))) | 866 (backward-char 1) t))) |
866 (when (save-excursion (backward-char 2) (looking-at ";;\\|in")) | 867 (when (save-excursion (backward-char 2) (looking-at ";;\\|in")) |
867 sh-st-punc))) | 868 sh-st-punc))) |
868 | 869 |
869 (defconst sh-font-lock-syntactic-keywords | 870 (defconst sh-font-lock-syntactic-keywords |
870 ;; Mark a `#' character as having punctuation syntax in a variable reference. | 871 ;; A `#' begins a comment when it is unquoted and at the beginning of a |
871 ;; Really we should do this properly. From Chet Ramey and Brian Fox: | 872 ;; word. In the shell, words are separated by metacharacters. |
872 ;; "A `#' begins a comment when it is unquoted and at the beginning of a | 873 ;; The list of special chars is taken from the single-unix spec |
873 ;; word. In the shell, words are separated by metacharacters." | 874 ;; of the shell command language (under `quoting') but with `$' removed. |
874 ;; To do this in a regexp would be slow as it would be anchored to the right. | 875 `(("[^|&;<>()`\\\"' \t\n]\\(#+\\)" 1 ,sh-st-symbol) |
875 ;; But I can't be bothered to write a function to do it properly and | |
876 ;; efficiently. So we only do it properly for `#' in variable references and | |
877 ;; do it efficiently by anchoring the regexp to the left. | |
878 `(("\\${?[^}#\n\t ]*\\(##?\\)" 1 ,sh-st-punc) | |
879 ;; Find HEREDOC starters and add a corresponding rule for the ender. | 876 ;; Find HEREDOC starters and add a corresponding rule for the ender. |
880 ("[^<>]<<\\(-\\)?\\s-*\\(\\(['\"][^'\"]+['\"]\\|\\sw\\|\\s_\\)+\\).*\\(\n\\)" | 877 ("[^<>]<<\\(-\\)?\\s-*\\(\\(['\"][^'\"]+['\"]\\|\\sw\\|\\s_\\)+\\).*\\(\n\\)" |
881 4 (sh-font-lock-heredoc | 878 4 (sh-font-lock-heredoc |
882 (match-beginning 0) (match-string 2) (match-end 1))) | 879 (match-beginning 0) (match-string 2) (match-end 1))) |
883 ;; Distinguish the special close-paren in `case'. | 880 ;; Distinguish the special close-paren in `case'. |
1255 (make-local-variable 'skeleton-newline-indent-rigidly) | 1252 (make-local-variable 'skeleton-newline-indent-rigidly) |
1256 (make-local-variable 'sh-shell-variables) | 1253 (make-local-variable 'sh-shell-variables) |
1257 (make-local-variable 'sh-shell-variables-initialized) | 1254 (make-local-variable 'sh-shell-variables-initialized) |
1258 (make-local-variable 'imenu-generic-expression) | 1255 (make-local-variable 'imenu-generic-expression) |
1259 (make-local-variable 'sh-indent-supported-here) | 1256 (make-local-variable 'sh-indent-supported-here) |
1260 (make-local-variable 'font-lock-unfontify-region-function) | |
1261 (setq skeleton-end-hook (lambda () | 1257 (setq skeleton-end-hook (lambda () |
1262 (or (eolp) (newline) (indent-relative))) | 1258 (or (eolp) (newline) (indent-relative))) |
1263 paragraph-start (concat page-delimiter "\\|$") | 1259 paragraph-start (concat page-delimiter "\\|$") |
1264 paragraph-separate paragraph-start | 1260 paragraph-separate paragraph-start |
1265 comment-start "# " | 1261 comment-start "# " |