changeset 4393:f6c39b2d8b62

Make font-lock-{add,remove}-keywords actually work. 2008-01-14 Jerry James <james@xemacs.org> * font-lock.el (font-lock-add-keywords): Adapt to differences in Emacs and XEmacs compiled font-lock lists. * font-lock.el (font-lock-remove-keywords): Ditto. * font-lock.el (font-lock-set-defaults-1): Make changes specified by font-lock-keywords-alist and font-lock-removed-keywords-alist.
author Jerry James <james@xemacs.org>
date Mon, 14 Jan 2008 16:50:32 -0700
parents e8f448f997ac
children b03b5e362fcf
files lisp/ChangeLog lisp/font-lock.el
diffstat 2 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Jan 14 15:25:22 2008 +0100
+++ b/lisp/ChangeLog	Mon Jan 14 16:50:32 2008 -0700
@@ -1,3 +1,11 @@
+2008-01-14  Jerry James  <james@xemacs.org>
+
+	* font-lock.el (font-lock-add-keywords): Adapt to differences in
+	Emacs and XEmacs compiled font-lock lists.
+	* font-lock.el (font-lock-remove-keywords): Ditto.
+	* font-lock.el (font-lock-set-defaults-1): Make changes specified
+	by font-lock-keywords-alist and font-lock-removed-keywords-alist.
+
 2008-01-14  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* bytecomp.el (byte-compile-output-file-form): 
--- a/lisp/font-lock.el	Mon Jan 14 15:25:22 2008 +0100
+++ b/lisp/font-lock.el	Mon Jan 14 16:50:32 2008 -0700
@@ -959,7 +959,7 @@
 	 (let ((was-compiled (eq (car font-lock-keywords) t)))
 	   ;; Bring back the user-level (uncompiled) keywords.
 	   (if was-compiled
-	       (setq font-lock-keywords (cadr font-lock-keywords)))
+	       (setq font-lock-keywords (cdr font-lock-keywords)))
 	   ;; Now modify or replace them.
 	   (if (eq how 'set)
 	       (setq font-lock-keywords keywords)
@@ -1069,7 +1069,7 @@
 	 (let ((was-compiled (eq (car font-lock-keywords) t)))
 	   ;; Bring back the user-level (uncompiled) keywords.
 	   (if was-compiled
-	       (setq font-lock-keywords (cadr font-lock-keywords)))
+	       (setq font-lock-keywords (cdr font-lock-keywords)))
 
 	   ;; Edit them.
 	   (setq font-lock-keywords (copy-sequence font-lock-keywords))
@@ -2031,7 +2031,10 @@
 			     font-lock-defaults
 			     (font-lock-find-font-lock-defaults major-mode)))
 	       (keywords (font-lock-choose-keywords
-			  (nth 0 defaults) font-lock-maximum-decoration)))
+			  (nth 0 defaults) font-lock-maximum-decoration))
+	       (local (cdr (assq major-mode font-lock-keywords-alist)))
+	       (removed-keywords
+		(cdr-safe (assq major-mode font-lock-removed-keywords-alist))))
 
 	  ;; Keywords?
 	  (setq font-lock-keywords (if (fboundp keywords)
@@ -2096,7 +2099,14 @@
 		 ;; older way:
 		 ;; defaults not specified at all, so use `beginning-of-defun'.
 		 (setq font-lock-beginning-of-syntax-function
-		       'beginning-of-defun)))))
+		       'beginning-of-defun)))
+
+	  ;; Local fontification?
+	  (while local
+	    (font-lock-add-keywords nil (car (car local)) (cdr (car local)))
+	    (setq local (cdr local)))
+	  (when removed-keywords
+	    (font-lock-remove-keywords nil removed-keywords))))
 
     (setq font-lock-cache-position (make-marker))
     (setq font-lock-defaults-computed t)))