From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wrUKE3JbVF99MQAA0tVLHw (envelope-from ) for ; Sun, 06 Sep 2020 03:45:54 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SLmaDnJbVF+FZQAA1q6Kng (envelope-from ) for ; Sun, 06 Sep 2020 03:45:54 +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 5788B9404C4 for ; Sun, 6 Sep 2020 03:45:53 +0000 (UTC) Received: from localhost ([::1]:60548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kElck-0005Ru-EE for larch@yhetil.org; Sat, 05 Sep 2020 23:45:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kElcL-0005RE-Rg for emacs-orgmode@gnu.org; Sat, 05 Sep 2020 23:45:25 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:62271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kElcJ-0003N4-7a for emacs-orgmode@gnu.org; Sat, 05 Sep 2020 23:45:25 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 855A673A97; Sat, 5 Sep 2020 23:45:18 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=GlZGmEuAK9pkH+uMu8qp20nOtn8=; b=l+oNsZ YqoxlKN4ZWWrXowVb8EB++ZAuB4Bt0HMhIqgvfeTOjq5yHj9UFZ22/szcIZBcmhZ Ayj85dJaXA7qYmPyDGUfN/HzEMcROCw+GemiV5vBuiranZQPD8WRYIx6MJ8O5/DU UyE/xgn6PbV0VfAH66KSrBvy1jJbglwe/UNpI= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 6A29373A95; Sat, 5 Sep 2020 23:45:18 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=3iIaujsPPvYdI/KKtUGRszfRxTDopfq6ej/hrQC0B2I=; b=TTQJByQSan8T5pPMKDAKgK3DOMgWSmo2BDzJe1HYlxOcSyx5HwhZ6TFnYTW0wXFhF3AljA4wVf07Wy4eUA4ahWWZ6+jskSVvKbVl2Sb6yfcZxs+GKYh5ZhlIy6Pp1+aVR2vkfC247ih2KKgyp3IzdV1N02z/sYWy9xndPQDD6hg= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 9955173A94; Sat, 5 Sep 2020 23:45:17 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Tom Gillespie Subject: Re: [PATCH] lisp/ob-core.el: pass expanded body to org-confirm-babel-evaluate In-Reply-To: References: <87k0ywyydv.fsf@kyleam.com> <87k0yg4efs.fsf@kyleam.com> Date: Sat, 05 Sep 2020 23:45:16 -0400 Message-ID: <87wo1736wj.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 614872A0-EFF3-11EA-9C96-2F5D23BA3BAF-24757444!pb-smtp2.pobox.com Received-SPF: pass client-ip=64.147.108.71; envelope-from=kyle@kyleam.com; helo=pb-smtp2.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/05 23:45:18 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: emacs-orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=l+oNsZ Y; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=TTQJByQS; dmarc=none; 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-Spam-Score: -1.21 X-TUID: lPJd/i7JD9wY Tom Gillespie writes: > Hi Kyle, > Following up in this thread having investigated the impact of coderefs. > My conclusion is that coderefs need to be stripped out before they are > passed to org-confirm-babel-evaluate. They are not present in the > executed code and removing them is not something that a definition > of org-confirm-babel-evaluate should have to know anything about. > Right now I work around them by suggesting that users comment > out their coderefs. This works because my use case is restricted to > elisp code and I strip the comments using read, but other languages > would not have such an easy solution. Thanks for revisiting this. This change (df5a83637) hasn't made it into a release yet, so it'd be good to make this move now. > I have included a patch against maint that reuses the let block > from org-babel-execute-src-block to accomplish this. > diff --git a/lisp/ob-core.el b/lisp/ob-core.el > index cd876da0f..44b02feb9 100644 > --- a/lisp/ob-core.el > +++ b/lisp/ob-core.el > @@ -240,9 +240,14 @@ should be asked whether to allow evaluation." > (funcall org-confirm-babel-evaluate > ;; Language, code block body. > (nth 0 info) > - (if (org-babel-noweb-p headers :eval) > - (org-babel-expand-noweb-references info) > - (nth 1 info))) > + (let ((coderef (nth 6 info)) > + (expand > + (if (org-babel-noweb-p params :eval) params is undefined here. I've s/params/headers/ when applying. > + (org-babel-expand-noweb-references info) > + (nth 1 info)))) > + (if (not coderef) expand > + (replace-regexp-in-string > + (org-src-coderef-regexp coderef) "" expand nil nil 1)))) > org-confirm-babel-evaluate)))) > (cond > (noeval nil) Okay, so this is equivalent to your original patch, though your initial approach avoided duplicating the logic, which I think is worth doing. I'd like to make sure this gets in before a release, so I've applied this message's patch (3e1c0b0f4) and then followed it up with a patch that adds a test, and another that extracts the duplicated logic out to a helper (as in your original patch).