changeset 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 b5a48e84e696
children 1bfc2fad762a
files lisp/progmodes/sh-script.el
diffstat 1 files changed, 6 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/sh-script.el	Wed Mar 07 15:31:51 2001 +0000
+++ b/lisp/progmodes/sh-script.el	Wed Mar 07 15:34:43 2001 +0000
@@ -814,6 +814,7 @@
 ;; These are used for the syntax table stuff (derived from cperl-mode).
 ;; Note: parse-sexp-lookup-properties must be set to t for it to work.
 (defconst sh-st-punc (string-to-syntax "."))
+(defconst sh-st-symbol (string-to-syntax "_"))
 (defconst sh-here-doc-syntax (string-to-syntax "|")) ;; generic string
 
 (defun sh-font-lock-heredoc (start string quoted)
@@ -867,15 +868,11 @@
       sh-st-punc)))
 
 (defconst sh-font-lock-syntactic-keywords
-  ;; Mark a `#' character as having punctuation syntax in a variable reference.
-  ;; Really we should do this properly.  From Chet Ramey and Brian Fox:
-  ;; "A `#' begins a comment when it is unquoted and at the beginning of a
-  ;; word.  In the shell, words are separated by metacharacters."
-  ;; To do this in a regexp would be slow as it would be anchored to the right.
-  ;; But I can't be bothered to write a function to do it properly and
-  ;; efficiently.  So we only do it properly for `#' in variable references and
-  ;; do it efficiently by anchoring the regexp to the left.
-  `(("\\${?[^}#\n\t ]*\\(##?\\)" 1 ,sh-st-punc)
+  ;; A `#' begins a comment when it is unquoted and at the beginning of a
+  ;; word.  In the shell, words are separated by metacharacters.
+  ;; The list of special chars is taken from the single-unix spec
+  ;; of the shell command language (under `quoting') but with `$' removed.
+  `(("[^|&;<>()`\\\"' \t\n]\\(#+\\)" 1 ,sh-st-symbol)
     ;; Find HEREDOC starters and add a corresponding rule for the ender.
     ("[^<>]<<\\(-\\)?\\s-*\\(\\(['\"][^'\"]+['\"]\\|\\sw\\|\\s_\\)+\\).*\\(\n\\)"
      4 (sh-font-lock-heredoc
@@ -1257,7 +1254,6 @@
   (make-local-variable 'sh-shell-variables-initialized)
   (make-local-variable 'imenu-generic-expression)
   (make-local-variable 'sh-indent-supported-here)
-  (make-local-variable 'font-lock-unfontify-region-function)
   (setq skeleton-end-hook (lambda ()
 			    (or (eolp) (newline) (indent-relative)))
 	paragraph-start (concat page-delimiter "\\|$")