5

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?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
kjo
  • 11,717
  • 1
  • 30
  • 89

1 Answers1

4

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".

Ray Shadow
  • 7,816
  • 1
  • 16
  • 44