From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Shiyuan Newsgroups: gmane.emacs.help Subject: Re: font lock Date: Tue, 11 Mar 2014 12:44:34 -0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1394567079 20844 80.91.229.3 (11 Mar 2014 19:44:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Mar 2014 19:44:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 11 20:44:49 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WNSbZ-0005gw-3q for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Mar 2014 20:44:49 +0100 Original-Received: from localhost ([::1]:57111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSbY-00061y-By for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Mar 2014 15:44:48 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSbN-00061s-0u for help-gnu-emacs@gnu.org; Tue, 11 Mar 2014 15:44:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNSbL-0007ng-2Y for help-gnu-emacs@gnu.org; Tue, 11 Mar 2014 15:44:36 -0400 Original-Received: from mail-ve0-x22c.google.com ([2607:f8b0:400c:c01::22c]:57304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSbK-0007nX-Tp for help-gnu-emacs@gnu.org; Tue, 11 Mar 2014 15:44:34 -0400 Original-Received: by mail-ve0-f172.google.com with SMTP id jx11so9198733veb.31 for ; Tue, 11 Mar 2014 12:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=T0ptrKgSvfJS76isXpNgc1n5tkJ6TmVPaf0nn0Vwug0=; b=qSFyY5naBEVICfRTx0fwbxtnrhYZTA5r2OTZnWS5FZ8MweusVRTv1i7gYiCa39/lZe 0syfmyxsJ68cUDm/tf6WNwvSsko2VR5p8kMxtqvizvgYeIu3T9sDx8P7E/DrcbDCWnEM dvi0Lg7Pr4WYxX23L+vc45idzbghUJ/IfCjeHfbgcHWaNIvviCEcY4vO6wsGxfMWfUWl xQRoCj0/jnsftSsqBD75M/E0Fm4AAjX/wj4wC/uBVlNExHQPVmYCjwbAU2zt9vk3cVpw 4ADnTKw9dAE7vg6UQEOTUmYaO7uCmLdHHplRW/IMhbD85qLTHDpsZqjPUmmBhVY94f/k ayQQ== X-Received: by 10.220.147.16 with SMTP id j16mr1980531vcv.28.1394567074165; Tue, 11 Mar 2014 12:44:34 -0700 (PDT) Original-Received: by 10.59.6.3 with HTTP; Tue, 11 Mar 2014 12:44:34 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::22c X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96432 Archived-At: I found the answers. Taking out the 't' in the list will make the keywords not to be highlighted in the comments. Also the variable font-lock-keywords seems to contains the complete keywords highlighting list. Thanks. On Tue, Mar 11, 2014 at 12:32 PM, Shiyuan wrote: > Hi all, > I want to write a major mode which is derived from c++-mode. I need > to add keywords for color highlighting. It works but I don't want to the > keyword to be highlighted if the keyword is in the comments. How can I do > that? According to the Elisp manual, It seems doable by changing the > number in the font-lock-add-keywords, however I couldn't find the > documentation. I tried 0 and 1 but neither works. > > (define-derived-mode my-mode c++-mode "MY-MODE" > "Major mode for editing XXX files") > > (add-hook 'ion-mode-hook > (lambda() > (font-lock-add-keywords nil > '(("\\<\\(\\(?:null\\| decimal \\| list\\)\\)\\>" 1 'font-lock-type-face t) > ("\\<\\(define\\|override\\|exist\\|andp\\|and\\|or\\|not\\|if\\)\\>" > 1 'font-lock-keyword-face t))))) > (provide 'ion-mode) > > Also, Is there a variable which holds the complete list of the > keyword--face pairs for highlighting? The variable font-lock-defaults seems > not complete---the new keywords I added using the code below is not shown > in the value of font-lock-defaults. > > Thanks. > > >