unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: brad clawsie <clawsie@fastmail.fm>
To: help-gnu-emacs@gnu.org
Subject: elisp optimization question
Date: Thu, 08 May 2008 11:03:53 -0700	[thread overview]
Message-ID: <86k5i4pt9y.fsf@jobbicycle.corp.yahoo.com> (raw)

-----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 "&#187;" nil t)
    (replace-match "&gt;&gt;"))
  (goto-char (point-min))
  (while (re-search-forward "&#8217;" nil t)
    (replace-match "'"))
  (goto-char (point-min))
  (while (re-search-forward "&#8220;" nil t)
    (replace-match "\""))
  (goto-char (point-min))
  (while (re-search-forward "&#8221;" nil t)
    (replace-match "\""))
  (goto-char (point-min))
  (while (re-search-forward "&#8212;" nil t)
    (replace-match "-"))
  (goto-char (point-min))
  (while (re-search-forward "&laquo;" nil t)
    (replace-match "&lt;"))
  (goto-char (point-min))
  (while (re-search-forward "&raquo;" nil t)
    (replace-match "&gt;"))
  (goto-char (point-min))
  (while (re-search-forward "&ouml;" nil t)
    (replace-match "o"))
  )
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAkgjQIwACgkQxRg3RkRK91MO8gCgqJHsYhE/3bUERIeVztOkABUI
xy0An3rk59o/OCHfaOlSVmM3zBdTgUXQ
=lwIH
-----END PGP SIGNATURE-----




             reply	other threads:[~2008-05-08 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-08 18:03 brad clawsie [this message]
2008-05-08 22:14 ` elisp optimization question Lennart Borgman (gmail)
2008-05-09  1:42   ` Kevin Rodgers
     [not found] <mailman.11345.1210283700.18990.help-gnu-emacs@gnu.org>
2008-05-09  0:00 ` harven
2008-05-09  1:45   ` Kevin Rodgers
     [not found]   ` <mailman.11354.1210297808.18990.help-gnu-emacs@gnu.org>
2008-05-09  9:59     ` Rupert Swarbrick
2008-05-09 21:43       ` harven
2008-05-09  0:36 ` Xah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86k5i4pt9y.fsf@jobbicycle.corp.yahoo.com \
    --to=clawsie@fastmail.fm \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).