forked from mirrors/org-mode
ob-lua: Use lexical binding
* lisp/ob-lua.el (org-babel-lua-initiate-session-by-key): (org-babel-lua-initiate-session): (org-babel-lua-evaluate-session): Silence byte-compiler.
This commit is contained in:
parent
2090efaed7
commit
f795479432
|
@ -1,4 +1,4 @@
|
||||||
;;; ob-lua.el --- Org Babel functions for Lua evaluation
|
;;; ob-lua.el --- Org Babel functions for Lua evaluation -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright (C) 2014, 2016 Free Software Foundation, Inc.
|
;; Copyright (C) 2014, 2016 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
@ -189,13 +189,14 @@ Emacs-lisp table, otherwise return the results as a string."
|
||||||
"Initiate a lua session.
|
"Initiate a lua session.
|
||||||
If there is not a current inferior-process-buffer in SESSION
|
If there is not a current inferior-process-buffer in SESSION
|
||||||
then create. Return the initialized session."
|
then create. Return the initialized session."
|
||||||
(require org-babel-lua-mode)
|
;; (require org-babel-lua-mode)
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(let* ((session (if session (intern session) :default))
|
(let* ((session (if session (intern session) :default))
|
||||||
(lua-buffer (org-babel-lua-session-buffer session))
|
(lua-buffer (org-babel-lua-session-buffer session))
|
||||||
(cmd (if (member system-type '(cygwin windows-nt ms-dos))
|
;; (cmd (if (member system-type '(cygwin windows-nt ms-dos))
|
||||||
(concat org-babel-lua-command " -i")
|
;; (concat org-babel-lua-command " -i")
|
||||||
org-babel-lua-command)))
|
;; org-babel-lua-command))
|
||||||
|
)
|
||||||
(cond
|
(cond
|
||||||
((and (eq 'lua-mode org-babel-lua-mode)
|
((and (eq 'lua-mode org-babel-lua-mode)
|
||||||
(fboundp 'lua-start-process)) ; lua-mode.el
|
(fboundp 'lua-start-process)) ; lua-mode.el
|
||||||
|
@ -205,10 +206,9 @@ then create. Return the initialized session."
|
||||||
;;(lua-toggle-shells lua-default-interpreter)
|
;;(lua-toggle-shells lua-default-interpreter)
|
||||||
;; `lua-shell' creates a buffer whose name is the value of
|
;; `lua-shell' creates a buffer whose name is the value of
|
||||||
;; `lua-which-bufname' with '*'s at the beginning and end
|
;; `lua-which-bufname' with '*'s at the beginning and end
|
||||||
(let* ((bufname (if (and lua-process-buffer
|
(let* ((bufname (if (and lua-buffer (buffer-live-p lua-buffer))
|
||||||
(buffer-live-p lua-process-buffer))
|
|
||||||
(replace-regexp-in-string ;; zap surrounding *
|
(replace-regexp-in-string ;; zap surrounding *
|
||||||
"^\\*\\([^*]+\\)\\*$" "\\1" (buffer-name lua-process-buffer))
|
"^\\*\\([^*]+\\)\\*$" "\\1" (buffer-name lua-buffer))
|
||||||
(concat "Lua-" (symbol-name session))))
|
(concat "Lua-" (symbol-name session))))
|
||||||
(lua-which-bufname bufname))
|
(lua-which-bufname bufname))
|
||||||
(lua-start-process)
|
(lua-start-process)
|
||||||
|
@ -216,11 +216,11 @@ then create. Return the initialized session."
|
||||||
(t
|
(t
|
||||||
(error "No function available for running an inferior Lua")))
|
(error "No function available for running an inferior Lua")))
|
||||||
(setq org-babel-lua-buffers
|
(setq org-babel-lua-buffers
|
||||||
(cons (cons session lua-process-buffer)
|
(cons (cons session lua-buffer)
|
||||||
(assq-delete-all session org-babel-lua-buffers)))
|
(assq-delete-all session org-babel-lua-buffers)))
|
||||||
session)))
|
session)))
|
||||||
|
|
||||||
(defun org-babel-lua-initiate-session (&optional session params)
|
(defun org-babel-lua-initiate-session (&optional session _params)
|
||||||
"Create a session named SESSION according to PARAMS."
|
"Create a session named SESSION according to PARAMS."
|
||||||
(unless (string= session "none")
|
(unless (string= session "none")
|
||||||
(error "Sessions currently not supported, work in progress")
|
(error "Sessions currently not supported, work in progress")
|
||||||
|
@ -349,7 +349,7 @@ function t2s(t, indent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
"
|
"
|
||||||
(format "fd:write(_))
|
(concat "fd:write(_))
|
||||||
fd:close()"
|
fd:close()"
|
||||||
(org-babel-process-file-name tmp-file 'noquote)))
|
(org-babel-process-file-name tmp-file 'noquote)))
|
||||||
(list (format "fd=io.open(\"%s\", \"w\")
|
(list (format "fd=io.open(\"%s\", \"w\")
|
||||||
|
|
Loading…
Reference in a new issue