Hi Immanuel,
immanuel <[email protected]> writes:
> #+BEGIN_SRC emacs-lisp :lexical t :tangle elisp.el
> (defun lex-p ()
> "Return t if lexical binding is in effect."
> (interactive)
> (let (lex
> _lex-p)
> (let ((lex t))
> (setq _lex-p
> (lambda ()
> lex)))
> (if (funcall _lex-p)
> (message "lexical binding")
> (message "no lexical binding"))))
>
> (lex-p)
> #+END_SRC
>
> When evaluating this code block with C-c C-c I get lexical binding.
> When tangling it or with org-babel-load-file I get no lexical
> binding.
You can declare lexical-binding in the source block, like this:
#+BEGIN_SRC emacs-lisp :lexical t :tangle elisp.el
;;; elisp.el -*- lexical-binding: t; -*-
(defun lex-p ()
"Return t if lexical binding is in effect."
(interactive)
(let (lex
_lex-p)
(let ((lex t))
(setq _lex-p
(lambda ()
lex)))
(if (funcall _lex-p)
(message "lexical binding")
(message "no lexical binding"))))
(lex-p)
#+END_SRC
#+RESULTS:
: lexical binding
--
Bastien