From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: elisp optimization question
Date: Thu, 08 May 2008 19:45:43 -0600 [thread overview]
Message-ID: <g00abb$iun$2@ger.gmane.org> (raw)
In-Reply-To: <875de456-396d-4c4e-9d99-2ccb5a4a94d8@z72g2000hsb.googlegroups.com>
harven wrote:
> hi,
> you can save some typing by using an alist. Here is what i use to
> convert
> accented-letters into html and back.
>
> (defun accent-html (prefix)
> "Accented letter translation é -> é.
> With an argument, reverse é <- é.
> Works on the whole buffer"
> (interactive "P")
> (save-excursion
> (let ((association
> '(("É" . "É") ("á" . "á") ("à" . "à")
> ("â" . "â") ("ä" . "ä") (""" . "ã")
> ("é" . "é") ("è" . "è") ("ê" . "ê")
> ("ë" . "ë") ("í" . "í") ("ì" . "ì")
> ("î" . "î") ("ï" . "ï") ("ñ" . "ñ")
> ("ó" . "ó") ("ò" . "ò") ("ô" . "ô")
> ("ö" . "ö") ("ı" . "õ") ("ú" .
> "ú")
> ("ù" . "ù") ("û" . "û") ("ü" . "ü")
> ("ç" . "ç")))
> (case-fold-search nil))
> (dolist (paire association)
> (when prefix
> (setq paire (cons (cdr paire) (car paire))))
> (goto-char (point-min))
> (while (search-forward (car paire) nil t)
> (replace-match (cdr paire) nil t))))))
Even faster than an alist is a hash table.
--
Kevin Rodgers
Denver, Colorado, USA
next prev parent reply other threads:[~2008-05-09 1:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.11345.1210283700.18990.help-gnu-emacs@gnu.org>
2008-05-09 0:00 ` elisp optimization question harven
2008-05-09 1:45 ` Kevin Rodgers [this message]
[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
2008-05-08 18:03 brad clawsie
2008-05-08 22:14 ` Lennart Borgman (gmail)
2008-05-09 1:42 ` Kevin Rodgers
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='g00abb$iun$2@ger.gmane.org' \
--to=kevin.d.rodgers@gmail.com \
--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).