Following this StackOverflow question, I coded this function to clean up text pasted from other sources, such as Google Docs:
(defun sanitize-md () "Replace characters." (interactive "*") (save-excursion (let ((replacement-list '( ("\\" . "/") ("ﬁ" . "fi") ("“" . "\"") ("”" . "\"") ))) (while (let* ((pair (pop replacement-list)) (to-find (car pair)) (to-replace (cdr pair))) (message "%s %s" to-find to-replace) (query-replace to-find to-replace nil (point-min) (point-max)) ) replacement-list) )))
My problem is the curly double quote
“, which I have in a document. When I run this function, I get this in the
\ / Mark set Replaced 0 occurrences
If I remove the line on
query-replace, then the
*Messages* buffer shows all four pairs. And if I put the double-quote pair as the first element of the list, then it gets replaced.
query-replace stop at the first element of the
dolist, and how can I code the replacement of all pairs?