Return the longest prefix of TYPE to which PRED returns non-nil.
TYPE should be a tty type name such as "xterm-16color".
The function tries only those prefixes that are followed by a
dash or underscore in the original type name, like "xterm" in
the above example.