This question led to a new package:
In writing error messages and warnings for a package/class, I find it a pain to manually insert
\MessageBreaks so that words don't get cruelly bisected because of TeX's
max_print_line value (which typically is set to 79). In some cases it's not possible to predict where the
\MessageBreak should go because a macro in the warning/error message may be expanded to any length of string.
I'd like to have a macro that would take my warning/error message, expand it (so that any macros are expanded to plain strings), and insert
\MessageBreaks in the appropriate places based on the value of
max_print_line and LaTeX's per-line prefixes (
Package <XXX> Warning: and similar).
(If the value of
max_print_line can't be accessed from within TeX, I'd settle for just implementing a greedy word-wrap algorithm with the default line length values.)