From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Shiyuan Newsgroups: gmane.emacs.help Subject: font lock Date: Tue, 11 Mar 2014 12:32:51 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1394566381 12051 80.91.229.3 (11 Mar 2014 19:33:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Mar 2014 19:33:01 +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:33:10 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 1WNSQD-00064n-Ef for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Mar 2014 20:33:05 +0100 Original-Received: from localhost ([::1]:57077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSQD-0008FB-0c for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Mar 2014 15:33:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSQ2-0008F3-WF for help-gnu-emacs@gnu.org; Tue, 11 Mar 2014 15:32:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNSQ2-00034B-3G for help-gnu-emacs@gnu.org; Tue, 11 Mar 2014 15:32:54 -0400 Original-Received: from mail-vc0-x22f.google.com ([2607:f8b0:400c:c03::22f]:63437) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSQ1-00033y-VR for help-gnu-emacs@gnu.org; Tue, 11 Mar 2014 15:32:54 -0400 Original-Received: by mail-vc0-f175.google.com with SMTP id lh14so6984616vcb.6 for ; Tue, 11 Mar 2014 12:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ZHsnWeRgjeA+05a4BBAjzZgjdYs4hqvixeyeRGD3Kro=; b=IULkGVRqPFu3TlMKB9twXVIadu/1rYZG8fbyLxi06obOSLYZNT2w/5S/TOVk4ew/cP If0kf0TdrIatkNQGMQZemP7VpoohQcRmKj0RRLvjQIZIhQduaMwmr/vVd6xjbxaPMClJ uk9aqtKuwYa3f3HKZ9Sy60zUnUTxfzsz9xBPd73UoTXrrSFlNAzoU8obk1mUzTr7Ht9S VRozmJ1h9Zk1/lB8a0r0J6+l7nH4Ys7pyGiQFTi02ordhyr2snCAe/Sd++Ha9mXh4gbs 1e2Y9FuqiKzj9d3OxbwQlwsL09Hrsu5c72zi0+ObzATlfZ/LKqUBdh3qko4lxew4nqpD TRUw== X-Received: by 10.58.57.42 with SMTP id f10mr17342198veq.1.1394566371587; Tue, 11 Mar 2014 12:32:51 -0700 (PDT) Original-Received: by 10.59.6.3 with HTTP; Tue, 11 Mar 2014 12:32:51 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c03::22f 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:96431 Archived-At: 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.