From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mH9hIpXYOmGRYwAAgWs5BA (envelope-from ) for ; Fri, 10 Sep 2021 06:01:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id AIAHHpXYOmE/SgAAbx9fmQ (envelope-from ) for ; Fri, 10 Sep 2021 04:01:25 +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 69A083244 for ; Fri, 10 Sep 2021 06:01:24 +0200 (CEST) Received: from localhost ([::1]:58318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOXj8-0007yI-Iz for larch@yhetil.org; Fri, 10 Sep 2021 00:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOXiL-0007xv-82 for emacs-orgmode@gnu.org; Fri, 10 Sep 2021 00:00:33 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:34501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOXiH-0002x0-7l for emacs-orgmode@gnu.org; Fri, 10 Sep 2021 00:00:32 -0400 Received: by mail-qv1-xf30.google.com with SMTP id e18so513551qvo.1 for ; Thu, 09 Sep 2021 21:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:from:to:cc:subject:in-reply-to:date:message-id :mime-version; bh=oL3ugifpmeYsDzS3K0s+498r1XHWq4yLQstYKJiTQsg=; b=nEy7rOFVmuz6YEKekyGc1a45U3wucX1Ut+8hf0KyEabN5HPH86hR36my7QxV5tbJgE DGVoo8Ypjn8czgoZHyW+UmfZb8tgedLJOkbRPCOVifamnNQQEucMYUEjKN1wkYo6Tykt GKLdxzIOKJdVjyXyYUbLYXQO+lfQntria0GOtW6Yi8KZZwoThwmZGvS3DwMWoYaHcdOJ RPcJvxDtTSa4YMmNg/vai5yZjyn4U6AAacKTy61UYb2UJdocN+Yx3kH+Whgcv2EC/8bV ffnyj5hg9N1CuJ60LkRyzbsFApa+sAIk+VvaNqFjgcnkteSdP03DqxPZS3k7NE4LLrTf hMuQ== 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:cc:subject:in-reply-to:date :message-id:mime-version; bh=oL3ugifpmeYsDzS3K0s+498r1XHWq4yLQstYKJiTQsg=; b=H9jycxpjjkLwypARYAxB09ADDe2EY+DN1hsdwEqSX60+Ig7URuKr2TMpBhjvI1NAeW uDXRzTzw3HvaOLG/I5qC5+eeERDUwVKbvG5EyhNOS8hScb07eZ3xxWiAIv7DKEcmycYT PCEpQV8CpLcszp4cHEI8CpqEOrR/KAudLTqtSR77G7Nz75SNvh8F327MZPsKTC09tGan h2wCcy3J5KZb5s7zQ3fueyRa440C9DEnQuLGmGiko8yi5qw2I0ytOAwt91jGmTZ0O8UB WNLXX4koos0AU6ZUvx5TkGbl6MNe//z13+QlKdj/LULf4eTn9GevSqexfU+Anh8A0kU5 vAWQ== X-Gm-Message-State: AOAM532LLB/5t8mWsx1nUGx4lxZi8S42tuiqFXxb04q/NXJeBG9o0iF8 yL1E1drcHN51ri/z2f+Iq2NFO+zhrPA= X-Google-Smtp-Source: ABdhPJzWoTiceLHBg1QQc3iFNGAgugyyBdHgkem2v3JHmzKxW/0LM6xLFT7Kl76ITEBoNo+PX/6K+w== X-Received: by 2002:a05:6214:527:: with SMTP id x7mr1288177qvw.55.1631246428028; Thu, 09 Sep 2021 21:00:28 -0700 (PDT) Received: from arch ([2601:82:c200:166d:afae:ebe6:a0e2:409e]) by smtp.gmail.com with ESMTPSA id h2sm2933943qkf.106.2021.09.09.21.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 21:00:27 -0700 (PDT) User-agent: mu4e 1.5.14; emacs 28.0.50 From: No Wayman To: theophilusx@gmail.com Subject: Re: [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/)] In-Reply-To: <871r5xfa8t.fsf@gmail.com> Date: Thu, 09 Sep 2021 22:38:06 -0400 Message-ID: <87o89184h1.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qv1-xf30.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: , Cc: emacs-orgmode@gnu.org 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=1631246485; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=oL3ugifpmeYsDzS3K0s+498r1XHWq4yLQstYKJiTQsg=; b=qZgjf/8ti+ah2Uy4Wk5JOqQ/CnLaO2up6FQZQXJkSIJVqm4xqSgtbHKMAgy+p6NX7OMkMb PoYbmquuqRgwnmmlXD5NEkg2YN2Qa1jNAFdCdAJ5aF8sZXSEKLG3YBlfjgyhe25Ag/xQwm BlikNRs4g8QecBECXf2+ODEaktXp+wSKOnOCjiBA6cc+Ce83mfdd386JjoNx99V5NGc263 dxuXuUAqGHagjlg95bhbRbA0DEuLHwxDUMTxwc+PrdkfUEBtEJtFH46lRYb+5wZbRCXwN8 G+kdtRMrvLT6agA85CQAbVaSvqC27UbuoYrDKbIa4xYopHhpz624Ck1VFISz/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631246485; a=rsa-sha256; cv=none; b=dE7jMP24onpshHhBb956ktUaKG1Qb6i2NjSrhzducAwyKRuv47jY/ILACrJl01dgqPILag 6AQu8VeuXLo1kW21RM83VU+AHZfWdK5OFDydUUWwp9CjowbVrZmVLD9E3ywQWQxG5UWO/+ kx+YAAIapu5gKr26/ZlM9798FCB6JdUUE/gXrHdIgxfpyMyJv83+LoMmvImrVHbwWRU94C Pq0ujLJhTFGd731ci7bYtqulKie9bwaPYV0jdk+z9Hfrc71IMkJDTpcFuOuKSLPUtV+YPW cK+OAt4bVgbZjf+/wedcimqpUNFSvyJUiaIqf92tU49l9U6hJOblr03z8d2doA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nEy7rOFV; 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.11 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nEy7rOFV; 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: 69A083244 X-Spam-Score: -3.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: JDt6TrdHckmC > My thoughts on this would be that if lexical-bindings is > supposed to be > bound to t, it should be done by eval when it gets a non-nil > value for > it's optional argument. If I execute (eval FORM t) in an emacs > lisp > buffer, it looks like lexical-bind is not set either, so I don't > think > it should be in org either. To set it means we could get the > same code > behaving differently depending on whether the source block is > 'tangled' > and then evaluated or evaluated within org, which doesn't feel > right. I agree that we should avoid inconsistency. However it is already present. You can verify this with the following src block: #+begin_src emacs-lisp :lexical t :tangle ./dynamic.el :results verbatim (symbol-value lexical-binding) #+end_src 1. `org-babel-execute-src-block' with point in the src block => nil (lexical binding enabled) 2. `org-edit-special' with point in the src block, `eval-last-sexp' within *Org Src* buffer => t (lexical binding enabled) 3. Tangle to the block to "dynamic.el", `eval-last-sexp' within "dynamic.el" => nil (dynamic binding) > Might be worth asking on emacs-devel why (eval FORM t) does not > set this variable? I understand why it doesn't. Elisp can be interpreted independent of a buffer, and different buffers need to distinguish which scope to use. It's more a question of what do we gain by leaving it unbound while evaluating a src block? A user can rebind `lexical-binding' without hurting anything. The only case I can think of is if they intend to use it as a free variable, it won't be free. I can't imagine a use case where that would be true while the user is also explicitly requesting lexical binding, though. IMO, it should be set during evaluation (addressed by my patch). An alternative solution would be to allow one to set the lexical environment as part of the header args. e.g. #+begin_src emacs-ilsp :lexical ((lexical-binding . t) t) (symbol-value lexical-binding) #+end_src That way we offer the full flexibility of `eval' to those who would use it. A separate issue, but one worth considering, is whether or not tangling a `:lexical t` src block should automatically add the file-local variable line in the tangled file. Prior confusion (its not just me, I swear): https://emacs.stackexchange.com/questions/61754/how-can-i-enable-lexical-binding-for-elisp-code-in-org-mode#comment100554_61758 https://lists.gnu.org/archive/html/emacs-orgmode/2019-08/msg00247.html