help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp newbie: simplifying from cl structures?


From: John Mastro
Subject: Re: elisp newbie: simplifying from cl structures?
Date: Sat, 7 Feb 2015 15:26:16 -0800

>     (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."))))

-- 
john



reply via email to

[Prev in Thread] Current Thread [Next in Thread]