Thanks, Jerry! I will try your patch when I get some downtime. -John
Jerry James wrote:
Hi John,
On Jan 7, 2008 8:56 AM, John Kuhns <john(a)designadvance.com> wrote:
> Hi XEmacs team -
>
> So I installed xemacs 21.4.21 today and tried out the new
> font-lock-add-keywords method. But, for some reason it's still not
> working for me. Is there something I need to set to get it working?
>
> Here's what I tried:
> (add-hook 'lisp-mode-hook
> (lambda () (font-lock-add-keywords 'lisp-mode
> '(("\\<\\(then\\|else\\|@key\\|@optional\\)\\>" .
> font-lock-keyword-face)))))
>
> Which I want to result in highlighting standalone keywords. For example,
> @key should be hightlighted in this line:
> (defun foo (arg1 @key arg2) ... )
>
It looks like you are the victim of an incomplete sync with Emacs.
The code to use the values passed to font-lock-add-keywords was never
put into XEmacs. In short, font-lock-add-keywords does not do
anything useful in any released version of XEmacs.
If you can compile your own XEmacs, try the patch below, which fixes
the problem for me. Also, you should change your code above in one of
two ways. First, use add-one-shot-hook instead of add-hook, or you'll
keep adding the same expression to the font-lock keywords for Lisp
every time you open a Lisp file. Second, don't use a hook at all:
just make the (font-lock-add-keywords ...) call in your
.xemacs/init.el file.
Finally, it appears that "\\<@" doesn't match " @". I
don't know why
(probably something to do with @ not being a word character), or
whether that is correct, but a workaround is to change your regexp
like this:
(font-lock-add-keywords 'lisp-mode
'(("\\(\\<then\\|\\<else\\|@key\\|@optional\\)\\>" .
font-lock-keyword-face)))
diff -r e8f448f997ac lisp/font-lock.el
--- a/lisp/font-lock.el Mon Jan 14 15:25:22 2008 +0100
+++ b/lisp/font-lock.el Mon Jan 14 12:55:39 2008 -0700
@@ -959,7 +959,7 @@ see the variables `c-font-lock-extra-typ
(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 @@ happens, so the major mode can be correc
(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 @@ Each keyword has the form (MATCHER HIGHL
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 @@ Each keyword has the form (MATCHER HIGHL
;; 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)))
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta