[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG?][PATCH] Should the `lexical-binding' variable be bound during
From: |
Tim Cross |
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: |
Fri, 10 Sep 2021 11:53:39 +1000 |
User-agent: |
mu4e 1.7.0; emacs 27.2.50 |
No Wayman <iarchivedmywholelife@gmail.com> writes:
> 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?
>
>
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.
Might be worth asking on emacs-devel why (eval FORM t) does not set this
variable?