[21.4] Adapt to differences in compiled font-lock lists
Jerry James <[email protected]> Wed, 24 Sep 2014 09:43:01 -0600
| Newsgroups | gmane.emacs.xemacs.patches |
|---|---|
| Message-ID | <CAHCOHQkb+kGt7gKgb3-qzsNHdnd4BOpu1dq01B1kCjcsVb_FHw@mail.gmail.com> |
RECOMMEND 21.4 This is the patch we discussed a few weeks ago. It was applied to 21.5 back in 2008. This patch adapts some code in font-lock.el to differences between the Emacs and XEmacs compiled font-lock lists. Aidan hasn't reappeared, so I don't know which font-lock.el comments he found confusing. Therefore, I am submitting this patch in the same form it had when applied to 21.5 diff -r af4d0249573a lisp/ChangeLog --- a/lisp/ChangeLog Thu Apr 18 23:05:34 2013 -0400 +++ b/lisp/ChangeLog Wed Sep 24 09:40:01 2014 -0600 @@ -1,3 +1,11 @@ +2014-09-24 Jerry James <[email protected]> + + * font-lock.el (font-lock-add-keywords): Adapt to differences in + Emacs and XEmacs compiled font-lock lists. + (font-lock-remove-keywords): Ditto. + (font-lock-set-defaults-1): Make changes specified by + font-lock-keywords-alist and font-lock-removed-keywords-alist. + 2012-01-08 Vin Shelton <[email protected]> * cus-face.el: autoload custom-set-face-bold. diff -r af4d0249573a lisp/font-lock.el --- a/lisp/font-lock.el Thu Apr 18 23:05:34 2013 -0400 +++ b/lisp/font-lock.el Wed Sep 24 09:40:01 2014 -0600 @@ -951,7 +951,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) @@ -1061,7 +1061,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)) @@ -2032,7 +2032,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) @@ -2097,7 +2100,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))) -- Jerry James http://www.jamezone.org/