# HG changeset patch # User Mike Sperber # Date 1361354836 -3600 # Node ID e32ce9c59c23cbeed381b4248642720749aef344 # Parent 74172066fd6aba10d3e5b167de76921daa661c33 Allow the lhs a syntax-alist entry in `font-lock-defaults' to be a string. 2013-02-08 Michael Sperber * font-lock.el (font-lock-set-defaults-1): (font-lock-defaults): Allow the left-hand-side of a syntax-alist entry in `font-lock-defaults' to be a string, in addition to a char. (This is a sync with GNU Emacs.) diff -r 74172066fd6a -r e32ce9c59c23 lisp/ChangeLog --- a/lisp/ChangeLog Sat Feb 16 21:52:55 2013 +0900 +++ b/lisp/ChangeLog Wed Feb 20 11:07:16 2013 +0100 @@ -1,3 +1,10 @@ +2013-02-08 Michael Sperber + + * font-lock.el (font-lock-set-defaults-1): + (font-lock-defaults): Allow the left-hand-side of a syntax-alist + entry in `font-lock-defaults' to be a string, in addition to a + char. (This is a sync with GNU Emacs.) + 2013-02-16 Stephen J. Turnbull Thanks to Jeff Sparkes for suggestion and the original patches and diff -r 74172066fd6a -r e32ce9c59c23 lisp/font-lock.el --- a/lisp/font-lock.el Sat Feb 16 21:52:55 2013 +0900 +++ b/lisp/font-lock.el Wed Feb 20 11:07:16 2013 +0100 @@ -529,9 +529,9 @@ to use for fontification) or a list of symbols. If KEYWORDS-ONLY is non-nil, syntactic fontification (strings and comments) is not performed. If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying. If -SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form (CHAR -. STRING) used to set the local Font Lock syntax table, for keyword and -syntactic fontification (see `modify-syntax-entry'). +SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form +(CHAR-OR-STRING . STRING) used to set the local Font Lock syntax table, for +keyword and syntactic fontification (see `modify-syntax-entry'). If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move backwards outside any enclosing syntactic block, for syntactic fontification. @@ -2070,8 +2070,16 @@ (setq font-lock-syntax-table (copy-syntax-table (syntax-table))) (while slist - (modify-syntax-entry (car (car slist)) (cdr (car slist)) - font-lock-syntax-table) + (let ((entry (cdr (car slist))) + (thing (car (car slist)))) + (mapc #'(lambda (char) + (modify-syntax-entry char entry + font-lock-syntax-table)) + (cond + ((stringp thing) (string-to-list thing)) + ((characterp thing) (list thing)) + (t + (error "invalid syntax-alist entry for `font-lock-defaults': %S" (car slist)))))) (setq slist (cdr slist))))) ;; Syntax function?