From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Miele Subject: [PATCH] ob-emacs-lisp: Set `lexical-binding' in source editing buffers Date: Sun, 10 Feb 2019 13:57:31 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:39092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsogA-0007tB-PI for emacs-orgmode@gnu.org; Sun, 10 Feb 2019 07:57:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsog8-0000lw-6Y for emacs-orgmode@gnu.org; Sun, 10 Feb 2019 07:57:50 -0500 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:46567) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gsog6-0000kf-G0 for emacs-orgmode@gnu.org; Sun, 10 Feb 2019 07:57:46 -0500 Received: by mail-qt1-x844.google.com with SMTP id y20so9133121qtm.13 for ; Sun, 10 Feb 2019 04:57:44 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org * 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. TINYCHANGE --- lisp/ob-emacs-lisp.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el index cd86f4a20..17952069e 100644 --- a/lisp/ob-emacs-lisp.el +++ b/lisp/ob-emacs-lisp.el @@ -43,7 +43,8 @@ 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 their value. It is used as the optional LEXICAL argument to -`eval', which see.") +`eval', which see. And it is used as the value for +`lexical-binding' in buffers created by `org-edit-src-code'.") (defun org-babel-expand-body:emacs-lisp (body params) "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)) (concat "(pp " body ")") body)) - (if (listp lexical) - lexical - (member lexical '("yes" "t")))))) + (org-babel-emacs-lisp-lexical lexical)))) (org-babel-result-cond result-params (let ((print-level nil) (print-length nil)) @@ -88,6 +87,22 @@ their value. It is used as the optional LEXICAL argument to (org-babel-pick-name (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))) +(defun org-babel-emacs-lisp-lexical (lexical) + "Convert :lexical source block argument 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' according to :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") (provide 'ob-emacs-lisp) -- 2.20.1