From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qJzyGKOTOmHAgQEAgWs5BA (envelope-from ) for ; Fri, 10 Sep 2021 01:07:15 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mB/FFKOTOmF7aQAAB5/wlQ (envelope-from ) for ; Thu, 09 Sep 2021 23:07:15 +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 7AAD61F932 for ; Fri, 10 Sep 2021 01:07:14 +0200 (CEST) Received: from localhost ([::1]:46220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOT8S-0003qp-Fa for larch@yhetil.org; Thu, 09 Sep 2021 19:07:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOT7p-0003qI-Rc for emacs-orgmode@gnu.org; Thu, 09 Sep 2021 19:06:33 -0400 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:44930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOT7o-000362-1s for emacs-orgmode@gnu.org; Thu, 09 Sep 2021 19:06:33 -0400 Received: by mail-qk1-x72f.google.com with SMTP id c10so2670qko.11 for ; Thu, 09 Sep 2021 16:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:from:to:subject:date:message-id:mime-version; bh=ClcNFda28GRvWdXzNHbV9sL0WvrD6iTlc2sjbchrCW4=; b=oKgnSZE/dxqn0LohLiBIaYEDNmeU1ec2HmH2+AGfSH+w5ykZycCSH/tG8DmWjDVBoC +OEZcZGk2YJ1922G6erCttT/IJluSkNHBcSmz7gND2x2H9FIPige1c0aG3KtoZH4iiOb 0gMRRpRjadIM43JALsUlLmb/xth7XeTl7v2IR/PSAbicFqnQKzrTTwNgMdW1vwE5TYuL MegqU/+SZRi06LYAJImqcSsmuB3o4kerfYlorEcYmSTmBSXc8Cogapeh/zgftZRrOZPC NRAdxYkrkOyCmx77PPsyn8zBlfofrgQ+6q56xKVUQJf5CxKnqe5aR1H1AXj4N46PWkTW CM7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=ClcNFda28GRvWdXzNHbV9sL0WvrD6iTlc2sjbchrCW4=; b=2mRLLOlgs/L5yhr+gjMR1c01+G/qOwApVxYFifEKAZZsJTtctopIKS5tl4xCs2iOcQ Mi8QvnvpEjQcPE9FaDeNbaKDHLcdOkcmIwvUYrQka2WdXJLMn8yXsh3NrSNb72HPzPH6 1+3k3Bt+4UFUNBlk/9nJWPfnNeA6nZOqHJ14X63H6TZAugNMyEs9uzDvukprgD+37SuQ ZSm2+Bd8BkdLbJZBdJ0F4+E9DIhQBw0i8IPew236aWuatdN7Flnbs6oGVgZT4tAIJuGA N38EGOokFwIkfVwoWH/8nuKtCAk7J+4QTlfvh5oU+ND2fUrp8e/UhwGs2Ywfb/9+uD2J cSig== X-Gm-Message-State: AOAM531n5Uuw0bSdUgPtbolGATvHYVRC4D13DXdKdI3hFIlqZhbf6OR6 S89KtjnvxYa5G22mXC2+tIfLzadJXFw= X-Google-Smtp-Source: ABdhPJzY2WgbAkj1ReRj7aIltUcjxCnSUrkreWVCZg5FEaoZDpXfHvdlXJE9gejINaTv4AIkQURuNQ== X-Received: by 2002:ae9:c115:: with SMTP id z21mr5068485qki.482.1631228790185; Thu, 09 Sep 2021 16:06:30 -0700 (PDT) Received: from arch ([2601:82:c200:166d:afae:ebe6:a0e2:409e]) by smtp.gmail.com with ESMTPSA id q22sm2081488qtn.25.2021.09.09.16.06.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 16:06:29 -0700 (PDT) User-agent: mu4e 1.5.14; emacs 28.0.50 From: No Wayman To: emacs-orgmode@gnu.org Subject: [BUG?][PATCH] Should the `lexical-binding' variable be bound during src block with :lexical t? [9.4.6 (9.4.6-ga451f9 @ /home/n/.emacs.d/straight/build/org/)] Date: Thu, 09 Sep 2021 18:58:23 -0400 Message-ID: <87tuit73ij.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::72f; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qk1-x72f.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=1631228834; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ClcNFda28GRvWdXzNHbV9sL0WvrD6iTlc2sjbchrCW4=; b=uz1x+/fAZhDD1lxZWU9bvH4+qvjPaF5rqEexEaO4AnajQX/8xKsruVtgluJjq1VthTtEGy vAAk1VOtAs86fPsY9IAZSn7VXwFmrG0SlxNADvSK79DvxppklmoHoWEYyVcSVleXIskUlC CIukhXGBH+aWqytHhyJyUKAYC9XVwn1iYvUzQVTZnGPtAXpEC9hh4u/CefHWh90kALfATi mIqt0DYO9twE2WXgjvV2hsn1J3CWscYhGfUt3bymgpuIVL+DwQIcIdG+WoT4xWG+7+53Qx 99vCdwxzqkh+4a2ZYRgmyBUsrUZn5vKoTmieGimwWIDhKtEbuvYhpfQzI26bvQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631228834; a=rsa-sha256; cv=none; b=g78kVX+7dQh1LCswpm5lBY37X4FLZqzEgMsT8msgnsDHVb65pt9ikRZqVF7wYQ82RXajMn QynXkNEPPwxBYDke+0G7nu3xTIppz3RujJkSFoDhuaxkw0Rj4vsSwFX8E2t3OR6x4pjvDW W4eAYywDjwNDUCyMgHFOhR+5Y7pD69ADB0oMMEvxIxNmxwZoJzCw848fcI/fKxNn7Ak3Bi Ods9iqBlfvdMpmlidayJl/umO9p39MZWuVyVYEWJsNXMMimqpFillM6NFX7bM2GYTYWjTP 41eJ1igJp5Q3f3AiBrZfceg6xpPflEvk5G64m4w0anZLd9FqbUdz6noJRznX6A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="oKgnSZE/"; 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: -3.77 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="oKgnSZE/"; 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: 7AAD61F932 X-Spam-Score: -3.77 X-Migadu-Scanner: scn0.migadu.com X-TUID: IXpUb5yf1ZqS --=-=-= Content-Type: text/plain; format=flowed I ran into this with some code I'm writing which checks against `lexical-binding'. Should the following result in "lexical binding enabled" or "lexical binding disabled"?: #+begin_src emacs-lisp :lexical t (message "lexical binding %sabled" (if lexical-binding "en" "dis")) #+end_src Currently the `lexical-binding' variable is not bound because `org-babel-execute:emacs-lisp' passes t to `eval', which enables lexical binding, but does not bind the `lexical-binding' variable. The attached patch binds the variable in the lexical environment. It's a matter of whether or not this is the right thing to do. Thoughts? Emacs : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-09-04 Package: Org mode version 9.4.6 (9.4.6-ga451f9 @ /home/n/.emacs.d/straight/build/org/) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-emacs-lisp-bind-lexical-binding-for-lexical-t-src.patch Content-Description: org-babel-execute-bind-lexical-binding-var >From 42b92303faa86b1e9bd0692fca9469eb6a8f02ce Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Thu, 9 Sep 2021 16:40:02 -0400 Subject: [PATCH] ob-emacs-lisp: bind lexical-binding for :lexical t src blocks * lisp/ob-emacs-lisp.el (org-babel-execute:emacs-lisp): bind lexical-binding in lexical environments Because we use `eval' to execute the src block, this variable needs to be explicitly set. Passing t as eval's LEXICAL arg will not bind this variable. --- lisp/ob-emacs-lisp.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el index d03151f13..6cf387b96 100644 --- a/lisp/ob-emacs-lisp.el +++ b/lisp/ob-emacs-lisp.el @@ -61,7 +61,7 @@ by `org-edit-src-code'.") (defun org-babel-execute:emacs-lisp (body params) "Execute a block of emacs-lisp code with Babel." - (let* ((lexical (cdr (assq :lexical params))) + (let* ((lexical (org-babel-emacs-lisp-lexical (cdr (assq :lexical params)))) (result-params (cdr (assq :result-params params))) (body (format (if (member "output" result-params) "(with-output-to-string %s\n)" @@ -71,7 +71,7 @@ by `org-edit-src-code'.") (member "pp" result-params)) (concat "(pp " body ")") body)) - (org-babel-emacs-lisp-lexical lexical)))) + (when lexical (list (cons 'lexical-binding t) t))))) (org-babel-result-cond result-params (let ((print-level nil) (print-length nil)) -- 2.33.0 --=-=-=--