]> gitweb.michael.orlitzky.com - emacs.d.git/blobdiff - fix-nonstandard-chars.el
Overhauled the fix-nonstandard-chars function because it was completely broken.
[emacs.d.git] / fix-nonstandard-chars.el
index e5c3464476659ea7a98c3757b567fde8603c6a0c..2ba368b83a81aecceb4d9ab569944567b1ca6300 100644 (file)
@@ -1,9 +1,19 @@
-(defun fix-nonstandard-chars
+(defun fix-nonstandard-chars (context)
   "Replace some typical nonstandard characters that result from
    copy-and-pasting word processor text into XHTML documents."
 
-  (replace-string "’" "'")
-  (replace-string "“" "“")
-  (replace-string "”" "”")
-  (replace-string "–" "-")
+  (interactive "p")
+
+  (setq replacements '( ("’" "'")
+                       ("“" "“")
+                       ("”" "”")
+                       ("–" "-")
+                       ("—" "—") ))
+
+  (dolist (replacement replacements nil)
+    ;; The mark gets all fucked up here. It's easiest to
+    ;; just return to the beginning of the buffer each time.
+    (beginning-of-buffer)
+    (replace-string (nth 0 replacement) (nth 1 replacement))
+    )
 )