#+PROPERTY: header-args:emacs-lisp :lexical t Setting the property for the whole buffer to have lexical binding in emacs-lisp source blocks. Lexical binding will hold when evaluating any source block where no other ~:lexical~ header arg is present. * Moo :PROPERTIES: :header-args:emacs-lisp+: :noweb-ref moo :END: noweb-ref will make all blocks under this heading expand with =<>= #+begin_src emacs-lisp (+ x 3) #+end_src * Goo :PROPERTIES: :header-args:emacs-lisp+: :noweb yes :header-args:emacs-lisp+: :var foo="bar" :END: turn noweb on so we interpret the =<>= syntax as code to expand setting a var ~foo~ to the string "bar" to be used later. ** Poop properties go down into the subtrees #+begin_src emacs-lisp (let ((x 1)) <>) #+end_src #+RESULTS: : 4 *** Floppy :PROPERTIES: :header-args:emacs-lisp+: :noweb no :END: apparently continuing with the "+" pattern takes the no over the yes above this will fail to expand moo. #+begin_src emacs-lisp (let ((x 1)) <>) #+end_src #+RESULTS: : let: Symbol’s value as variable is void: <> ** Gah Define a function with a free variable x. #+begin_src emacs-lisp :results none (defun getx () x) #+end_src Because ~x~ is lexically bound in this block, ~getx~ will error since ~x~ is not a dynamic variable and isn't bound with indefinite scope. #+begin_src emacs-lisp (let ((x 1)) ; ‘x’ is lexically bound. (getx)) #+end_src #+RESULTS: : Symbol’s value as variable is void: x we can flip lexical binding off for the evaluation of this block and the free variable ~x~ is bound when ~getx~ is evaluated. #+begin_src emacs-lisp :lexical no (let ((x 2)) ; ‘x’ is dynamically bound (getx)) #+end_src #+RESULTS: : 2 ** Bah :PROPERTIES: :header-args:emacs-lisp+: :var foo="baz" :END: overriding the variable in this subtree #+begin_src emacs-lisp foo #+end_src #+RESULTS: : baz * Loo #+begin_src emacs-lisp :noweb-ref defvars (defvar loo) #+end_src * Boo #+begin_src emacs-lisp :noweb-ref defvars (defvar boo) #+end_src * Mama #+begin_src emacs-lisp :noweb yes <> #+end_src