[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
elisp optimization question
From: |
brad clawsie |
Subject: |
elisp optimization question |
Date: |
Thu, 08 May 2008 11:03:53 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (berkeley-unix) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hi, i use the following function to translate unicode and other
entities found on the web into ascii that i can view in emacs-w3m. i
am concerned that each search and replace as done in my example is
inefficient, is there a better way to do this? i.e., is there a better
way to group search/replace pairs? thanks in advance!
(defun w3m-filter-brad (url)
(goto-char (point-min))
(while (re-search-forward "»" nil t)
(replace-match ">>"))
(goto-char (point-min))
(while (re-search-forward "’" nil t)
(replace-match "'"))
(goto-char (point-min))
(while (re-search-forward "“" nil t)
(replace-match "\""))
(goto-char (point-min))
(while (re-search-forward "”" nil t)
(replace-match "\""))
(goto-char (point-min))
(while (re-search-forward "—" nil t)
(replace-match "-"))
(goto-char (point-min))
(while (re-search-forward "«" nil t)
(replace-match "<"))
(goto-char (point-min))
(while (re-search-forward "»" nil t)
(replace-match ">"))
(goto-char (point-min))
(while (re-search-forward "ö" nil t)
(replace-match "o"))
)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
iEYEARECAAYFAkgjQIwACgkQxRg3RkRK91MO8gCgqJHsYhE/3bUERIeVztOkABUI
xy0An3rk59o/OCHfaOlSVmM3zBdTgUXQ
=lwIH
-----END PGP SIGNATURE-----