Function: sh-syntax-propertize-function

sh-syntax-propertize-function is a byte-compiled function defined in sh-script.el.gz.

Signature

(sh-syntax-propertize-function START END)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sh-script.el.gz
(defun sh-syntax-propertize-function (start end)
  (goto-char start)
  (sh-syntax-propertize-here-doc end)
  (funcall
   (syntax-propertize-rules
    (sh-here-doc-open-re
     (2 (sh-font-lock-open-heredoc
         (1+ (match-beginning 0)) (match-string 1) (match-beginning 2))))
    ("\\s|" (0 (prog1 nil (sh-syntax-propertize-here-doc end))))
    ;; 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.  Also -- if there's something like
    ;; \ #foo, then that's not a comment, unless the backslash itself
    ;; is backslashed.
    ("\\(?:[^|&;<>(`\\\"' \t\n]\\|\\${\\|\\(?:[^\\]\\|^\\)\\\\\\(?:\\\\\\\\\\)*.\\)\\(#+\\)" (1 "_"))
    ;; In addition, `#' at the beginning of closed parentheses
    ;; does not start a comment if the parentheses are not isolated
    ;; by metacharacters, excluding [()].
    ;; (e.g. `foo(#q/)' and `(#b)foo' in zsh)
    ("[^|&;<>(`\\\"' \t\n](\\(#+\\)" (1 "_"))
    ("(\\(#\\)[^)]+?)[^|&;<>)`\\\"' \t\n]" (1 "_"))
    ;; In a '...' the backslash is not escaping.
    ("\\(\\\\\\)'" (1 (sh-font-lock-backslash-quote)))
    ;; Make sure $@ and $? are correctly recognized as sexps.
    ("\\$\\([?@]\\)" (1 "_"))
    ;; Distinguish the special close-paren in `case'.
    (")" (0 (sh-font-lock-paren (match-beginning 0))))
    ;; Highlight (possibly nested) subshells inside "" quoted
    ;; regions correctly.
    ("\"\\(?:[^\\\"]\\|\\\\.\\)*?\\(\\$(\\|`\\)"
     (1 (ignore
         (if (nth 8 (save-excursion (syntax-ppss (match-beginning 0))))
             (goto-char (1+ (match-beginning 0)))
           ;; Save excursion because we want to also apply other
           ;; syntax-propertize rules within the affected region.
           (save-excursion
             (sh-font-lock-quoted-subshell end)))))))
   (point) end))