emacs-devel
[Top][All Lists]
Advanced

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

Re: cmake emacs mode


From: Stuart D. Herring
Subject: Re: cmake emacs mode
Date: Wed, 26 Apr 2006 08:17:39 -0700 (PDT)
User-agent: SquirrelMail/1.4.3a-11.EL3

> ; TODO: If anyone knows how to match function names occurring before an
> ; open-paren and highlight them without also highlighting the
> ; open-paren, please contact address@hidden or address@hidden
> ; and tell us how to do it.  We would rather not have to include the
> ; entire list of CMake commands in this mode file, which is a pain to
> ; maintain.  Thanks.

There's several things here.  First, there's no reason you have to go
through the *scratch* nonsense.  Just put the big commented-out
`regexp-opt' call into the `defvar':

(defconst cmake-font-lock-defaults
  (list (cons (regexp-opt '("foo" "bar") 'words)
'font-lock-function-name-face))
  "Highlighting expressions for CMAKE mode.")

You then don't have to have the 3k output in the file, just the code in
the comment.

I also note that there's a syntax error that makes the doc string actually
be a part of the (list) form.  If you want to not force the load of
regexp-opt, you can use `eval-when-compile'; see regexp-opt.el for info. 
Moreover, later you do
(setq font-lock-defaults '(cmake-font-lock-defaults))
...which suggests to me that the variable should in fact be called
`cmake-font-lock-keywords' or so, not `...-defaults'.

Now, if you'd really rather get rid of the list altogether, as the comment
suggests, then you can use this as an element of the keywords list:
("\\(\\w+\\)(" 1 font-lock-function-name-face)
The trick is that the 1 says to highlight the first captured expression,
rather than the whole match, and the group doesn't contain the `('.

Moreover, this mode (aside from the indenting) looks to be extremely
simple; you might be able to get away with making it a derived major mode
(from Fundamental mode, probably; see `define-derived-mode') or even a
generic mode (see `define-generic-mode').  Might make it less trouble to
keep up with.

Hope it helps,
Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




reply via email to

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