Hi there,
In Common Lisp, you can put a #+NIL in front of an expression, to
prevent the compiler from processing it; for example, the following
defines a list of 3 elements:
(list 1 2 3)
The following defines a list of 2 elements (the `3` is swallowed):
(list 1 2 #+nil 3)
While this one...does nothing:
#+nil (list 1 2 3)
So I wanted to highlight all the `#+nil (...)` patterns as if they were
comments, and to do so I started with something as simle as:
syntax match lispExcludedForm /\v\#\+nil \([^)]+\)/
highlight link lispExcludedForm lispComment
I knew that this was not going to work in case of nested parentheses,
and after taking a look at the default syntax file for Lisp, I came up
with the following:
syntax region lispExcludedFormWithNil
\ matchgroup=lispExcludedContentStart
\ start="#+nil ("
\ skip="|.\{-}|"
\ matchgroup=lispExcludedContentStop
\ end=")"
\ contains=@lispBaseListCluster
highlight link lispExcludedContentStart lispComment
highlight link lispExcludedContentStop lispComment
With this I was able to deal with nested parentheses just fine; however,
if I had highlight commands defined for any of the elements contained
inside the `@lispBaseListCluster` cluster, Vim would still end up
coloring those elements while I want the whole region to look like a
`lispComment` instead -- and this is where I got stuck.
So, for the brave ones that made it this far:
- Can I define highlight commands that not only take specific elements
into account (i.e. `lispList`), but also their parents (i.e.
`lispExcludedFormWithNil > lispList`) -- this way I could link
`lispList` to `lispComment` only when contained inside
`lispExcludedFormWithNil`
- If not, should I have to create my own `@lispBaseListExcludedCluster`
cluster, and make sure no highlight command is defined for any of its
elements?
- In which case, can I programmatically iterate through all the elements
of a syntax cluster, and maybe create copies of it?
And last but not least: is what I am trying to achieve, even possible?
Am I on the right track?
Thanks in advance!
--
Matteo Landi
https://matteolandi.net
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/YYP56rkdqqoOX51t%40hairstyle.local.
No comments:
Post a Comment