unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Dmitry Dzhus <dima@sphinx.net.ru>
To: help-gnu-emacs@gnu.org
Subject: Re: Evaluating a 'variable' in a nested list
Date: Wed, 21 Apr 2010 23:16:55 +0400	[thread overview]
Message-ID: <87bpdcfwew.fsf@sphinx.net.ru> (raw)
In-Reply-To: slrnhssll0.3ir.tim@bart.johnson.com

Tim Johnson wrote:

> When I load a scheme file, syntax highlight fails and I get the 
> following error message:
> """
> Error during redisplay: (void-function scheme-user-keywords-regexp)
> """
> I believe that I have coded the following form:
> '((scheme-user-keywords-regexp 1 scheme-font-lock-user-keywords-face t))
> Incorrectly, so that 'scheme-user-keywords-regexp is being treated 
> as a function when the hook is run.

By reading docs for `font-lock-add-keywords` function and
`font-lock-keywords`, you may find out that each element of keywords
list starts from either regexp or name of function to be called to match
string for highlighting. Since you've used the quote syntax,
`scheme-user-keywords` is added into the list of font lock rules as a
symbol and is then treated as a function name. You may use the
quasiquote syntax to evaluate just one element of list you use for
`font-lock-add-keywords`:

    (add-hook 'scheme-mode-hook
              (lambda ()
                (font-lock-add-keywords 
                 nil 
                 `((,scheme-user-keywords-regexp 0 scheme-font-lock-user-keywords-face t)))))

So *the value* of `scheme-user-keywords-regexp` gets into the list.

Note that since your matcher regular expression has no subexpressions,
you must use index 0 to highlight the whole matched string; instead, you
could've just used this:

    (add-hook 'scheme-mode-hook
              (lambda ()
                (font-lock-add-keywords 
                 nil 
                 `((,scheme-user-keywords-regexp . scheme-font-lock-user-keywords-face)))))
-- 
Happy Hacking.

http://sphinx.net.ru

  reply	other threads:[~2010-04-21 19:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21  1:44 Evaluating a 'variable' in a nested list Tim Johnson
2010-04-21 19:16 ` Dmitry Dzhus [this message]
2010-04-21 21:44   ` Tim Johnson

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=87bpdcfwew.fsf@sphinx.net.ru \
    --to=dima@sphinx.net.ru \
    --cc=help-gnu-emacs@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.
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).