[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cleanup.el (Was Replacing non-ascii characters)
From: |
Francesco Potorti` |
Subject: |
Re: cleanup.el (Was Replacing non-ascii characters) |
Date: |
Tue, 13 Dec 2005 10:00:07 +0100 |
>;;; cleanup.el --- Clean up quoted material of a few common types
>;; Rationale: Do you sometimes cut and paste from web pages into
>;; Emacs? Sometimes the result isn't ASCII text, but an ugly
>;; near-ASCII text that can't be saved with plain encoding.
Here is what I have used for many years, about the same rationale as
above. THe first is a utility function used by the following commands.
(defun do-accent (subst-list)
(dolist (pair subst-list)
(save-excursion
(while (re-search-forward (car pair) nil t)
(replace-match (cdr pair) t)))))
(defun en-accent ()
(interactive)
(do-accent '(("a`" . "\340") ("e`" . "\350") ("e'" . "\351")
("E`" . "\310") ("i`" . "\354")
("o`" . "\362") ("u`" . "\371")
("ch\350\\>" . "ch\351") ("\\<n\350\\>" . "n\351"))))
(defun en-accent-reverse ()
(interactive)
(do-accent '(("a'" . "\340") ("e'" . "\350")
("E'" . "\310") ("i'" . "\354")
("o'" . "\362") ("u'" . "\371")
("\\<ch\350\\>" . "ch\351") ("\\<n\350\\>" . "n\351"))))
(defun de-accent ()
(interactive)
(do-accent '(("\340" . "a`") ("\350" . "e`")
("\310" . "E`") ("\351" . "e`")
("\354" . "i`") ("\362" . "o`")
("\371" . "u`"))))
(defun de-utf8-accent ()
(interactive)
(do-accent '(("\303\240" . "\340") ("\303\250" . "\350")
("\303\210" . "\310") ("\303\254" . "\354")
("\303\262" . "\362") ("\303\271" . "\371"))))
(defun de-windows ()
(interactive)
(do-accent '(("\205" . "..") ("\226" . "--") ("\200" . "\244")
("\221" . "`") ("\222" . "'")
("\223" . "\"") ("\224" . "\""))))
(defun en-ascii ()
(interactive)
(do-accent '(("\205" . "..") ("\221" . "`") ("\222" . "'")
("\223" . "\"") ("\224" . "\"") ("\226" . "--"))))
(defun en-latin ()
(interactive)
(en-ascii) (do-accent '(("\200" . "\244"))))