ob-emacs-lisp: Set `lexical-binding' in edit buffers
* lisp/ob-emacs-lisp.el (org-babel-execute:emacs-lisp, org-babel-emacs-lisp-lexical): Factor out the conversion of the :lexical source block argument to a form that is appropriate for `lexical-binding' and the LEXICAL argument to `eval'. * lisp/ob-emacs-lisp.el (org-babel-edit-prep:emacs-lisp): Set `lexical-binding'. * lisp/ob-emacs-lisp.el (org-babel-default-header-args:emacs-lisp): Update docstring.
This commit is contained in:
parent
e73a7f87f9
commit
a2deb8ce76
|
@ -96,6 +96,10 @@ You can add dynamic block into ~org-dynamic-block-alist~ with function
|
||||||
~org-dynamic-block-insert-dblock~ command.
|
~org-dynamic-block-insert-dblock~ command.
|
||||||
|
|
||||||
*** Babel
|
*** Babel
|
||||||
|
**** ob-emacs-lisp sets ~lexical-binding~ in Org edit buffers
|
||||||
|
When editing an Elisp src block, the editing buffer's
|
||||||
|
~lexical-binding~ is set according to the src block's =:lexical=
|
||||||
|
parameter.
|
||||||
**** Add LaTeX output support in PlantUML
|
**** Add LaTeX output support in PlantUML
|
||||||
*** New minor mode to display headline numbering
|
*** New minor mode to display headline numbering
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,9 @@
|
||||||
|
|
||||||
A value of \"yes\" or t causes source blocks to be eval'd using
|
A value of \"yes\" or t causes source blocks to be eval'd using
|
||||||
lexical scoping. It can also be an alist mapping symbols to
|
lexical scoping. It can also be an alist mapping symbols to
|
||||||
their value. It is used as the optional LEXICAL argument to
|
their value. It is used both as the optional LEXICAL argument to
|
||||||
`eval', which see.")
|
`eval', and as the value for `lexical-binding' in buffers created
|
||||||
|
by `org-edit-src-code'.")
|
||||||
|
|
||||||
(defun org-babel-expand-body:emacs-lisp (body params)
|
(defun org-babel-expand-body:emacs-lisp (body params)
|
||||||
"Expand BODY according to PARAMS, return the expanded body."
|
"Expand BODY according to PARAMS, return the expanded body."
|
||||||
|
@ -71,9 +72,7 @@ their value. It is used as the optional LEXICAL argument to
|
||||||
(member "pp" result-params))
|
(member "pp" result-params))
|
||||||
(concat "(pp " body ")")
|
(concat "(pp " body ")")
|
||||||
body))
|
body))
|
||||||
(if (listp lexical)
|
(org-babel-emacs-lisp-lexical lexical))))
|
||||||
lexical
|
|
||||||
(member lexical '("yes" "t"))))))
|
|
||||||
(org-babel-result-cond result-params
|
(org-babel-result-cond result-params
|
||||||
(let ((print-level nil)
|
(let ((print-level nil)
|
||||||
(print-length nil))
|
(print-length nil))
|
||||||
|
@ -88,6 +87,23 @@ their value. It is used as the optional LEXICAL argument to
|
||||||
(org-babel-pick-name (cdr (assq :rowname-names params))
|
(org-babel-pick-name (cdr (assq :rowname-names params))
|
||||||
(cdr (assq :rownames params))))))))
|
(cdr (assq :rownames params))))))))
|
||||||
|
|
||||||
|
(defun org-babel-emacs-lisp-lexical (lexical)
|
||||||
|
"Interpret :lexical source block argument.
|
||||||
|
Convert LEXICAL into the form appropriate for `lexical-binding'
|
||||||
|
and the LEXICAL argument to `eval'."
|
||||||
|
(if (listp lexical)
|
||||||
|
lexical
|
||||||
|
(not (null (member lexical '("yes" "t"))))))
|
||||||
|
|
||||||
|
(defun org-babel-edit-prep:emacs-lisp (info)
|
||||||
|
"Set `lexical-binding' in Org edit buffer.
|
||||||
|
Set `lexical-binding' in Org edit buffer according to the
|
||||||
|
corresponding :lexical source block argument."
|
||||||
|
(setq lexical-binding
|
||||||
|
(org-babel-emacs-lisp-lexical
|
||||||
|
(org-babel-read
|
||||||
|
(cdr (assq :lexical (nth 2 info)))))))
|
||||||
|
|
||||||
(org-babel-make-language-alias "elisp" "emacs-lisp")
|
(org-babel-make-language-alias "elisp" "emacs-lisp")
|
||||||
|
|
||||||
(provide 'ob-emacs-lisp)
|
(provide 'ob-emacs-lisp)
|
||||||
|
|
Loading…
Reference in New Issue