Incorrect smart quotes after em-dash

When I’m closing a quotation with em-dash or ellipsis, I type space (because I like spaces around them, as in the AP style manual) and use a TextExpander snippet to change

;-
[/code] to [code]
— ”

or

;.
[/code] to [code]
… ”

The result is em-dash or ellipsis followed by a non-breaking space and the correct closing quote. (Leave out the spaces if you don’t want them.) The non-breaking space prevents the ending quotes sometimes pushing to the next line by itself.

There are several TextExpander equivalents.