]> gitweb.michael.orlitzky.com - emacs.d.git/blobdiff - fix-nonstandard-chars.el
mode-hooks/python-mode-hooks.el: don't mangle docstrings please.
[emacs.d.git] / fix-nonstandard-chars.el
index e5c3464476659ea7a98c3757b567fde8603c6a0c..e1ec2f563d8ddc7cd796c411c40a4f8dee56d7b3 100644 (file)
@@ -1,9 +1,25 @@
-(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))
+    )
 )