* Syntax highlight (problem with 'concat)
@ 2006-01-03 3:34 Tim Johnson
2006-01-03 3:43 ` Ian Zimmerman
0 siblings, 1 reply; 4+ messages in thread
From: Tim Johnson @ 2006-01-03 3:34 UTC (permalink / raw)
Hello:
I'm attempting to create a derived mode for lisp using the example
from this URL:
http://www.emacswiki.org/cgi-bin/wiki/DerivedMode
;; Note the line in the code below where I use the 'concat form
;; This line does not provide the syntax highlighting that I desire.
;; However, the line above with the literal regexp string *does*
;; highlight correctly
;; Any hints on how to correct the usage of the 'concat form will
;; be greatly appreciated.
(define-derived-mode tj-lisp-mode lisp-mode "tj-lisp"
"Major Mode for extending standard lisp mode"
(defconst tj-lisp-user-keywords (regexp-opt '("print" "setq")))
(defconst tj-word-begin "\\b\\(")
(defconst tj-word-end "\\)\\b")
;;register keywords
(setq tj-lisp-font-lock-keywords
(list '("\\b\\(if\\|progn\\)\\b" . font-lock-loop-face)
'("\\b\\(print\\|setq\\)\\b" . font-lock-user-keyword-face) ;; good, line below is bad
;'((concat tj-word-begin tj-lisp-user-keywords tj-word-end) . font-lock-user-keyword-face)
))
(font-lock-mode))
;; TIA
tj
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Syntax highlight (problem with 'concat)
2006-01-03 3:34 Syntax highlight (problem with 'concat) Tim Johnson
@ 2006-01-03 3:43 ` Ian Zimmerman
2006-01-03 3:59 ` Tim Johnson
0 siblings, 1 reply; 4+ messages in thread
From: Ian Zimmerman @ 2006-01-03 3:43 UTC (permalink / raw)
Cc: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Syntax highlight (problem with 'concat)
2006-01-03 3:43 ` Ian Zimmerman
@ 2006-01-03 3:59 ` Tim Johnson
2006-01-03 18:09 ` Kevin Rodgers
0 siblings, 1 reply; 4+ messages in thread
From: Tim Johnson @ 2006-01-03 3:59 UTC (permalink / raw)
* Ian Zimmerman <nobrowser@gmail.com> [060102 18:51]:
> 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)
>
> 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
I suspected that ....
> ...
>
> (cons (concat tj-word-begin tj-lisp-user-keywords tj-word-end) 'font-lock-user-keyword-face)
Aha!
> ...
>
>
> or use quasi-quotes (see Elisp manual)
Okay, will bone up on that too...
Thank you Ian!
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Syntax highlight (problem with 'concat)
2006-01-03 3:59 ` Tim Johnson
@ 2006-01-03 18:09 ` Kevin Rodgers
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2006-01-03 18:09 UTC (permalink / raw)
Tim Johnson wrote:
> * Ian Zimmerman <nobrowser@gmail.com> [060102 18:51]:
>>or use quasi-quotes (see Elisp manual)
>
> Okay, will bone up on that too...
Good luck finding that: the correct term is "Backquote".
--
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-01-03 18:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-03 3:34 Syntax highlight (problem with 'concat) Tim Johnson
2006-01-03 3:43 ` Ian Zimmerman
2006-01-03 3:59 ` Tim Johnson
2006-01-03 18:09 ` Kevin Rodgers
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).