]> gitweb.michael.orlitzky.com - emacs.d.git/blob - fix-nonstandard-chars.el
mode-hooks: allow M-<backspace> to kill previous words in terminals.
[emacs.d.git] / fix-nonstandard-chars.el
1 (defun fix-nonstandard-chars (context)
2 "Replace some typical nonstandard characters that result from
3 copy-and-pasting word processor text into XHTML documents."
4
5 (interactive "p")
6
7 (setq replacements
8 '( ("’" "'")
9 ("“" "&ldquo;")
10 ("”" "&rdquo;")
11 ("–" "-")
12 ("—" "&mdash;")
13 ("°" "&deg;")
14 ("®" "&reg;")
15 ("™" "&trade;")
16 )
17 )
18
19 (dolist (replacement replacements nil)
20 ;; The mark gets all fucked up here. It's easiest to
21 ;; just return to the beginning of the buffer each time.
22 (beginning-of-buffer)
23 (replace-string (nth 0 replacement) (nth 1 replacement))
24 )
25 )