From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Newbie Help with creating a major-mode for syntax hilighting Date: Wed, 29 Apr 2009 19:33:43 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6a2dc813-e6c7-46e7-9c8b-a7484393e030@j9g2000prh.googlegroups.com> References: 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 1241064927 20443 80.91.229.12 (30 Apr 2009 04:15:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Apr 2009 04:15:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 30 06:15:18 2009 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 1LzNg4-0008PJ-0x for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Apr 2009 06:15:16 +0200 Original-Received: from localhost ([127.0.0.1]:44479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LzNg3-0000ZR-AF for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Apr 2009 00:15:15 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!j9g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 79 Original-NNTP-Posting-Host: 24.6.175.142 Original-X-Trace: posting.google.com 1241058824 20947 127.0.0.1 (30 Apr 2009 02:33:44 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 30 Apr 2009 02:33:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j9g2000prh.googlegroups.com; posting-host=24.6.175.142; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:168846 X-Mailman-Approved-At: Thu, 30 Apr 2009 00:14:52 -0400 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:64119 Archived-At: On Apr 29, 11:55 am, "carlos....@ieee.org" wrote: > I am following theXahLee'sexample bellow to create my own major mode for = syntax coloring. > > http://xahlee.org/emacs/elisp_syntax_coloring.html > > My goal is to highlight all lines that begin with "E | ...." > > so following the example I add the following to my .emacs file > > '(("Sin\\|Cos\\|Sum" . font-lock-function-name-face) > ("Pi\\|Infinity" . font-lock-constant-face) > ) > > ;; I tested the following regular expression using search-forward-regex > (setq nlDataKeywords > '(("^E +| +*$" )) . font-lock-warning-face) > ) > ) > > (define-derived-mode nl-data-mode fundamental-mode > (setq font-lock-defautls '(nlDataKeywords) > ) > ) > > The .emacs file loads without errors, but when I set the mode to nl-data-= mode I get the following error in the mini-buffer: > > Only strings should be stored in the buffer-local variable mode-name. > > I tried moving the changes to my ~/.emacs.el fiel and loading that with t= he same result. I tried using regexp-quote function, all with the same erro= rs > > (setq nlDataKeywords > '( > ( ,(regexp-quote '("^E +| +*$" )) . font-lock-warning-face) > ) > ) > > (define-derived-mode nl-data-mode fundamental-mode > (setq font-lock-defautls '(nlDataKeywords) > ) > ) > > Can someone knowledgeable on the mail list help me out? > > Thanks and best regards, > > Carlos Hi Carlos, Thanks for checking out my tutorial. There are few errors in your code. =E2=80=A2 font-lock-defaults is spelled wrong. =E2=80=A2 the paren nesting structure is wrong in your (setq nlDataKeywords ...) here's the code you might want: (setq nlDataKeywords '( ("^E +| *.+$" . font-lock-warning-face) ) ) (define-derived-mode nl-data-mode fundamental-mode (setq font-lock-defaults '(nlDataKeywords) ) ) If you turn on the mode, the following line will be highlighted. E | something ... Xah =E2=88=91 http://xahlee.org/ =E2=98=84