From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: elisp newbie: simplifying from cl structures? Date: Sat, 7 Feb 2015 15:26:16 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1423351613 18816 80.91.229.3 (7 Feb 2015 23:26:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Feb 2015 23:26:53 +0000 (UTC) Cc: emacs list To: "Tory S. Anderson" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 08 00:26:52 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YKEm3-0000qI-Mp for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Feb 2015 00:26:51 +0100 Original-Received: from localhost ([::1]:54960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKEm3-0000dQ-1a for geh-help-gnu-emacs@m.gmane.org; Sat, 07 Feb 2015 18:26:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKElq-0000dJ-CE for help-gnu-emacs@gnu.org; Sat, 07 Feb 2015 18:26:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKElp-00060h-GR for help-gnu-emacs@gnu.org; Sat, 07 Feb 2015 18:26:38 -0500 Original-Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:60978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKElp-00060X-Cr for help-gnu-emacs@gnu.org; Sat, 07 Feb 2015 18:26:37 -0500 Original-Received: by mail-oi0-f54.google.com with SMTP id v63so12127650oia.13 for ; Sat, 07 Feb 2015 15:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=FALDO/VbjCTqnjg42P3JSDKNkHR4/VHvqhsvapyqE5w=; b=ipsEGME9kAn40wRlfZGc0qA8E8j8jTpBV1FMVI9zQ8uFzABZupq0O1zKt4Ax+VJ5tX E0UQaIpMMNUxawVYJCNmad//TRI0ST6B87c8NI6bDNUb7KwhPtU580yVGGkMybCLxbo6 IuT3skpB0tIaqm3ZsAHYHk0alf0J7Rf2+0w8Amg6B+tMeM2jBmPAxpCqoti9qWBS1p4H sUR4ePkdozxL9eIPw4iT49E+nwGOlbL5Xx7C+69c56tQaVWjdb0ZuJhWe63LajthCR1R X1vIE4QDjtet/3AwEoLJ8SxlmbOzR+t81DsgY/7th81wm3ePbSzvxr8XLrmMaqIaEldL 5sUw== X-Received: by 10.202.178.131 with SMTP id b125mr6679381oif.80.1423351596892; Sat, 07 Feb 2015 15:26:36 -0800 (PST) Original-Received: by 10.76.12.162 with HTTP; Sat, 7 Feb 2015 15:26:16 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::236 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102569 Archived-At: > (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