I'm not sure this would be easy to implement, because the matching lines are not passed to the -k alias 'on the fly'. Instead, they are added into an internal cache, from which the alias receives them once the filtering process is done. For us this means that $regml() will always hold the value of the last match.
This example shows what I mean:
alias test {
- write f_file A | write f_file B | write f_file C
filter -fkg f_file f_alias /(.)/g
.remove f_file
}
alias -l f_alias {
- linesep
var %a = $regml(0), %b = 0
echo -s Captured %a subpattern(s)
while %a > %b { inc %b | echo -s - $regml(%b) }
linesep
}