I occasionally like to tinker with syntax files (especially conceals; I use
λ for anonymous functions (
fn) in several languages).
However, one complaint with conceal is that I can only use a single character. When concealing, e.g.,
fn, having one character breaks some vertical alignment. One solution is to use
λ. instead, keeping the two characters and aligning with the lambda-calculus origins.
In at least two syntax files I use,
fn is part of a
syn-keyword definition. In order to use the
λ. above, I need to do something like this:
syn match group /fn\@=/ conceal cchar=λ syn match group /fn\@<=/ conceal cchar=.
syn-matchs have lower priority, so these don't apply. The original
syn keyword group fn conceal cchar=λ
works just fine, because it is a keyword defined later.
I would like to either
fnfrom a syntax keyword group, or
- override a keyword from a match
One possible solution is
syn clear group " re-add everything else " syn keyword group ...
But this fails when
group has more than just keywords and is very complex. It's also not scalable at all.
I'm open to some kind of meta-programming/parsing the output of
syn list, but it needs to be quasi-readable/understandable.
Here's a clojure example:
; should be concealed? fn [x] ; definitely should be (fn [x] x) ; definitely should be ( fn [x]) ; shouldn't be, though my current keyword solution would (let [fn 1] fn) ; same (let [ fn 1] fn) ; definitely shouldn't be (let [afn 1] afn)
And here's one from sml
(* should conceal *) val id = fn x => x (* also should conceal *) val _ = (fn x => x) id (* technically this isn't valid SML, but it should conceal and it demonstrates a beginning-of-line issue *) fn x => x