From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: font-lock basics? Date: Mon, 31 Jan 2005 11:29:52 -0500 Message-ID: <87k6pt36zo.fsf-monnier+emacs@gnu.org> References: <87mzupwwix.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1107191363 7853 80.91.229.6 (31 Jan 2005 17:09:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2005 17:09:23 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 31 18:09:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Cveq7-0003aG-00 for ; Mon, 31 Jan 2005 17:55:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cvf2r-0001BA-7m for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2005 12:09:01 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cvf28-0000qx-BX for emacs-devel@gnu.org; Mon, 31 Jan 2005 12:08:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cvf26-0000q1-5x for emacs-devel@gnu.org; Mon, 31 Jan 2005 12:08:15 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cveve-0007Cn-Iw for emacs-devel@gnu.org; Mon, 31 Jan 2005 12:01:34 -0500 Original-Received: from [209.226.175.25] (helo=tomts5-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CveR1-00070v-34 for emacs-devel@gnu.org; Mon, 31 Jan 2005 11:29:55 -0500 Original-Received: from alfajor ([67.71.119.71]) by tomts5-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050131162954.FKID2026.tomts5-srv.bellnexxia.net@alfajor>; Mon, 31 Jan 2005 11:29:54 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id C0F4E2FD49; Mon, 31 Jan 2005 11:29:52 -0500 (EST) Original-To: Francis Litterio In-Reply-To: (Francis Litterio's message of "Mon, 31 Jan 2005 10:43:12 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:32675 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32675 >>> (progn >>> (font-lock-mode -1) >>> (kill-all-local-variables) >>> (font-lock-add-keywords nil '(("high" . font-lock-keyword-face))) >>> (font-lock-mode t)) >> >> Try to set font-lock-defaults instead. > That begs the question: What is wrong with the above code? According to > the docstrings for the functions called above, it should work. Why > doesn't it? Actually the docstrings are sufficiently vague that it's not clear whether it should work or not. In any case one of the problems is that font-lock-add-keywords is meant to add to a *preexisting* list of keywords. So the above only makes sense if the font-lock-add-keywords is called from some minor mode which simply assumes that the major mode has setup font-lock-defaults. And even that doesn't work so well because the minor mode has no control over font-lock-case-fold-search. Maybe the patch below papers over this particular manifestation of the more general problem. Miles, what is the context of your question? Stefan Index: font-core.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/font-core.el,v retrieving revision 1.23 diff -u -u -b -r1.23 font-core.el --- font-core.el 1 Sep 2003 15:45:12 -0000 1.23 +++ font-core.el 31 Jan 2005 16:24:56 -0000 @@ -1,7 +1,7 @@ ;;; font-core.el --- Core interface to font-lock -;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 02, 2003 -;; Free Software Foundation, Inc. +;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +;; 2002, 2003, 2005 Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: languages, faces @@ -202,6 +202,7 @@ ;; Only do hard work if the mode has specified stuff in ;; `font-lock-defaults'. (when (or font-lock-defaults + (and (boundp 'font-lock-keywords) font-lock-keywords) (cdr (assq major-mode font-lock-defaults-alist))) (font-lock-mode-internal mode))) @@ -295,6 +296,5 @@ (provide 'font-core) +;; arch-tag: f8c286e1-02f7-41d9-b89b-1b67780aed71 ;;; font-core.el ends here - -;;; arch-tag: f8c286e1-02f7-41d9-b89b-1b67780aed71