Function: org-babel-lua-initiate-session-by-key

org-babel-lua-initiate-session-by-key is a byte-compiled function defined in ob-lua.el.gz.

Signature

(org-babel-lua-initiate-session-by-key &optional SESSION)

Documentation

Initiate a lua session.

If there is not a current inferior-process-buffer in SESSION then create. Return the initialized session.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-lua.el.gz
(defun org-babel-lua-initiate-session-by-key (&optional session)
  "Initiate a lua session.
If there is not a current inferior-process-buffer in SESSION
then create.  Return the initialized session."
  ;; (require org-babel-lua-mode)
  (save-window-excursion
    (let* ((session (if session (intern session) :default))
           (lua-buffer (org-babel-lua-session-buffer session))
	   ;; (cmd (if (member system-type '(cygwin windows-nt ms-dos))
	   ;;       (concat org-babel-lua-command " -i")
	   ;;     org-babel-lua-command))
	   )
      (cond
       ((and (eq 'lua-mode org-babel-lua-mode)
             (fboundp 'lua-start-process)) ; lua-mode.el
        ;; Make sure that lua-which-bufname is initialized, as otherwise
        ;; it will be overwritten the first time a Lua buffer is
        ;; created.
        ;;(lua-toggle-shells lua-default-interpreter)
        ;; `lua-shell' creates a buffer whose name is the value of
        ;; `lua-which-bufname' with '*'s at the beginning and end
        (let* ((bufname (if (and lua-buffer (buffer-live-p lua-buffer))
                            (replace-regexp-in-string ;; zap surrounding *
                             "^\\*\\([^*]+\\)\\*$" "\\1" (buffer-name lua-buffer))
                          (concat "Lua-" (symbol-name session))))
               (lua-which-bufname bufname))
          (lua-start-process)
          (setq lua-buffer (org-babel-lua-with-earmuffs bufname))))
       (t
	(error "No function available for running an inferior Lua")))
      (setq org-babel-lua-buffers
            (cons (cons session lua-buffer)
                  (assq-delete-all session org-babel-lua-buffers)))
      session)))