From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id aL87C5Tz3WTKXQEASxT56A (envelope-from ) for ; Thu, 17 Aug 2023 12:16:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id UHceC5Tz3WSXDwEAauVa8A (envelope-from ) for ; Thu, 17 Aug 2023 12:16:52 +0200 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 22D2D49CE1 for ; Thu, 17 Aug 2023 12:16:51 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=En7vh01I; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1692267411; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ysYbuvfbGlmI+ei9taynaiXTKAlyOEQQZpaNOfeZKwY=; b=ufzgKdfjLqkUXZZAG4t5HdqDDBYj56FsxRHXfCxC1yphbyadNe6WtvlJOZAHOVfaULjLwG /oBnM9oP8zF0t92hscKESi7vGpFpin9GKEP1nTC2C4RaA+rQ6uYVollnyDrYEORVdybKfN s8hZtDT8ESvgNZMO9SoBwVhrr5llpCI60Qb5GLNTcrwYZCZGtqpS5CkAg/T6u3MJ3RTkd3 7ri79C+CMxJxsi9aNg1aTVUpO5TH8/gk8bCe0U3jchpd0YxWgN6MoPW3lh6KhbnWEDFKwg x+SFaTJn3P38OuPdzLhplWgnALYpMlcsHZTagGSPJtG1sTka18TkrXS+iKbHkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=En7vh01I; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1692267411; a=rsa-sha256; cv=none; b=EMdmPkyWm4VrqZG7dypvyF3tN4cabyR/ZpDMo3fNm+uQMG/7tYjv7QZinBlRlLWDYuyOMY p/LdMrT+q6E+KvARhllwEyWq9Ur7FDapa+r/Lna3B/WN//MymBFTkxxYvJpQI8721rIRTk Drox3t7u93P3gnFzunt71J+juHFsgB1HUf73fsN7yGEMbKxaq3/dano9oAf3ZJgRNldVx5 v+i/Jj2frAVqxlYXclfKFSi9/ihqXNlcffmLVk3aH7t+wuy77dC9RWMi7ndCe2fY9WfNDw F2IkcB4vW9bGlU0zBoWsX+LRPhbk/PTjmX0F35hQuU7yWvcAOJcUIKZ5dhC8Xw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qWa2g-0005ED-Ic; Thu, 17 Aug 2023 06:15:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWa2R-0005D8-CF for emacs-orgmode@gnu.org; Thu, 17 Aug 2023 06:15:48 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qWa2M-0002kl-Bo for emacs-orgmode@gnu.org; Thu, 17 Aug 2023 06:15:33 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 113B3240028 for ; Thu, 17 Aug 2023 12:15:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1692267326; bh=+OmxzWC5nH65t4+TVA9To5Gd5RQrkUXn7pvZzvfQIog=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=En7vh01IokGd0sSjZTi0IxxI438OgMcnFVIuhJQb+I5e4xbujIzd/CIcp4cv4+sqj UbomCRf/keWAV/HtcKmTokQbfRvf35flHYTj5jtkE7otX70SQMQxHWJ9DUVAuqW5tI roPaueY/dhcD/DSgvGMhKzYtAhhJzHDblj0DxtBHtCm7W2mEupTwSpu6Ov9G83VT7W Pm19j+dE40ST1E04Jnn10lYn6nNo75Sn9+2J6xElB/ceEpqHfdqHRhvo9QszeIRKo1 T9KYsKoZV73SPT6QeRiZx2ECZV8I0npo/alwQlADNSuK3m221YokSUbcoRvkxAnUgA XRjbXAU0lNmBw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RRLVP1blzz9rxH; Thu, 17 Aug 2023 12:15:25 +0200 (CEST) From: Ihor Radchenko To: Tom Gillespie Cc: emacs-orgmode Subject: Re: [PATCH] ob-tangle.el: restore :tangle closure nil behavior In-Reply-To: References: <877cpvpd4i.fsf@localhost> <87y1ibnx33.fsf@localhost> Date: Thu, 17 Aug 2023 10:15:53 +0000 Message-ID: <87r0o2q8iu.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -8.26 X-Spam-Score: -8.26 X-Migadu-Queue-Id: 22D2D49CE1 X-Migadu-Scanner: mx1.migadu.com X-TUID: 55Qk969W7f/l Tom Gillespie writes: >> My confusion about you patch comes from the fact that >> >> #+begin_src emacs-lisp :tangle (if (= 1 1) "yes") >> 2 >> #+end_src >> >> works just fine on main. > > It appears to work fine on main, but that is because > what is actually happening behind the scenes is that in the test > (unless (or (string= src-tfile "no") ...) ...) the actual comparison is > (string= "(if (= 1 1) \"yes\")" "no") which appears to work, but is > not comparing the result of the closure, only its string value. What I see when tangling a file with the above code block is Debugger entered--returning value: ("emacs-lisp" "2" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:results . "replace") (:exports . "code") (:tangle . "yes") <---------- evaluated (:lexical . "no") (:eval . "never-export") (:comments . "link") (:hlines . "no") (:noweb . "yes") (:cache . "no") (:session . "none")) "" nil 2 "(ref:%s)") (org-babel-get-src-block-info) * (# 1) * (apply # 1) * (org-babel-tangle-single-block 1) (org-babel-tangle-collect-blocks nil nil) (org-babel-tangle nil) (funcall-interactively org-babel-tangle nil) >> I admit that I don't fully understand your use case. > > I want to use a closure to conditionally control whether a block will tangle. > If I hardcode :tangle no, then :var x=(error "oops") will not evaluate. The > (error "oops") is a placeholder for a number of things that will result in > an error if the condition for :tangle (when condition "file-name") is not > satisfied. Do you mean something like #+PROPERTY: headline-args :var x=1 #+begin_src elisp :tangle (if (= x 1) "yes" "no") ... #+end_src ? >> Something like (org-babel-get-heading-arg :tangle info/params) > > I need to go to bed, because I definitely started on an implementation > of that I forgot about it as a potential solution. Yes, this seems like > a better and clearer way to go about it. Let me know if you need any help. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at