From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolaj Schumacher Newsgroups: gmane.emacs.help Subject: Re: problem understanding font-lock-defaults structure Date: Thu, 09 Oct 2008 19:16:37 +0200 Message-ID: References: <13173afe-f51c-4c67-b738-1949f2b28b5f@f40g2000pri.googlegroups.com> <296d3d40-598c-4ea4-8394-c69975c0399f@a3g2000prm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223572651 14146 80.91.229.12 (9 Oct 2008 17:17:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Oct 2008 17:17:31 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Xah Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 09 19:18:29 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Knz9a-0007vL-RX for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Oct 2008 19:18:23 +0200 Original-Received: from localhost ([127.0.0.1]:46230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Knz8W-0001ud-T7 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Oct 2008 13:17:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Knz8E-0001to-BN for help-gnu-emacs@gnu.org; Thu, 09 Oct 2008 13:16:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Knz8D-0001tN-7n for help-gnu-emacs@gnu.org; Thu, 09 Oct 2008 13:16:57 -0400 Original-Received: from [199.232.76.173] (port=48542 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Knz8D-0001tE-4F for help-gnu-emacs@gnu.org; Thu, 09 Oct 2008 13:16:57 -0400 Original-Received: from dd18200.kasserver.com ([85.13.138.168]:49746) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Knz8C-0003LG-Sv for help-gnu-emacs@gnu.org; Thu, 09 Oct 2008 13:16:57 -0400 Original-Received: from thursday (BAHa009.bah.pppool.de [77.135.160.9]) by dd18200.kasserver.com (Postfix) with ESMTP id 7DB0318074848; Thu, 9 Oct 2008 19:16:58 +0200 (CEST) In-Reply-To: <296d3d40-598c-4ea4-8394-c69975c0399f@a3g2000prm.googlegroups.com> (Xah's message of "Thu\, 9 Oct 2008 08\:29\:02 -0700 \(PDT\)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:58630 Archived-At: Xah wrote: > (setq myKeywordsLevel1 > (list > ("Sin\\|Cos" . font-lock-function-name-face) > ("=CF=80\\|=E2=88=9E" . font-lock-constant-face) > ("x\\|y" . font-lock-variable-name-face))) > > Are you sure? It gives (invalid-function "Sin\\|Cos"). You're right. (setq myKeywordsLevel1 (list (cons "Sin\\|Cos" font-lock-function-name-face) (cons "=CF=80\\|=E2=88=9E" font-lock-constant-face) (cons "x\\|y" font-lock-variable-name-face))) I was looking only at the "(quote" line. >> There's no need to use `, here. `font-lock-keywords' accepts symbols. >> (setq font-lock-keywords '((myKeywordsLevel1 nil nil))) > > after eval that form, than i looked at the value of font-lock-keywords > using describe-variable, it says: My bad, too. I meant `font-lock-defaults' -- the variable you were already using, and we were talking about. -keywords just crept in from finger memory. Here's a complete, working example: (setq myKeywordsLevel1 '(("Sin\\|Cos" . font-lock-function-name-face) ("=CF=80\\|=E2=88=9E" . font-lock-constant-face) ("x\\|y" . font-lock-variable-name-face))) (define-derived-mode foo-mode fundamental-mode (setq font-lock-defaults '(myKeywordsLevel1))) > Its value is > (t > (myKeywordsLevel1) > (myKeywordsLevel1 > (0 font-lock-keyword-face))) > > Local in buffer untitled<3>; > =C2=BB > > Where did all the extra came from? The list has been "compiled". The t marks it as such, so it isn't processed twice. Due to this kind of voodoo, I avoid touching `font-lock-keywords'. I use `font-lock-add-keywords'. regards, Nikolaj Schumacher