all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marco Antoniotti <marcoxa@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Help needed to simplify code for customisation
Date: Tue, 10 Mar 2009 09:53:39 -0700 (PDT)	[thread overview]
Message-ID: <d7760ed0-8cb5-42f1-963d-afe0dbeee3f0@h5g2000yqh.googlegroups.com> (raw)
In-Reply-To: gp5jn001kva@enews2.newsguy.com

On Mar 10, 12:42 pm, "William James" <w_a_x_...@yahoo.com> wrote:
> TomSW wrote:
> > (require 'cl)
>
> > (defvar my-accounts-alist
> >   '(("richardriley"  "root" "richardriley")
> >     ("rileyrgdev"    "rileyrgdev"))
> >   "Associate email accounts with sender addresses: an alist each item
> > of
> > which is a list whose first member is the account name and any
> > following
> > members are regular expressions to match against a sender address.")
>
> > (defun my-get-account (from)
> >   (car (find-if (lambda (regexps)
> >                   (some (lambda (regexp)
> >                           (string-match regexp from))
> >                         regexps))
> >                 from my-accounts-alist
> >                 :key 'cdr)))
>
> Clojure:
>
> (def my-accounts-map
>   { "richardriley"  [#"root" #"richardriley"],
>     "rileyrgdev"    [#"rileyrgdev"] } )
>
> (defn my-get-account [from]
>   (ffirst
>     (filter
>       (fn [[acct re-list]] (some #(re-find % from) re-list))
>       my-accounts-map)))

Hey.  That is not the homework you are supposed to hand in.

Cheers
--
Marco





  reply	other threads:[~2009-03-10 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10  2:14 Help needed to simplify code for customisation Richard Riley
2009-03-10  6:44 ` Xah Lee
     [not found]   ` <b5ecffc4-3770-4c6e-8f1c-38042d65d09e@a39g2000yqc.googlegroups.com>
2009-03-10 11:42     ` William James
2009-03-10 16:53       ` Marco Antoniotti [this message]
2009-03-11  6:37         ` Kenneth Tilton
2009-03-11  2:39 ` 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

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

  git send-email \
    --in-reply-to=d7760ed0-8cb5-42f1-963d-afe0dbeee3f0@h5g2000yqh.googlegroups.com \
    --to=marcoxa@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.