Thank you, both,
It seems that _get_last_grep_buffer() actually return the number of search buffers there are, rather than the last buffer used (at least in v12.0.3).
The value I really want is in the static variable current_grep_id, so I've added an access function to tbsearch.e:
int _get_current_grep_buffer()
{
return (current_grep_id);
}
Now, using
_find_or_create_temp_view(temp_view_id, '', '.search' :+ _get_current_grep_buffer(), false, VSBUFFLAG_THROW_AWAY_CHANGES|VSBUFFLAG_HIDDEN|VSBUFFLAG_KEEP_ON_QUIT);
works a treat.
Not sure that I really ought to be editing tbsearch.e, but not sure what else to do.
Thank you again.
Barrie