]> gitweb.michael.orlitzky.com - emacs.d.git/commitdiff
Overhauled the fix-nonstandard-chars function because it was completely broken.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 2 Feb 2010 21:19:26 +0000 (16:19 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 2 Feb 2010 21:19:26 +0000 (16:19 -0500)
fix-nonstandard-chars.el

index 52f42df6c2b8d565eb80d191604ef8932648bc2b..2ba368b83a81aecceb4d9ab569944567b1ca6300 100644 (file)
@@ -2,11 +2,18 @@
   "Replace some typical nonstandard characters that result from
    copy-and-pasting word processor text into XHTML documents."
 
   "Replace some typical nonstandard characters that result from
    copy-and-pasting word processor text into XHTML documents."
 
-  (interactive "P")
+  (interactive "p")
 
 
-  (replace-string "’" "'")
-  (replace-string "“" "&ldquo;")
-  (replace-string "”" "&rdquo;")
-  (replace-string "–" "-")
-  (replace-string "—" "&mdash;")
+  (setq replacements '( ("’" "'")
+                       ("“" "&ldquo;")
+                       ("”" "&rdquo;")
+                       ("–" "-")
+                       ("—" "&mdash;") ))
+
+  (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))
+    )
 )
 )