unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Ian Zimmerman <nobrowser@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Syntax highlight (problem with 'concat)
Date: Mon, 02 Jan 2006 19:43:39 -0800 (PST)	[thread overview]
Message-ID: <871wzq2cye.fsf@gmail.com> (raw)
In-Reply-To: <20060103033426.GA1812@johnsons-web.com>


Tim> Hello:
Tim> I'm attempting to create a derived mode for lisp using the example
Tim> from this URL:
Tim> http://www.emacswiki.org/cgi-bin/wiki/DerivedMode

Tim> ;; Note the line in the code below where I use the 'concat form
Tim> ;; This line does not provide the syntax highlighting that I desire.
Tim> ;;  However, the line above with the literal regexp string *does*
Tim> ;; highlight correctly
Tim> ;; Any hints on how to correct the usage of the 'concat form will
Tim> ;; be greatly appreciated.
Tim> (define-derived-mode tj-lisp-mode lisp-mode "tj-lisp"
Tim> "Major Mode for extending standard lisp mode"
Tim> (defconst tj-lisp-user-keywords (regexp-opt '("print" "setq")))
Tim> (defconst tj-word-begin "\\b\\(")
Tim> (defconst tj-word-end "\\)\\b")
Tim> ;;register keywords
Tim> (setq tj-lisp-font-lock-keywords
Tim> (list '("\\b\\(if\\|progn\\)\\b" .  font-lock-loop-face)
Tim> '("\\b\\(print\\|setq\\)\\b" .  font-lock-user-keyword-face)   ;; good, line below is bad
Tim> ;'((concat tj-word-begin tj-lisp-user-keywords tj-word-end) . font-lock-user-keyword-face)
Tim> ))
Tim> (font-lock-mode))
Tim> ;; TIA
Tim> tj

The quote around the last item in the list applies to _everything_ inside.
So your concat call never actually happens.  What you want is something like

...

(cons (concat tj-word-begin tj-lisp-user-keywords tj-word-end) 'font-lock-user-keyword-face)
...


or use quasi-quotes (see Elisp manual)

-- 
A true pessimist won't be discouraged by a little success.

  reply	other threads:[~2006-01-03  3:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-03  3:34 Syntax highlight (problem with 'concat) Tim Johnson
2006-01-03  3:43 ` Ian Zimmerman [this message]
2006-01-03  3:59   ` Tim Johnson
2006-01-03 18:09     ` Kevin Rodgers

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=871wzq2cye.fsf@gmail.com \
    --to=nobrowser@gmail.com \
    --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).