[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp newbie: simplifying from cl structures?
From: |
Pascal J. Bourguignon |
Subject: |
Re: elisp newbie: simplifying from cl structures? |
Date: |
Sun, 08 Feb 2015 01:37:01 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
John Mastro <john.b.mastro@gmail.com> writes:
>> (defun change-smtp ()
>> "Change the SMTP server according to the current from line."
>> (save-excursion
>> (cl-loop with from = (save-restriction
>> (message-narrow-to-headers)
>> (message-fetch-field "from"))
>> for (address server port) in smtp-accounts
>> if (string-match address from)
>> return (funcall 'set-smtp server port address))
>> (error "Cannot infer SMTP information.")))
>
> Second try. The return won't escape the `error' in the above.
>
> (defun change-smtp ()
> "Change the SMTP server according to the current from line."
> (save-excursion
> (cl-loop with from = (save-restriction
> (message-narrow-to-headers)
> (message-fetch-field "from"))
> for (address server port) in smtp-accounts
> if (string-match address from)
> return (funcall 'set-smtp server port address)
> finally (error "Cannot infer SMTP information."))))
do (if (string-match address from)
(return (funcall 'set-smtp server port address)))
finally (error "Cannot infer SMTP information.")
will.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk