Is it possible to see full version of a Message
that got truncated? IE, I see something along the lines of 0.105309,0.394682,<<20>>,<<20
Undocumented function Internal`HandlerBlock
(uncovered by Maxim Rytin) is applicable here:
Off[FindMaximum::"nrnum"]
Internal`HandlerBlock[{"Message", Print},
Message[FindMaximum::"nrnum", arg1, arg2, arg3]]
(* => Hold[Message[FindMaximum::nrnum,arg1,arg2,arg3],False]*)
Another handler type is "MessageTextFilter". "Message" is invoked for every generated message and passes one argument of the form Hold[..., ...] to the handler function, with the second element set to False for quieted messages. "MessageTextFilter" is invoked for messages that actually get printed and calls the function with three arguments.
Maxim Rytin
Another possibility is to modify $MessagePrePrint
in such a way that it will print messages containing in-line cells with truncated arguments which can be expanded to full arguments on evaluation. It can be done with Interpretation
:
truncatingRules = {lst : {x_, y__} /;
MatrixQ[lst, NumberQ] && Length[lst] > 3 :>
{x /. v : {a_, b__} /; Length[v] > 3 :>
{a,
Interpretation[Style[Skeleton[Length[{b}]], Gray],
Sequence @@ {b}]},
Interpretation[Style[Skeleton[Length[{y}]], Gray],
Sequence @@ {y}]},
lst : {x_, y__} /; VectorQ[lst, NumberQ] && Length[lst] > 3 :>
{x, Interpretation[Style[Skeleton[Length[{y}]], Gray],
Sequence @@ {y}]}};
InlineCellInsideMessage[expr_] :=
Style[DisplayForm[
Cell[BoxData[MakeBoxes[expr, StandardForm]], "Input"]],
FontWeight -> Bold, FontFamily -> "Courier", Background -> Yellow,
FontColor -> Red, FontSize -> 12, StripOnInput -> True,
AutoNumberFormatting -> True, ShowStringCharacters -> True]
$MessagePrePrint =
Function[expr,
If[TrueQ[ByteCount[Unevaluated[expr]] < $OutputSizeLimit/20.],
InlineCellInsideMessage[expr],
InlineCellInsideMessage[expr /. truncatingRules]
]]
Of course, the above version of $MessagePrePrint
is just a draft but it illustrates the main idea.