diff lisp/font-lock.el @ 5719:e32ce9c59c23

Allow the lhs a syntax-alist entry in `font-lock-defaults' to be a string. 2013-02-08 Michael Sperber <mike@xemacs.org> * 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.)
author Mike Sperber <sperber@deinprogramm.de>
date Wed, 20 Feb 2013 11:07:16 +0100
parents cc6f0266bc36
children 1d6995b6986e
line wrap: on
line diff
--- 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?