(defun replace-smart-quotes (beg end)
"Replace 'smart quotes' in buffer or region with ascii quotes."
(format-replace-strings '(("\x201C" . "\"")
("\x201D" . "\"")
("\x2018" . "'")
("\x2019" . "'"))
nil beg end))
Put that in your
~/.emacs and you should be able to use M-x replace-smart-quotes to fix all quotes in the current buffer or selected region.
To avoid restarting Emacs for the
~/.emacs change to take effect, move your cursor to the end of the
defun with M-C-e and evaluate it C-x C-e.
Update re comment:
To automatically do this when yanking (pasting), you could do something like the following:
(defun yank-and-replace-smart-quotes ()
"Yank (paste) and replace smart quotes from the source with ascii quotes."
(replace-smart-quotes (mark) (point)))
If you then want to do that when you hit C-y, you can bind it using:
(global-set-key (kbd "C-y") 'yank-and-replace-smart-quotes)
It's probably a better idea to use another key however (maybe C-c y) as this will use some of the default