comparison 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
comparison
equal deleted inserted replaced
5718:74172066fd6a 5719:e32ce9c59c23
527 527
528 KEYWORDS may be a symbol (a variable or function whose value is the keywords 528 KEYWORDS may be a symbol (a variable or function whose value is the keywords
529 to use for fontification) or a list of symbols. If KEYWORDS-ONLY is non-nil, 529 to use for fontification) or a list of symbols. If KEYWORDS-ONLY is non-nil,
530 syntactic fontification (strings and comments) is not performed. If CASE-FOLD 530 syntactic fontification (strings and comments) is not performed. If CASE-FOLD
531 is non-nil, the case of the keywords is ignored when fontifying. If 531 is non-nil, the case of the keywords is ignored when fontifying. If
532 SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form (CHAR 532 SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form
533 . STRING) used to set the local Font Lock syntax table, for keyword and 533 (CHAR-OR-STRING . STRING) used to set the local Font Lock syntax table, for
534 syntactic fontification (see `modify-syntax-entry'). 534 keyword and syntactic fontification (see `modify-syntax-entry').
535 535
536 If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move 536 If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move
537 backwards outside any enclosing syntactic block, for syntactic fontification. 537 backwards outside any enclosing syntactic block, for syntactic fontification.
538 Typical values are `beginning-of-line' (i.e., the start of the line is known to 538 Typical values are `beginning-of-line' (i.e., the start of the line is known to
539 be outside a syntactic block), or `beginning-of-defun' for programming modes or 539 be outside a syntactic block), or `beginning-of-defun' for programming modes or
2068 (if (nth 3 defaults) 2068 (if (nth 3 defaults)
2069 (let ((slist (nth 3 defaults))) 2069 (let ((slist (nth 3 defaults)))
2070 (setq font-lock-syntax-table 2070 (setq font-lock-syntax-table
2071 (copy-syntax-table (syntax-table))) 2071 (copy-syntax-table (syntax-table)))
2072 (while slist 2072 (while slist
2073 (modify-syntax-entry (car (car slist)) (cdr (car slist)) 2073 (let ((entry (cdr (car slist)))
2074 font-lock-syntax-table) 2074 (thing (car (car slist))))
2075 (mapc #'(lambda (char)
2076 (modify-syntax-entry char entry
2077 font-lock-syntax-table))
2078 (cond
2079 ((stringp thing) (string-to-list thing))
2080 ((characterp thing) (list thing))
2081 (t
2082 (error "invalid syntax-alist entry for `font-lock-defaults': %S" (car slist))))))
2075 (setq slist (cdr slist))))) 2083 (setq slist (cdr slist)))))
2076 2084
2077 ;; Syntax function? 2085 ;; Syntax function?
2078 (cond (defaults 2086 (cond (defaults
2079 (setq font-lock-beginning-of-syntax-function 2087 (setq font-lock-beginning-of-syntax-function