emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] lisp: scoping vars in repetitive defuns


From: Adam Porter
Subject: Re: [O] lisp: scoping vars in repetitive defuns
Date: Wed, 18 Sep 2019 16:42:32 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Matt Price <address@hidden> writes:

> This is fun, thanks John. I really like the plist version put would
> also like to loop through the variables in a let statement somehow.
>
> I think what I'm missing is the equivalent of a javascript implicit
> destructuring construct:
>
> let { } = object;
>
> which will define new variables prop1, prop2... forever enumerable
> property of the object.  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.

In fact, he has written an article about that sort of thing, which you
can find linked here, along with some other destructuring tools:

https://github.com/alphapapa/emacs-package-dev-handbook#a-callable-plist-data-structure-for-emacs
https://github.com/alphapapa/emacs-package-dev-handbook#with-dict-with-plist-vals-1

Note that automatically binding variables named according to plist keys
which are not known in advance would have to happen at runtime and would
require use of eval, as well as potentially overriding variables that
you're already using.

Instead, I recommend using -let, which has a &plist keyword, which you
can use like:

  (-let* (((&plist :query :preamble :preamble-case-fold) 
(org-ql--query-preamble query)))
    (list query preamble preamble-case-fold))




reply via email to

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