From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: New assoc-let package Date: Wed, 03 Dec 2014 22:54:50 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417665324 14788 80.91.229.3 (4 Dec 2014 03:55:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Dec 2014 03:55:24 +0000 (UTC) Cc: emacs-devel To: Artur Malabarba Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 04 04:55:16 2014 Return-path: Envelope-to: ged-emacs-devel@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 1XwNVb-0001Hg-7B for ged-emacs-devel@m.gmane.org; Thu, 04 Dec 2014 04:55:15 +0100 Original-Received: from localhost ([::1]:44351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwNVa-0005s4-QL for ged-emacs-devel@m.gmane.org; Wed, 03 Dec 2014 22:55:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwNVQ-0005nO-Oz for emacs-devel@gnu.org; Wed, 03 Dec 2014 22:55:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwNVJ-0001JZ-3G for emacs-devel@gnu.org; Wed, 03 Dec 2014 22:55:04 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:10879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwNVI-0001JT-Vb for emacs-devel@gnu.org; Wed, 03 Dec 2014 22:54:57 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am8PAOwQflRMCqTq/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAwEBAwFWIwULCw4mEhQNCw0kE4grAwkJ0FENhXsBAQEBBgEBAQEejjiCNweESAWLAYxVBYIskFuETYF4hBkhMAGCRgEBAQ X-IPAS-Result: Am8PAOwQflRMCqTq/2dsb2JhbABbgweBK4I1hVrFHQQCAoEkFwEBAQEBAXyEAwEBAwFWIwULCw4mEhQNCw0kE4grAwkJ0FENhXsBAQEBBgEBAQEejjiCNweESAWLAYxVBYIskFuETYF4hBkhMAGCRgEBAQ X-IronPort-AV: E=Sophos;i="5.07,502,1413259200"; d="scan'208";a="99516706" Original-Received: from 76-10-164-234.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([76.10.164.234]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 Dec 2014 22:54:55 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id B6F6DAE15A; Wed, 3 Dec 2014 22:54:50 -0500 (EST) In-Reply-To: (Artur Malabarba's message of "Wed, 3 Dec 2014 23:40:14 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:178796 Archived-At: >>>>> "Artur" == Artur Malabarba writes: > Hi All, > As part of another project, which involves excessive handing of > alists, I wrote up a little macro which has turned out to be > stupendously useful. I'm just checking whether this functionality is > already offered somewhere, because if it isn't I'll make an Elpa > package for it. > Simply put, the macro takes an alist and a body, and makes the data of > the alist accessible by just writing the car of the desired cell > preceded by a dot. > For instance, the following: > (assoc-let alist > (if (and .title .body) > .body > .site)) I don't know of any package that does something like that, no. The way I'd have done it is (cl-macrolet (((a field) `(cdr (assq ,field alist)))) (if (and (a title) (a body)) (a body) (a site))) -- Stefan