From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Newbie Help with creating a major-mode for syntax hilighting
Date: Wed, 29 Apr 2009 19:33:43 -0700 (PDT) [thread overview]
Message-ID: <6a2dc813-e6c7-46e7-9c8b-a7484393e030@j9g2000prh.googlegroups.com> (raw)
In-Reply-To: mailman.6282.1241044806.31690.help-gnu-emacs@gnu.org
On Apr 29, 11:55 am, "carlos....@ieee.org"
<kilimanj...@rocketmail.com> 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 the same result. I tried using regexp-quote function, all with the same errors
>
> (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.
• font-lock-defaults is spelled wrong.
• 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
∑ http://xahlee.org/
☄
next parent reply other threads:[~2009-04-30 2:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.6282.1241044806.31690.help-gnu-emacs@gnu.org>
2009-04-30 2:33 ` Xah Lee [this message]
2009-04-29 18:55 Newbie Help with creating a major-mode for syntax hilighting carlos.lin@ieee.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a2dc813-e6c7-46e7-9c8b-a7484393e030@j9g2000prh.googlegroups.com \
--to=xahlee@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).