Insert \thinspace only if not followed by certain characters



(Cross-posted from <http://tex.stackexchange.com/q/59482/2966>.)

Following a tip I'd seen, I’ve defined a \spaceddash command and
assigned it to the Unicode em-dash character U+2014 “—”:

\documentclass{minimal}
\usepackage[utf8]{inputenc}
\DeclareRobustCommand{\spaceddash}%
{\unskip\nobreak\thinspace\textemdash\thinspace\ignorespaces}
\DeclareUnicodeCharacter{2014}{\spaceddash}

\begin{document}
meow — meow

meow—meow

— meow

meow —.
\end{document}

The last line before \end{document} shows a problem with this: there's a
\thinspace between the em-dash and the period afterward, and I'd rather
not have it there.

Following the example of xspace & xpunctuate, I'm trying to define a
sort of \xthinspace command, one that will insert the \thinspace except
if the dash is followed by certain punctuation marks (e.g., period,
comma, close-parenthesis, close-quote).

How do I go about this?

--Joel
.