emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: No Wayman <iarchivedmywholelife@gmail.com>
To: theophilusx@gmail.com
Cc: emacs-orgmode@gnu.org
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/)]
Date: Thu, 09 Sep 2021 22:38:06 -0400	[thread overview]
Message-ID: <87o89184h1.fsf@gmail.com> (raw)
In-Reply-To: <871r5xfa8t.fsf@gmail.com>

> 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 
You can verify this with the following src block:

#+begin_src emacs-lisp :lexical t :tangle ./dynamic.el :results 
(symbol-value lexical-binding)

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 
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)

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):



  reply	other threads:[~2021-09-10  4:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 22:58 No Wayman
2021-09-10  1:53 ` Tim Cross
2021-09-10  2:38   ` No Wayman [this message]
2021-09-10  6:32 ` Timothy
2021-09-10 15:12   ` No Wayman
2021-09-10 15:15     ` No Wayman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o89184h1.fsf@gmail.com \
    --to=iarchivedmywholelife@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=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/)]' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).