Matt Price <mopto...@gmail.com> 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))