changeset 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 74172066fd6a
children 1d6995b6986e
files lisp/ChangeLog lisp/font-lock.el
diffstat 2 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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  <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.)
+
 2013-02-16  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	Thanks to Jeff Sparkes for suggestion and the original patches and
--- 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?