From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4OQvAW1zeWHmOgAAgWs5BA (envelope-from ) for ; Wed, 27 Oct 2021 17:42:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id yNZfOGxzeWGDHwAAbx9fmQ (envelope-from ) for ; Wed, 27 Oct 2021 15:42:36 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 20E7E377B0 for ; Wed, 27 Oct 2021 17:42:36 +0200 (CEST) Received: from localhost ([::1]:48430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfl4U-0007k2-FH for larch@yhetil.org; Wed, 27 Oct 2021 11:42:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfkNP-0003aC-PX for emacs-orgmode@gnu.org; Wed, 27 Oct 2021 10:58:03 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:37808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfkNO-0005Bv-5B for emacs-orgmode@gnu.org; Wed, 27 Oct 2021 10:58:03 -0400 Received: by mail-pl1-x631.google.com with SMTP id n11so2196714plf.4 for ; Wed, 27 Oct 2021 07:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version; bh=bYTP8xWwTTlwHy6If1uVEC27j9npu616200NrgGusBg=; b=EnZRhatJphSJ08BZ8PK66T4TiauCnCDFrMyzM4Qv8xPwJx0ixwfXMc6mmt3Y0nhKWS yLU+c9g8uOXUpGv5vVWG+ULCsv2wfnXW4cFcC7EHrwCyuyze+6FKOTLa42ebYHVrCeaS A3CsnClrJ3owBUoU3cAWCaaSkohDmAjzTS5QptFjKitkKcZaOc0eAbz0ILkgIWJcbZiK M+QBn2tdGgiFzOl+VjpWJdnK/uMnSGbTeWuTuwVhbS/jCSbb9oQswt7MSibspn6ZyX6j +zGIqUdD5S+LI04mTExw0zR+nNjlSRGJEKRhoMYmvAINbChTMSZhC0sV02k8xwmf6FzK u/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=bYTP8xWwTTlwHy6If1uVEC27j9npu616200NrgGusBg=; b=yaruX5gH+TOrCcf3Tel7iCLzJNb+DjO2VyxLx4GT5/P6I6z+iuPJ1ITIrEE7gS/jOp zaE41Z8wdHNNkXoPkrYrwz10+a/kXf1RT81RtVMvTKnPitbE875rIRnnCS7y2C32GvPK nZFdInfdA/61lI83s4U4c1JtgaEcxGR39KqBIMJkMGz7TWawi7w0VM0CcEmF5CXYMNAf TZiffEDndzYbsmt36s6NLhZEXOxZO+qik8+OgTCjJ8rFfzV4LcUCQUI1H5TZfQwzIPXz 4lJ+NZfbZ1iJPSJOFF7Wqku2ffVhez2fOc6740znJQKV+N9VUlzmxYz5460HKGhUNw83 +axQ== X-Gm-Message-State: AOAM532M7k04iilDBMcC5cJIBYVjNby6+1HbMxgisPdgzi5p6+JLl5Ft /nW5O5C9QUgr9bj19WrPK60umNOAmHU= X-Google-Smtp-Source: ABdhPJwaZYTHQA1vgZ1Erk1w4eKBHXZK9bFcyVowYmaqDbPJmKoPca67vU8SS7N6t8kZ49AOAb/+fw== X-Received: by 2002:a17:90a:7025:: with SMTP id f34mr6409724pjk.107.1635346679688; Wed, 27 Oct 2021 07:57:59 -0700 (PDT) Received: from ryzen3950 (c-73-170-229-218.hsd1.ca.comcast.net. [73.170.229.218]) by smtp.gmail.com with ESMTPSA id rm6sm50114pjb.18.2021.10.27.07.57.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 07:57:58 -0700 (PDT) From: Matt Huszagh To: "emacs-orgmode@gnu.org" Cc: Subject: [PATCH] Fix behavior of lambda default header arg vars Date: Wed, 27 Oct 2021 07:57:54 -0700 Message-ID: <87o87abjm5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=huszaghmatt@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1635349356; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=bYTP8xWwTTlwHy6If1uVEC27j9npu616200NrgGusBg=; b=kpQFBjX8g4o4q3he/196vyxKooE2V6I7snyEPA/hz05TOK+wEOHeArMPTTI0rPlvWFIUyT kNLIybI2PYhhBblfap0huK0qbFGjuUftsL4rtm0q8+LFnIv0qpJm6C5xjiwdsD0dUWStzN oBE/5ZlDJmLH52AugOKqY+5oNx7Nf0f/pUTpbCDwbiDW3kiAAcHil8eqSq0KvAJBgbOWF8 KNI2Ukevw/cQZ6Bia7QrjVtVpvt9q3dkWtrKCuoqDS8LvpPDugXK36MiCQgPN9aHG3nYHq 6uRR5JzIVj/Y9DQjO4AyA1Z3Bqb5gSGV1kbulfu6n/pxFcd70xhEeOH+F2Fa2A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635349356; a=rsa-sha256; cv=none; b=mZ4Gno9S8EKs/mMvXwlnJ7g3xf8ndXAa57yyY+sGyE5SBc9bc/TtVmyH0/OvuivAFZqJza 0tmdUmJih3pTRNDQanIfHwu3+2Gv8Ft96iy/j+ckfBQVk/mbTu/ud2C7fY/foWZKMUTUPw RAgBVVTbyXLfqtm49P2Eb9qIWQMsHVUxYoFUyWbmOWslqOX84gprDvY3RrwidFjr9FPRO+ pf4cmAo+r9mB4KVCIvBgro6B7Dt3+toSoFnR2efhgsFTHEOLbGMkxe2B6i+UH3Mstw/JDa mQXFVlHeF0V+9S4Dh5dx1aZOTl7BhhrIDrNa9875bKqlwjd4REMS+mX1lKqc+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EnZRhatJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.63 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=EnZRhatJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 20E7E377B0 X-Spam-Score: -1.63 X-Migadu-Scanner: scn0.migadu.com X-TUID: 73smcQ5p9Ms3 --=-=-= Content-Type: text/plain Hello, :var header arguments can be provided multiple times. This is supported directly at the source block and through the default header argument facility. However, this was not handled correctly when the var was evaluated from a closure in a default header argument (only the last var was taken). This patch fixes that. I've also added documentation explaining how to set multiple vars in the default header argument facility. Thanks, Matt --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-core.el-Fix-behavior-of-lambda-default-header-arg.patch >From 5f02fe4e896e6909fab18e8d90a7e14bdce9d5c4 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Wed, 27 Oct 2021 07:47:20 -0700 Subject: [PATCH] ob-core.el: Fix behavior of lambda default header arg vars * lisp/ob-core.el: Permit multiple :var default header arguments when using closures. Additionally, document how to use default header arguments for arguments that can be provided multiple times. --- lisp/ob-core.el | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 7a9467b0e..21f461a08 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -478,12 +478,21 @@ For the format of SAFE-LIST, see `org-babel-safe-header-args'." This is a list in which each element is an alist. Each key corresponds to a header argument, and each value to that header's value. The value can either be a string or a closure that -evaluates to a string. The closure is evaluated when the source -block is being evaluated (e.g. during execution or export), with -point at the source block. It is not possible to use an -arbitrary function symbol (e.g. 'some-func), since org uses -lexical binding. To achieve the same functionality, call the -function within a closure (e.g. (lambda () (some-func))). +evaluates to a string. Some header arguments (e.g., :var for +some language backends) can be provided multiple times for a +source block. This functionality is also supported for default +header arguments by providing the header argument multiple times +in the alist. For example: + +'((:var . \"foo=\\\"bar\\\"\") + (:var . \"bar=\\\"foo\\\"\")) + +A closure is evaluated when the source block is being +evaluated (e.g. during execution or export), with point at the +source block. It is not possible to use an arbitrary function +symbol (e.g. 'some-func), since org uses lexical binding. To +achieve the same functionality, call the function within a +closure (e.g. (lambda () (some-func))). To understand how closures can be used as default header arguments, imagine you'd like to set the file name output of a @@ -2718,6 +2727,11 @@ parameters when merging lists." (pcase pair (`(:var . ,value) (let ((name (cond + ;; Default header arguments can accept lambda + ;; functions. We uniquely identify the var + ;; according to the full string contents of + ;; the lambda function. + ((functionp value) value) ((listp value) (car value)) ((string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*=" value) (intern (match-string 1 value))) -- 2.31.1 --=-=-=--