all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* font-lock and regexp-opt
@ 2005-09-10 19:20 Mads Jensen
  2005-09-11 21:54 ` Stefan Monnier
  2005-09-13  2:28 ` August Karlstrom
  0 siblings, 2 replies; 4+ messages in thread
From: Mads Jensen @ 2005-09-10 19:20 UTC (permalink / raw)


Hi NG,

I am trying to write my first major mode, where I'd like to use
font-lock-mode to colorize some words. I browsed some code, and saw that
people are using regexp-opt for this, so I went with this approach,
too. Therefore, I have:

(defconst inducks-keywords 
  (regexp-opt '(...) t) "inducks fields to colorize")

And wrote the following:

(defconst inducks-font-heroes
  (list 
   (cons 
    (concat "\\<\\(" inducks-keywords "\\)\\>")
    'inducks-keyword)))

Is this a good way to do it ? It doesn't compile. I posted the entire
file here: http://mads.har-talt.dk/inducks.el (I am concentrating on
writing the font-lock part at the moment)

I am a total newbie in Emacs Lisp, but prefer trying to write something
useful instead of doing a lot of exercises. Naturally I read
documentation and tutorials, too.
--
Mads Jensen - mail sent to address ends in /dev/null
              s/spam/madsj for emailing me 
              gpg: 7E775BDA

It is impossible to make anything foolproof because fools are so
ingenious.

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

* Re: font-lock and regexp-opt
  2005-09-10 19:20 font-lock and regexp-opt Mads Jensen
@ 2005-09-11 21:54 ` Stefan Monnier
  2005-09-15 19:02   ` Mads Jensen
  2005-09-13  2:28 ` August Karlstrom
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2005-09-11 21:54 UTC (permalink / raw)


> (defconst inducks-keywords 
>   (regexp-opt '(...) t) "inducks fields to colorize")

> (defconst inducks-font-heroes
>   (list 
>    (cons 
>     (concat "\\<\\(" inducks-keywords "\\)\\>")
>     'inducks-keyword)))

> Is this a good way to do it ?

Looks OK to me.

> It doesn't compile.

Care to give us more info as to *how* it fails to compile?


        Stefan

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

* Re: font-lock and regexp-opt
  2005-09-10 19:20 font-lock and regexp-opt Mads Jensen
  2005-09-11 21:54 ` Stefan Monnier
@ 2005-09-13  2:28 ` August Karlstrom
  1 sibling, 0 replies; 4+ messages in thread
From: August Karlstrom @ 2005-09-13  2:28 UTC (permalink / raw)


Mads Jensen wrote:
> I am trying to write my first major mode, where I'd like to use
> font-lock-mode to colorize some words. I browsed some code, and saw that
> people are using regexp-opt for this, so I went with this approach,
> too. Therefore, I have:
> 
> (defconst inducks-keywords 
>   (regexp-opt '(...) t) "inducks fields to colorize")

(regexp-opt '(...) 'words) is even better.

> And wrote the following:
> 
> (defconst inducks-font-heroes
>   (list 
>    (cons 
>     (concat "\\<\\(" inducks-keywords "\\)\\>")
>     'inducks-keyword)))
> 
> Is this a good way to do it ? It doesn't compile. 

How does the compilation fail. Which version of Emacs are you using and 
on what operating system? Have you `M-x h f regexp-opt' etc.


August

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

* Re: font-lock and regexp-opt
  2005-09-11 21:54 ` Stefan Monnier
@ 2005-09-15 19:02   ` Mads Jensen
  0 siblings, 0 replies; 4+ messages in thread
From: Mads Jensen @ 2005-09-15 19:02 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Looks OK to me.
OK.
> Care to give us more info as to *how* it fails to compile?

I hacked a little bit more on the mode yesterday and today and added
some more stuff; I updated the file where compilation errors can be
found. 

Thanks for the help so far, both of you!
-- 
Mads Jensen - mail sent to address ends in /dev/null
              s/spam/madsj for emailing me 
              gpg: 7E775BDA

It is impossible to make anything foolproof because fools are so
ingenious.

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

end of thread, other threads:[~2005-09-15 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-10 19:20 font-lock and regexp-opt Mads Jensen
2005-09-11 21:54 ` Stefan Monnier
2005-09-15 19:02   ` Mads Jensen
2005-09-13  2:28 ` August Karlstrom

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.