unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stuart D. Herring" <herring@lanl.gov>
Cc: cmake@cmake.org, emacs-devel@gnu.org
Subject: Re: cmake emacs mode
Date: Wed, 26 Apr 2006 08:17:39 -0700 (PDT)	[thread overview]
Message-ID: <56450.128.165.123.132.1146064659.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <6.2.0.14.2.20060425222650.08bc97d0@pop.biz.rr.com>

> ; 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 cmake@cmake.org or kitware@kitware.com
> ; 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	other threads:[~2006-04-26 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-26  2:31 cmake emacs mode William A. Hoffman
2006-04-26 15:17 ` Stuart D. Herring [this message]
2006-04-26 21:01   ` Miles Bader

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=56450.128.165.123.132.1146064659.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=cmake@cmake.org \
    --cc=emacs-devel@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.
Code repositories for project(s) associated with this public inbox

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

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