I would like to add to this, as a spin off from the thread as well. Just to be clear, I also think the usefulness to extend these functions is there. But there are 2 other changes that are a more direct path and less computationally intense to accomplish what I set out to do.

The first is, having the /*line commands work on other windows than custom, through their name - but then we have to watch out for same name channel/query/whatever on different networks, so it'd be dependent on which "scon" it is executed, or through a globally unique identifier like the window id.

Also, since we're changing stuff anyway, I never quite understood the usefulness of having the optionally first number be interpreted as the line color, when a ctrl-k + number before the line achieves the same thing, and no confusion would arise from that. Although I do understand that changing the signature from a function is a big deal that can break some scripts.

The second one is the $fline identifier. From my courses at uni, I know that finding text is a pretty complex process to do right, so I wonder if the identifier could be changed or adapted to do less of it. One way would be to have a new field like $fline(*,*,0,*).last, so you can directly get the line number of the last occurrence (the first one is easy by changing the 0 into 1), without having to use $fline twice. That's some extra memspace tho. Another option could be to have any larger number than the amount of occurrences be interpreted as the last occurrence, like change the 0 in 1000 and if there are only 67 occurrences, return the line number of the 67th occurrence.

The last thing I can think of and maybe the best in this specific scenario, is a new identifier that works almost exactly as the ctrl-f (find) function and complements the $fline by doing the same thing the other way around. $find(*,N) with .text field, that starts searching from the bottom up and returns the line number from the Nth occurrence. This function could also integrated in $fline by having a fifth field that would indicate direction (1=up/0=down) instead of always counting by going down.

Sorry for the large amount of text smile