From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Francis Litterio Newsgroups: gmane.emacs.devel Subject: Re: font-lock basics? Date: Mon, 31 Jan 2005 11:14:22 -0500 Message-ID: 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 1107188691 30158 80.91.229.6 (31 Jan 2005 16:24:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2005 16:24:51 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 31 17:24:38 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 1CveLu-0008Cf-00 for ; Mon, 31 Jan 2005 17:24:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CveYd-0008BR-Ny for ged-emacs-devel@m.gmane.org; Mon, 31 Jan 2005 11:37:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CveYM-00084p-Iv for emacs-devel@gnu.org; Mon, 31 Jan 2005 11:37:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CveYK-00083q-Br for emacs-devel@gnu.org; Mon, 31 Jan 2005 11:37:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CveYK-00083n-8d for emacs-devel@gnu.org; Mon, 31 Jan 2005 11:37:28 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CveKh-0006Lt-6d for emacs-devel@gnu.org; Mon, 31 Jan 2005 11:23:23 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1CveKO-0002TI-P8 for emacs-devel@gnu.org; Mon, 31 Jan 2005 17:23:04 +0100 Original-Received: from brick.estc.com ([209.27.151.2]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 31 Jan 2005 17:23:04 +0100 Original-Received: from franl by brick.estc.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 31 Jan 2005 17:23:04 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 50 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: brick.estc.com X-Draft-From: ("nntp+news.gmane.org:gmane.emacs.devel" 32670) Gcc: nnfolder:sent-usenet X-Random-Quote: It is not the man who has too little, but the man who craves more, that is poor. -- Seneca (5 BC - 65), Epistles User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:2HttPv3Zl4iCqY6AYS7WA0eGYDw= X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner: Found to be clean X-MailScanner-From: ged-emacs-devel@m.gmane.org 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:32673 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32673 I wrote: > Stefan Monnier wrote: > >>> (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? I think this code in function font-lock-default-function is preventing the fontification from happening: ;; Only do hard work if the mode has specified stuff in ;; `font-lock-defaults'. (when (or font-lock-defaults (cdr (assq major-mode font-lock-defaults-alist))) (font-lock-mode-internal mode))) In a newly-created fundamental-mode buffer, font-lock-defaults is nil if the user has not explicitly assigned it a value (and the font-lock documentation does not state that one _must_ set font-lock-defaults for font-lock-mode to work). This patch to font-core.el fixes the problem: --- font-core.el 01 Sep 2003 11:45:12 -0400 1.23 +++ font-core.el 31 Jan 2005 11:18:03 -0500 @@ -200,8 +200,10 @@ (delq elt char-property-alias-alist)))))) ;; Only do hard work if the mode has specified stuff in - ;; `font-lock-defaults'. + ;; `font-lock-defaults' or if `font-lock-keywords' is non-nil + ;; in this buffer. (when (or font-lock-defaults + font-lock-keywords (cdr (assq major-mode font-lock-defaults-alist))) (font-lock-mode-internal mode))) I hope this helps. -- Francis Litterio franl world . std . com