mdwref.dtx: Include help text with errors.
[mdwtools] / mdwref.dtx
index e6e20c8..66c2d07 100644 (file)
@@ -3,26 +3,28 @@
 %% mdwref package -- slightly fancy cross-referencing stuff
 %% Copyright (c) 2007, 2019 Mark Wooding
 %%
-%% This program is free software; you can redistribute it and/or modify
-%% it under the terms of the GNU General Public License as published by
-%% the Free Software Foundation; either version 2 of the License, or
-%% (at your option) any later version.
+%% This file is part of the `mdwtools' LaTeX package collection.
 %%
-%% This program is distributed in the hope that it will be useful,
-%% but WITHOUT ANY WARRANTY; without even the implied warranty of
-%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-%% GNU General Public License for more details.
+%% `mdwtools' is free software: you can redistribute it and/or modify it
+%% under the terms of the GNU General Public License as published by the
+%% Free Software Foundation; either version 2 of the License, or (at your
+%% option) any later version.
+%%
+%% `mdwtools' is distributed in the hope that it will be useful, but
+%% WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%% General Public License for more details.
 %%
 %% You should have received a copy of the GNU General Public License
-%% along with this program; if not, write to the Free Software
-%% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%% along with `mdwtools'.  If not, write to the Free Software Foundation,
+%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 %%
 % \end{meta-comment}
 %
 % \begin{meta-comment} <Package preambles>
 %<+package>\NeedsTeXFormat{LaTeX2e}
 %<+package>\ProvidesPackage{mdwref}
-%<+package>                [2007/04/09 1.01 Cross-referencing]
+%<+package>                [2020/09/06 1.14.0 Cross-referencing]
 % \end{meta-comment}
 %
 % ^^A\CheckSum{96}
   \ifx\hyperref\@@undefined #1{#2}~\ref{#3}%
   \else \hyperref[#3]{#1{#2}~\ref*{#3}}\fi%
 }
+\def\xref@fallback#1{\formatxref\relax{?\texttt{#1}}{#1}}
 %    \end{macrocode}
 % \end{macro}
 %
   \def\@tempa{#2}\def\@tempb{#3}%
   \ifx\@tempb\q@delim%
     \PackageError{xref}{Bad ref syntax}%
+      {A reference name doesn't contain a `:'-delimited prefix.  Did you %
+       mean to use plain \string\ref here?}%
+     \xref@fallback{#2}%
   \else%
     \expandafter\let\expandafter\@tempa\csname xref$#2\endcsname%
     \ifx\@tempa\relax%
       \PackageError{xref}{Unknown ref kind `#2'}%
+        {The ref name's prefix `#2' is unknown: either it's been mistyped %
+         or there's a missing \string\defxref somewhere.}%
+     \xref@fallback{#2:#3}%
     \else%
       \toks@\expandafter{\@tempa}%
       \edef\next@##1{##1{\the\toks@}}%