Mercurial > hg > xemacs-beta
comparison lisp/font-lock.el @ 566:e62e90435c57
[xemacs-hg @ 2001-05-24 11:01:53 by yoshiki]
Daiki Ueno's patch "side effect on font-lock-keywords",
<m2n18lsumy.fsf@deisui.bug.org>
* font-lock.el (font-lock-compile-keywords): Rewrite as a side
effect free function.
(font-lock-fontify-keywords-region): Supply the argument to
font-lock-compile-keywords.
author | yoshiki |
---|---|
date | Thu, 24 May 2001 11:01:54 +0000 |
parents | 0493e9f3c27f |
children | 6e99cc8c6ca5 |
comparison
equal
deleted
inserted
replaced
565:e9162e1ea200 | 566:e62e90435c57 |
---|---|
1590 (defun font-lock-fontify-keywords-region (start end &optional loudvar) | 1590 (defun font-lock-fontify-keywords-region (start end &optional loudvar) |
1591 "Fontify according to `font-lock-keywords' between START and END. | 1591 "Fontify according to `font-lock-keywords' between START and END. |
1592 START should be at the beginning of a line." | 1592 START should be at the beginning of a line." |
1593 (let ((loudly (and font-lock-verbose | 1593 (let ((loudly (and font-lock-verbose |
1594 (>= (- end start) font-lock-message-threshold)))) | 1594 (>= (- end start) font-lock-message-threshold)))) |
1595 ;; If `font-lock-keywords' is not compiled, compile it. | |
1596 (unless (eq (car-safe font-lock-keywords) t) | |
1597 (setq font-lock-keywords (font-lock-compile-keywords | |
1598 font-lock-keywords))) | |
1595 (let* ((case-fold-search font-lock-keywords-case-fold-search) | 1599 (let* ((case-fold-search font-lock-keywords-case-fold-search) |
1596 (keywords (cdr (if (eq (car-safe font-lock-keywords) t) | 1600 (keywords (cdr font-lock-keywords)) |
1597 font-lock-keywords | |
1598 (font-lock-compile-keywords)))) | |
1599 (bufname (buffer-name)) | 1601 (bufname (buffer-name)) |
1600 (progress 5) (old-progress 5) | 1602 (progress 5) (old-progress 5) |
1601 (iter 0) | 1603 (iter 0) |
1602 (nkeywords (length keywords)) | 1604 (nkeywords (length keywords)) |
1603 keyword matcher highlights) | 1605 keyword matcher highlights) |
1667 (declare-fboundp (lazy-lock-after-fontify-buffer))))) | 1669 (declare-fboundp (lazy-lock-after-fontify-buffer))))) |
1668 | 1670 |
1669 | 1671 |
1670 ;; Various functions. | 1672 ;; Various functions. |
1671 | 1673 |
1672 (defun font-lock-compile-keywords (&optional keywords) | 1674 (defun font-lock-compile-keywords (keywords) |
1673 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD | 1675 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD |
1674 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. | 1676 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. |
1675 (let ((keywords (or keywords font-lock-keywords))) | 1677 (if (eq (car-safe keywords) t) |
1676 (setq font-lock-keywords | 1678 keywords |
1677 (if (eq (car-safe keywords) t) | 1679 (cons t (mapcar 'font-lock-compile-keyword keywords)))) |
1678 keywords | |
1679 (cons t (mapcar 'font-lock-compile-keyword keywords)))))) | |
1680 | 1680 |
1681 (defun font-lock-compile-keyword (keyword) | 1681 (defun font-lock-compile-keyword (keyword) |
1682 (cond ((nlistp keyword) ; Just MATCHER | 1682 (cond ((nlistp keyword) ; Just MATCHER |
1683 (list keyword '(0 font-lock-keyword-face))) | 1683 (list keyword '(0 font-lock-keyword-face))) |
1684 ((eq (car keyword) 'eval) ; Specified (eval . FORM) | 1684 ((eq (car keyword) 'eval) ; Specified (eval . FORM) |