From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: daimrod@gmail.com (=?utf-8?Q?Gr=C3=A9goire?= Jadi) Newsgroups: gmane.emacs.devel Subject: Re: Programmatic let Date: Wed, 05 Dec 2012 21:37:59 +0100 Message-ID: <87r4n4uteg.fsf@casa.home> References: <87sj7kqm59.fsf@fimbulvetr.bsc.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1354739826 25458 80.91.229.3 (5 Dec 2012 20:37:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Dec 2012 20:37:06 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 05 21:37:19 2012 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 1TgLiY-00041c-4o for ged-emacs-devel@m.gmane.org; Wed, 05 Dec 2012 21:37:18 +0100 Original-Received: from localhost ([::1]:43641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgLiM-0004c4-6U for ged-emacs-devel@m.gmane.org; Wed, 05 Dec 2012 15:37:06 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgLiF-0004ZH-1S for emacs-devel@gnu.org; Wed, 05 Dec 2012 15:37:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TgLiD-0006fF-RY for emacs-devel@gnu.org; Wed, 05 Dec 2012 15:36:58 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:46998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgLiD-0006f4-Kb for emacs-devel@gnu.org; Wed, 05 Dec 2012 15:36:57 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TgLiM-0003lm-KA for emacs-devel@gnu.org; Wed, 05 Dec 2012 21:37:06 +0100 Original-Received: from anantes-653-1-38-216.w109-211.abo.wanadoo.fr ([109.211.33.216]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Dec 2012 21:37:06 +0100 Original-Received: from daimrod by anantes-653-1-38-216.w109-211.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Dec 2012 21:37:06 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 73 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: anantes-653-1-38-216.w109-211.abo.wanadoo.fr User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:Oc7U4BCvadA8LhWk4WQyKnb6SLk= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:155311 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Llu=C3=ADs writes: > My elisp foo is quite poor, so this might well be a completely stupid app= roach > to the problem. > > I have a callback that gets automatically called, and uses some orgmode-s= pecific > routines whose behaviour can be tuned through some customizable variables. > > The usual approach in orgmode is: > > (let ((org-v1 ...) (org-v2 ...)) (org-func ...)) > > As my function is automatically called (as a response to the D-Bus messag= e), I'd > like to let the user specify a let-like form to let her temporarily overr= ide the > behaviour of the `org-func' that my package invokes: > > (setq my-cb-org-vars '((org-v1 ...) (org-v2 ...))) > (defun my-cb (...) > (programmatic-let my-cb-org-vars > (org-func ...))) > > Is it possible to implement `programmatic-let'? And if so, can you throw = me a > pointer to the appropriate docs? You could use progv: > (progv SYMBOLS VALUES &rest BODY) >=20 > Bind SYMBOLS to VALUES dynamically in BODY. > The forms SYMBOLS and VALUES are evaluated, and must evaluate to lists. > Each symbol in the first list is bound to the corresponding value in the > second list (or to nil if VALUES is shorter than SYMBOLS); then the > BODY forms are executed and their result is returned. This is much like > a `let' form, except that the list of symbols can be computed at run-time. However, given a defined set of variables, you could parse my-cb-org-vars yourself: (defvar my-cb-org-vars '((x ...) (y ...))) (defun my-cb (...) (let ((x (cdr (assoc 'x my-cb-org-vars))) (y (cdr (assoc 'y my-cb-org-vars)))) ....)) --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJQv7CpAAoJEBNzVHcrZRiUS7AP/2VB7ImIc8In5BvDZmUedCaz 4q/KS0rOZuylztBLWCL2DQ+C37pf+QYVuKQGuArsMrnDIj8oCeP6Jekmwb0geexe sw5CJC0Y4LZep7rfS69fKfPpPhwdKrIwFJyC9BS11H2xqnH+jzt8UiqQf14i1ZlM z6EvWLKHNA6ysGP8dmXZfxw7N/BjBiCyKL3DLckKbHDWHbXVpx10aHh9eRRPcGrX jv16T0z+dF2viEKcm+W8bXYrXRQx9ZmW7OskOXgKooejp29TFaKibI/n6UZnK0wa L0g+Cj35C9vUYyrOUN7NoIFfTD73Qi+EeiLpj7xjvLLz7A8mqyKZYhlUcGxvsoqf pigdtK+lsqQme4fyuco2vkWwSUTO5BP5bKQAisAigKWI7/G4uM+oqyP7wfhaxWcw EorgTVHYMHtwAGxcwLMrIyLZxcv7ijEvy1wPYbcr3AcLIjIYvouPmJiFAsUbzfu+ 8VxbDEVNRhjBkL638o5zkZlQIIbJSa+LkP6L9/5qHPyQRxBxNAjGROZNFtTiUX5g drELxb/CgMUWFRe+g7IAlvVD/YPsU1MgB6Ca7iVQWH2zj3lG4uM+jfWH22WT0UYV k82nuKUsx/wFqdqNtUGvuJ9qqJTacbRY95z/Fhv0MzeqHomMKVqmYCX+OXoQUMcT Qv92tikHZWZhGv6xqIvz =5MZz -----END PGP SIGNATURE----- --=-=-=--