Changes
Edited text for clarity (and extraneous commas), added examples.
\framed{\obeyspaces{A gap from here to there!}}
</texcode>
<context>
\framed{\obeyspaces{A gap from here to there!}}
</context>
But if you pass this text as a parameter for your own macro
<texcode>
\def\TextWithSpaces#1{\framed{\obeyspaces#1}}%
\TextWithSpaces{A gap from here to there!}
</texcode>
<context>
\def\TextWithSpaces#1{\framed{\obeyspaces#1}}%
\TextWithSpaces{A gap from here to there!}
</texcodecontext>
the additional spaces are '''ignored'''.
Here is a two-part solution for the problem (''suggested by Taco Hoekwater''):
\def\doTextWithSpaces #1{#1\egroup}
</texcode>
Both of these produce the desired result:
<context>
\def \TextWithSpaces {\framed\bgroup\obeyspaces\doTextWithSpaces}
\def\doTextWithSpaces #1{#1\egroup}
\TextWithSpaces{A gap from here to there!}
</context>