From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: lisp: scoping vars in repetitive defuns Date: Wed, 18 Sep 2019 19:17:58 -0400 Message-ID: References: <87impps3ce.fsf@fastmail.fm> <87r24d6zzd.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e4325a0592dc0ce7" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:32897) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAjDC-0007Qn-2F for emacs-orgmode@gnu.org; Wed, 18 Sep 2019 19:18:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAjDA-0001wE-Ih for emacs-orgmode@gnu.org; Wed, 18 Sep 2019 19:18:13 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:34518) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iAjDA-0001vM-1K for emacs-orgmode@gnu.org; Wed, 18 Sep 2019 19:18:12 -0400 Received: by mail-wm1-x330.google.com with SMTP id y135so5832660wmc.1 for ; Wed, 18 Sep 2019 16:18:11 -0700 (PDT) In-Reply-To: <87r24d6zzd.fsf@alphapapa.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Adam Porter Cc: org-mode-email --000000000000e4325a0592dc0ce7 Content-Type: text/plain; charset="UTF-8" I played with a similar idea of converting a plist to something you can call to access values at https://kitchingroup.cheme.cmu.edu/blog/2017/04/16/A-callable-plist-data-structure-for-Emacs/. It did end up as a macro, but no eval required. It never made it past that post, but it might have an application here. I am not sure why you have to loop over everything in a let statement though. you can use something like https://github.com/nicferrier/emacs-kv to get all the keys an loop over those to do what you want, or you can just use cl-loop to do that. So, unless you are defining new variables for readability you shouldn't need to let bind anything that is in the plist, only new things that are derived from it. John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Wed, Sep 18, 2019 at 5:45 PM Adam Porter wrote: > Joost Kremers writes: > > > On Wed, Sep 18 2019, Matt Price wrote: > >> Is thre away to do that kind of destructuring bind -- which > >> binds *everything* in the plist, without knowing the symbol names in > >> advance? that would be really great. > > > > let-alist perhaps? > > Well, let-alist is for alists, not plists. ;) But anyway, it's a macro, > and it does require knowing keys at compile time. -let is a good > alternative for plists and other maps. > > > --000000000000e4325a0592dc0ce7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I played with a similar idea of converting a plist to some= thing you can call to access values at=C2=A0= https://kitchingroup.cheme.cmu.edu/blog/2017/04/16/A-callable-plist-data-st= ructure-for-Emacs/. It did end up as a macro, but no eval required. It = never made it past that post, but it might have an application here.=C2=A0<= div>
I am not sure why you have to loop over everything in a = let statement though. you can use something like=C2=A0https://github.com/nicferrier/emacs-kv=C2= =A0to get all the keys an loop over those to do what you want, or you can j= ust use cl-loop to do that. So, unless you are defining new variables for r= eadability you shouldn't need to let bind anything that is in the plist= , only new things that are derived from it.

<= div>
John

-----------------= ------------------
Professor John Kitchin=C2=A0
Doherty Hall A207FDepartment of Chemical Engineering
Carnegie Mellon University
Pittsb= urgh, PA 15213
412-268-7803

<= /div>
O= n Wed, Sep 18, 2019 at 5:45 PM Adam Porter <adam@alphapapa.net> wrote:
Joost Kremers <joostkremers@fastmail.fm> writes:
> On Wed, Sep 18 2019, Matt Price wrote:
>> Is thre away to do that kind of destructuring bind -- which
>> binds *everything* in the plist, without knowing the symbol names = in
>> advance? that would be really great.
>
> let-alist perhaps?

Well, let-alist is for alists, not plists.=C2=A0 ;) But anyway, it's a = macro,
and it does require knowing keys at compile time.=C2=A0 -let is a good
alternative for plists and other maps.


--000000000000e4325a0592dc0ce7--