[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax highlight (problem with 'concat)
From: |
Ian Zimmerman |
Subject: |
Re: Syntax highlight (problem with 'concat) |
Date: |
Mon, 02 Jan 2006 19:43:39 -0800 (PST) |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
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.