On Thu, 23 Apr 2026 at 11:12, Janis Papanagnou
<[email protected]> wrote:
>
> A quick question concerning regexp expressions in syntax matches...
>
> On several places I had the same regexp sub-expression, like
>   \%(\%(\%(long\s*\)\?long\s*\)\|[qd]\)
> and I asked myself whether it is possible to define a reusable
> variable for that.
> And now, with the introduction of these sub-patterns
>   \%(\%([a-z_]\|\l\d\+\)\s\+\)\@8<!
> that appear everywhere there's even more gain if it's possible
> to specify that as variable for later use.
>
> Q: Is it possible in the regexp matcher to formulate things like
>
>   opt_long = "\%(\%(\%(long\s*\)\?long\s*\)\|[qd]\)"
>   context_start = " \%(\%([a-z_]\|\l\d\+\)\s\+\)\@8<!"
>
> and then use it as
>
>   syn match algol68Predefined  context_start+opt_long+whatever+...
>
> or else could it be made possible as a new Vim syntax feature?

Yes, using the simpler `newlinecharacter` for demonstration,

let s:context_start = ...
let s:context_end = ...
let s:tag = ["newline", "character"]
for s:sep in ['\s*', '']
  exe $"syntax algol68Predefined
/{s:context_start}{s:tag->join(sep)}{s:context_end}/"
endfor

So you could certainly build all the prelude highlighting from a
suitable data structure.

You could either generate it dynamically when the syntax file is
processed with Vim script, or just generate the syntax file itself (or
the prelude section) with Algol 68. :)

Regards,
Doug

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/CAJ1uvoAtZXP71PKocTvJLuDYWTOerYTgftPrCiYsj7Z%3DohRPfg%40mail.gmail.com.

Raspunde prin e-mail lui