unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Newbie Help with creating a major-mode for syntax hilighting
@ 2009-04-29 18:55 carlos.lin@ieee.org
  0 siblings, 0 replies; 2+ messages in thread
From: carlos.lin@ieee.org @ 2009-04-29 18:55 UTC (permalink / raw)
  To: help-gnu-emacs


I am following the Xah Lee's example 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



      




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Newbie Help with creating a major-mode for syntax hilighting
       [not found] <mailman.6282.1241044806.31690.help-gnu-emacs@gnu.org>
@ 2009-04-30  2:33 ` Xah Lee
  0 siblings, 0 replies; 2+ messages in thread
From: Xah Lee @ 2009-04-30  2:33 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-30  2:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6282.1241044806.31690.help-gnu-emacs@gnu.org>
2009-04-30  2:33 ` Newbie Help with creating a major-mode for syntax hilighting Xah Lee
2009-04-29 18:55 carlos.lin@ieee.org

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).