comparison lisp/font-lock.el @ 90602:b5c13d1564a9

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 437-446) - Update from CVS - lisp/url/url-methods.el: Fix format error when http_proxy is empty string - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 137-140) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-111
author Miles Bader <miles@gnu.org>
date Wed, 20 Sep 2006 06:04:23 +0000
parents 6823a91487f2 cc737d1f33f9
children bb0e318b7c53
comparison
equal deleted inserted replaced
90601:a1a25ac6c88a 90602:b5c13d1564a9
716 (append old keywords) 716 (append old keywords)
717 (append keywords old))))) 717 (append keywords old)))))
718 ;; If the keywords were compiled before, compile them again. 718 ;; If the keywords were compiled before, compile them again.
719 (if was-compiled 719 (if was-compiled
720 (setq font-lock-keywords 720 (setq font-lock-keywords
721 (font-lock-compile-keywords font-lock-keywords t))))))) 721 (font-lock-compile-keywords font-lock-keywords)))))))
722 722
723 (defun font-lock-update-removed-keyword-alist (mode keywords how) 723 (defun font-lock-update-removed-keyword-alist (mode keywords how)
724 "Update `font-lock-removed-keywords-alist' when adding new KEYWORDS to MODE." 724 "Update `font-lock-removed-keywords-alist' when adding new KEYWORDS to MODE."
725 ;; When font-lock is enabled first all keywords in the list 725 ;; When font-lock is enabled first all keywords in the list
726 ;; `font-lock-keywords-alist' are added, then all keywords in the 726 ;; `font-lock-keywords-alist' are added, then all keywords in the
823 (delete keyword font-lock-keywords))) 823 (delete keyword font-lock-keywords)))
824 824
825 ;; If the keywords were compiled before, compile them again. 825 ;; If the keywords were compiled before, compile them again.
826 (if was-compiled 826 (if was-compiled
827 (setq font-lock-keywords 827 (setq font-lock-keywords
828 (font-lock-compile-keywords font-lock-keywords t))))))) 828 (font-lock-compile-keywords font-lock-keywords)))))))
829 829
830 ;;; Font Lock Support mode. 830 ;;; Font Lock Support mode.
831 831
832 ;; This is the code used to interface font-lock.el with any of its add-on 832 ;; This is the code used to interface font-lock.el with any of its add-on
833 ;; packages, and provide the user interface. Packages that have their own 833 ;; packages, and provide the user interface. Packages that have their own
1412 (setq font-lock-syntactic-keywords (font-lock-eval-keywords 1412 (setq font-lock-syntactic-keywords (font-lock-eval-keywords
1413 font-lock-syntactic-keywords))) 1413 font-lock-syntactic-keywords)))
1414 ;; If `font-lock-syntactic-keywords' is not compiled, compile it. 1414 ;; If `font-lock-syntactic-keywords' is not compiled, compile it.
1415 (unless (eq (car font-lock-syntactic-keywords) t) 1415 (unless (eq (car font-lock-syntactic-keywords) t)
1416 (setq font-lock-syntactic-keywords (font-lock-compile-keywords 1416 (setq font-lock-syntactic-keywords (font-lock-compile-keywords
1417 font-lock-syntactic-keywords))) 1417 font-lock-syntactic-keywords
1418 t)))
1418 ;; Get down to business. 1419 ;; Get down to business.
1419 (let ((case-fold-search font-lock-keywords-case-fold-search) 1420 (let ((case-fold-search font-lock-keywords-case-fold-search)
1420 (keywords (cddr font-lock-syntactic-keywords)) 1421 (keywords (cddr font-lock-syntactic-keywords))
1421 keyword matcher highlights) 1422 keyword matcher highlights)
1422 (while keywords 1423 (while keywords
1568 "Fontify according to `font-lock-keywords' between START and END. 1569 "Fontify according to `font-lock-keywords' between START and END.
1569 START should be at the beginning of a line. 1570 START should be at the beginning of a line.
1570 LOUDLY, if non-nil, allows progress-meter bar." 1571 LOUDLY, if non-nil, allows progress-meter bar."
1571 (unless (eq (car font-lock-keywords) t) 1572 (unless (eq (car font-lock-keywords) t)
1572 (setq font-lock-keywords 1573 (setq font-lock-keywords
1573 (font-lock-compile-keywords font-lock-keywords t))) 1574 (font-lock-compile-keywords font-lock-keywords)))
1574 (let ((case-fold-search font-lock-keywords-case-fold-search) 1575 (let ((case-fold-search font-lock-keywords-case-fold-search)
1575 (keywords (cddr font-lock-keywords)) 1576 (keywords (cddr font-lock-keywords))
1576 (bufname (buffer-name)) (count 0) 1577 (bufname (buffer-name)) (count 0)
1577 (pos (make-marker)) 1578 (pos (make-marker))
1578 keyword matcher highlights) 1579 keyword matcher highlights)
1624 1625
1625 ;;; End of Keyword regexp fontification functions. 1626 ;;; End of Keyword regexp fontification functions.
1626 1627
1627 ;; Various functions. 1628 ;; Various functions.
1628 1629
1629 (defun font-lock-compile-keywords (keywords &optional regexp) 1630 (defun font-lock-compile-keywords (keywords &optional syntactic-keywords)
1630 "Compile KEYWORDS into the form (t KEYWORDS COMPILED...) 1631 "Compile KEYWORDS into the form (t KEYWORDS COMPILED...)
1631 Here each COMPILED is of the form (MATCHER HIGHLIGHT ...) as shown in the 1632 Here each COMPILED is of the form (MATCHER HIGHLIGHT ...) as shown in the
1632 `font-lock-keywords' doc string. 1633 `font-lock-keywords' doc string.
1633 If REGEXP is non-nil, it means these keywords are used for 1634 If SYNTACTIC-KEYWORDS is non-nil, it means these keywords are used for
1634 `font-lock-keywords' rather than for `font-lock-syntactic-keywords'." 1635 `font-lock-syntactic-keywords' rather than for `font-lock-keywords'."
1635 (if (not font-lock-set-defaults) 1636 (if (not font-lock-set-defaults)
1636 ;; This should never happen. But some external packages sometimes 1637 ;; This should never happen. But some external packages sometimes
1637 ;; call font-lock in unexpected and incorrect ways. It's important to 1638 ;; call font-lock in unexpected and incorrect ways. It's important to
1638 ;; stop processing at this point, otherwise we may end up changing the 1639 ;; stop processing at this point, otherwise we may end up changing the
1639 ;; global value of font-lock-keywords and break highlighting in many 1640 ;; global value of font-lock-keywords and break highlighting in many
1642 (if (eq (car-safe keywords) t) 1643 (if (eq (car-safe keywords) t)
1643 keywords 1644 keywords
1644 (setq keywords 1645 (setq keywords
1645 (cons t (cons keywords 1646 (cons t (cons keywords
1646 (mapcar 'font-lock-compile-keyword keywords)))) 1647 (mapcar 'font-lock-compile-keyword keywords))))
1647 (if (and regexp 1648 (if (and (not syntactic-keywords)
1648 (eq (or syntax-begin-function 1649 (eq (or syntax-begin-function
1649 font-lock-beginning-of-syntax-function) 1650 font-lock-beginning-of-syntax-function)
1650 'beginning-of-defun) 1651 'beginning-of-defun)
1651 (not beginning-of-defun-function)) 1652 (not beginning-of-defun-function))
1652 ;; Try to detect when a string or comment contains something that 1653 ;; Try to detect when a string or comment contains something that
1772 (when removed-keywords 1773 (when removed-keywords
1773 (font-lock-remove-keywords nil removed-keywords)) 1774 (font-lock-remove-keywords nil removed-keywords))
1774 ;; Now compile the keywords. 1775 ;; Now compile the keywords.
1775 (unless (eq (car font-lock-keywords) t) 1776 (unless (eq (car font-lock-keywords) t)
1776 (setq font-lock-keywords 1777 (setq font-lock-keywords
1777 (font-lock-compile-keywords font-lock-keywords t)))))) 1778 (font-lock-compile-keywords font-lock-keywords))))))
1778 1779
1779 ;;; Colour etc. support. 1780 ;;; Colour etc. support.
1780 1781
1781 ;; Note that `defface' will not overwrite any faces declared above via 1782 ;; Note that `defface' will not overwrite any faces declared above via
1782 ;; `custom-declare-face'. 1783 ;; `custom-declare-face'.