From: No Wayman <email@example.com> To: firstname.lastname@example.org Cc: email@example.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/)] Date: Thu, 09 Sep 2021 22:38:06 -0400 [thread overview] Message-ID: <firstname.lastname@example.org> (raw) In-Reply-To: <email@example.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 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
next prev parent 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: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.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/)]' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * 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: https://git.savannah.gnu.org/cgit/emacs/org-mode.git 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).