mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-29 20:35:02 +00:00
babel: Make code block params available when initiating session
This commit is contained in:
parent
215d11c092
commit
f4ae431706
@ -42,8 +42,7 @@ called by `org-babel-execute-src-block'."
|
||||
(save-excursion
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(result-type (fourth processed-params))
|
||||
(ess-ask-for-ess-directory (not (cdr (assoc :dir params))))
|
||||
(session (org-babel-R-initiate-session (first processed-params)))
|
||||
(session (org-babel-R-initiate-session (first processed-params) params))
|
||||
(vars (second processed-params))
|
||||
(column-names-p (and (cdr (assoc :colnames params))
|
||||
(string= "yes" (cdr (assoc :colnames params)))))
|
||||
@ -59,7 +58,7 @@ called by `org-babel-execute-src-block'."
|
||||
|
||||
(defun org-babel-prep-session:R (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((session (org-babel-R-initiate-session session))
|
||||
(let* ((session (org-babel-R-initiate-session session params))
|
||||
(vars (org-babel-ref-variables params)))
|
||||
(mapc (lambda (pair) (org-babel-R-assign-elisp session (car pair) (cdr pair))) vars)
|
||||
session))
|
||||
@ -94,16 +93,17 @@ called by `org-babel-execute-src-block'."
|
||||
name transition-file (if (eq (second value) 'hline) "TRUE" "FALSE")))
|
||||
(format "%s <- %s" name (org-babel-R-quote-tsv-field value))))
|
||||
|
||||
(defun org-babel-R-initiate-session (session)
|
||||
(defun org-babel-R-initiate-session (session params)
|
||||
"If there is not a current R process then create one."
|
||||
(unless (string= session "none")
|
||||
(setq session (or session "*R*"))
|
||||
(if (org-babel-comint-buffer-livep session)
|
||||
session
|
||||
(save-window-excursion
|
||||
(R)
|
||||
(rename-buffer (if (bufferp session) (buffer-name session)
|
||||
(if (stringp session) session (buffer-name)))) (current-buffer)))))
|
||||
(let ((session (or session "*R*"))
|
||||
(ess-ask-for-ess-directory (not (cdr (assoc :dir params)))))
|
||||
(if (org-babel-comint-buffer-livep session)
|
||||
session
|
||||
(save-window-excursion
|
||||
(R)
|
||||
(rename-buffer (if (bufferp session) (buffer-name session)
|
||||
(if (stringp session) session (buffer-name)))) (current-buffer))))))
|
||||
|
||||
(defun org-babel-R-construct-graphics-device-call (out-file params)
|
||||
"Construct the call to the graphics device"
|
||||
|
@ -183,7 +183,7 @@ then create. Return the initialized session."
|
||||
(setq clojure-buffer (org-babel-clojure-session-buffer session)))
|
||||
session)))
|
||||
|
||||
(defun org-babel-clojure-initiate-session (&optional session)
|
||||
(defun org-babel-clojure-initiate-session (&optional session params)
|
||||
"Return the slime-clojure repl buffer bound to this session
|
||||
or nil if \"none\" is specified"
|
||||
(unless (and (stringp session) (string= session "none"))
|
||||
|
@ -168,7 +168,7 @@ called by `org-babel-execute-src-block'."
|
||||
(insert (org-babel-chomp body)))
|
||||
buffer)))
|
||||
|
||||
(defun org-babel-gnuplot-initiate-session (&optional session)
|
||||
(defun org-babel-gnuplot-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session. The current
|
||||
`gnuplot-mode' doesn't provide support for multiple sessions."
|
||||
|
@ -85,7 +85,7 @@
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(defun org-babel-haskell-initiate-session (&optional session)
|
||||
(defun org-babel-haskell-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
;; TODO: make it possible to have multiple sessions
|
||||
|
@ -279,7 +279,7 @@ called by `org-babel-execute-src-block' via multiple-value-bind."
|
||||
;;
|
||||
;; BUG: does not work yet. Error: ad-Orig-error: buffer none doesn't exist or has no process
|
||||
;; UNUSED DEF
|
||||
(defun org-babel-oz-initiate-session (&optional session)
|
||||
(defun org-babel-oz-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
(unless (string= session "none")
|
||||
|
@ -69,7 +69,7 @@ specifying a var of the same value."
|
||||
|
||||
(defvar org-babel-perl-buffers '(:default . nil))
|
||||
|
||||
(defun org-babel-perl-initiate-session (&optional session)
|
||||
(defun org-babel-perl-initiate-session (&optional session params)
|
||||
"Simply return nil, as sessions are not supported by perl"
|
||||
nil)
|
||||
|
||||
|
@ -120,7 +120,7 @@ then create. Return the initialized session."
|
||||
(assq-delete-all session org-babel-python-buffers)))
|
||||
session)))
|
||||
|
||||
(defun org-babel-python-initiate-session (&optional session)
|
||||
(defun org-babel-python-initiate-session (&optional session params)
|
||||
(unless (string= session "none")
|
||||
(org-babel-python-session-buffer (org-babel-python-initiate-session-by-key session))))
|
||||
|
||||
|
@ -115,7 +115,7 @@ Emacs-lisp table, otherwise return the results as a string."
|
||||
"'" "\"" results)))))
|
||||
results)))
|
||||
|
||||
(defun org-babel-ruby-initiate-session (&optional session)
|
||||
(defun org-babel-ruby-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
(unless (string= session "none")
|
||||
|
@ -111,7 +111,7 @@ Emacs-lisp table, otherwise return the results as a string."
|
||||
"'" "\"" results)))))
|
||||
results)))
|
||||
|
||||
(defun org-babel-sh-initiate-session (&optional session)
|
||||
(defun org-babel-sh-initiate-session (&optional session params)
|
||||
(unless (string= session "none")
|
||||
(save-window-excursion
|
||||
(or (org-babel-comint-buffer-livep session)
|
||||
|
@ -279,7 +279,7 @@ of the source block to the kill ring."
|
||||
;; if called with a prefix argument, then process header arguments
|
||||
(if arg (funcall (intern (concat "org-babel-prep-session:" lang)) session params))
|
||||
;; just to the session using pop-to-buffer
|
||||
(pop-to-buffer (funcall (intern (format "org-babel-%s-initiate-session" lang)) session))
|
||||
(pop-to-buffer (funcall (intern (format "org-babel-%s-initiate-session" lang)) session params))
|
||||
(move-end-of-line 1)))
|
||||
|
||||
(defun org-babel-open-src-block-result (&optional re-run)
|
||||
|
Loading…
Reference in New Issue
Block a user