Based on an off-list suggestion from Brandon, I came up with this:
function oid_in_selection(oid) {
if (!selected()) { return 0; }
$o1 = selection_start($p1);
$o2 = selection_end($p2);
$offset_from_start = oid_offset($o1, $p1, $oid, 0);
$offset_from_end = oid_offset($o2, $p2, $oid, 0);
return ($offset_from_start >= 0 && $offset_from_end <= 0);
}
Seems to work based on the limited testing I've done so far.
-James