help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Help with creating a major-mode for syntax hilighting


From: Xah Lee
Subject: Re: Newbie Help with creating a major-mode for syntax hilighting
Date: Wed, 29 Apr 2009 19:33:43 -0700 (PDT)
User-agent: G2/1.0

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/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]