5
$\begingroup$

AFAICT, when given a built-in symbol as argument, Messages returns an empty list, at least initially.

For example:

Quit (* reset *)
Messages[ListPlot]

{}

After running ??ListPlot, however, I get

Messages[ListPlot]
{HoldPattern[ListPlot::usage] :> ListPlot[{y1y2, …}] plots points {1, y1}, 
{2, y2}, …. 
ListPlot[{{x1y1}, {x2y2}, …}] plots a list of points with specified x and y
coordinates. 
ListPlot[{data1data2, …}] plots data from all the datai.
ListPlot[{… , w[datai, …], …}] plots datai with features defined by the
symbolic wrapper w.}

If I then elicit some error message, e.g. by running ListPlot[{1, 2, 3}, PlotRange -> InvalidPlotRangeSetting], I get

Messages[ListPlot]
{HoldPattern[ListPlot::prng] :> Value of option PlotRange -> `1` is not All,
Full, Automatic, a positive machine number, or an appropriate list of range
specifications.,
HoldPattern[ListPlot::usage] :> ListPlot[{y1y2, …}] plots points {1, y1}, 
{2, y2}, …. 
ListPlot[{{x1y1}, {x2y2}, …}] plots a list of points with specified x and y
coordinates. 
ListPlot[{data1data2, …}] plots data from all the datai.
ListPlot[{… , w[datai, …], …}] plots datai with features defined by the
symbolic wrapper w.}

IOW, it's like pulling teeth... Totally impractical.

Is there a practical way to really get all the messages associated with a built-in symbol?

$\endgroup$
1
  • $\begingroup$ Note that some messages actually belong to General, e.g. General::prng. $\endgroup$ Apr 6, 2017 at 16:53

1 Answer 1

4
$\begingroup$

You can read them directly from the Messages.m file.

path = FileNameJoin[{$InstallationDirectory, "SystemFiles", "Kernel",
    "TextResources", "English", "Messages.m"}];

allMessages = Import[path, "HeldExpressions"];

symbolToLookup = ListPlot;

Select[allMessages, MemberQ[#, symbolToLookup, Infinity, Heads -> True] &]

To get usage messages load "Usage.m" instead of "Messages.m".

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.