Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode

This commit is contained in:
Carsten Dominik 2010-01-12 08:52:36 +01:00
commit 8623c4e846
7 changed files with 71 additions and 10 deletions

View File

@ -59,7 +59,17 @@ called by `org-babel-execute-src-block'."
"Prepare SESSION according to the header arguments specified in 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))
(vars (org-babel-ref-variables params))) (vars (org-babel-ref-variables params)))
(mapc (lambda (pair) (org-babel-R-assign-elisp session (car pair) (cdr pair))) vars))) (mapc (lambda (pair) (org-babel-R-assign-elisp session (car pair) (cdr pair))) vars)
session))
(defun org-babel-load-session:R (session body params)
"Load BODY into SESSION."
(save-window-excursion
(let ((buffer (org-babel-prep-session:R session params)))
(with-current-buffer buffer
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert (org-babel-chomp body)))
buffer)))
;; helper functions ;; helper functions

View File

@ -140,6 +140,15 @@ specifying a var of the same value."
vars))) vars)))
session-buf)) session-buf))
(defun org-babel-load-session:clojure (session body params)
"Load BODY into SESSION."
(save-window-excursion
(let ((buffer (org-babel-prep-session:clojure session params)))
(with-current-buffer buffer
(goto-char (point-max))
(insert (org-babel-chomp body)))
buffer)))
(defvar org-babel-clojure-buffers '()) (defvar org-babel-clojure-buffers '())
(defvar org-babel-clojure-pending-sessions '()) (defvar org-babel-clojure-pending-sessions '())

View File

@ -143,14 +143,25 @@ called by `org-babel-execute-src-block'."
"Prepare SESSION according to the header arguments specified in PARAMS." "Prepare SESSION according to the header arguments specified in PARAMS."
(let* ((session (org-babel-gnuplot-initiate-session session)) (let* ((session (org-babel-gnuplot-initiate-session session))
(vars (org-babel-ref-variables params)) (vars (org-babel-ref-variables params))
(var-lines (mapconc (var-lines (mapcar
(lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair))) (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair)))
vars))) vars)))
(message "%S" session)
(org-babel-comint-in-buffer session (org-babel-comint-in-buffer session
(mapc (lambda (var-line) (mapc (lambda (var-line)
(insert var-line) (comint-send-input nil t) (insert var-line) (comint-send-input nil t)
(org-babel-comint-wait-for-output session) (org-babel-comint-wait-for-output session)
(sit-for .1) (goto-char (point-max))) var-lines)))) (sit-for .1) (goto-char (point-max))) var-lines))
session))
(defun org-babel-load-session:gnuplot (session body params)
"Load BODY into SESSION."
(save-window-excursion
(let ((buffer (org-babel-prep-session:gnuplot session params)))
(with-current-buffer buffer
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert (org-babel-chomp body)))
buffer)))
(defun org-babel-gnuplot-initiate-session (&optional session) (defun org-babel-gnuplot-initiate-session (&optional session)
"If there is not a current inferior-process-buffer in SESSION "If there is not a current inferior-process-buffer in SESSION
@ -158,7 +169,7 @@ then create. Return the initialized session. The current
`gnuplot-mode' doesn't provide support for multiple sessions." `gnuplot-mode' doesn't provide support for multiple sessions."
(unless (string= session "none") (unless (string= session "none")
(save-window-excursion (gnuplot-send-string-to-gnuplot "" "line") (save-window-excursion (gnuplot-send-string-to-gnuplot "" "line")
(current-buffer)))) gnuplot-buffer)))
(defun org-babel-gnuplot-quote-timestamp-field (s) (defun org-babel-gnuplot-quote-timestamp-field (s)
"Convert field S from timestamp to Unix time and export to gnuplot." "Convert field S from timestamp to Unix time and export to gnuplot."

View File

@ -69,7 +69,17 @@ called by `org-babel-execute-src-block'."
(org-babel-comint-in-buffer session (org-babel-comint-in-buffer session
(mapc (lambda (var) (mapc (lambda (var)
(move-end-of-line 1) (insert var) (comint-send-input nil t) (move-end-of-line 1) (insert var) (comint-send-input nil t)
(org-babel-comint-wait-for-output session)) var-lines)))) (org-babel-comint-wait-for-output session)) var-lines))
session))
(defun org-babel-load-session:python (session body params)
"Load BODY into SESSION."
(save-window-excursion
(let ((buffer (org-babel-prep-session:python session params)))
(with-current-buffer buffer
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert (org-babel-chomp body)))
buffer)))
;; helper functions ;; helper functions

View File

@ -76,13 +76,22 @@ called by `org-babel-execute-src-block'."
(car pair) (car pair)
(org-babel-ruby-var-to-ruby (cdr pair)))) (org-babel-ruby-var-to-ruby (cdr pair))))
vars))) vars)))
;; (message "vars=%S" vars) ;; debugging
(org-babel-comint-in-buffer session (org-babel-comint-in-buffer session
(sit-for .5) (goto-char (point-max)) (sit-for .5) (goto-char (point-max))
(mapc (lambda (var) (mapc (lambda (var)
(insert var) (comint-send-input nil t) (insert var) (comint-send-input nil t)
(org-babel-comint-wait-for-output session) (org-babel-comint-wait-for-output session)
(sit-for .1) (goto-char (point-max))) var-lines)))) (sit-for .1) (goto-char (point-max))) var-lines))
session))
(defun org-babel-load-session:ruby (session body params)
"Load BODY into SESSION."
(save-window-excursion
(let ((buffer (org-babel-prep-session:ruby session params)))
(with-current-buffer buffer
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert (org-babel-chomp body)))
buffer)))
;; helper functions ;; helper functions

View File

@ -66,7 +66,17 @@ function is called by `org-babel-execute-src-block'."
(org-babel-comint-in-buffer session (org-babel-comint-in-buffer session
(mapc (lambda (var) (mapc (lambda (var)
(insert var) (comint-send-input nil t) (insert var) (comint-send-input nil t)
(org-babel-comint-wait-for-output session)) var-lines)))) (org-babel-comint-wait-for-output session)) var-lines))
session))
(defun org-babel-load-session:sh (session body params)
"Load BODY into SESSION."
(save-window-excursion
(let ((buffer (org-babel-prep-session:sh session params)))
(with-current-buffer buffer
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert (org-babel-chomp body)))
buffer)))
;; helper functions ;; helper functions

View File

@ -294,7 +294,8 @@ results already exist."
t))) t)))
(defun org-babel-execute-buffer (&optional arg) (defun org-babel-execute-buffer (&optional arg)
"Replace EVAL snippets in the entire buffer." "Call `org-babel-execute-src-block' on every source block in
the current buffer."
(interactive "P") (interactive "P")
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
@ -304,7 +305,8 @@ results already exist."
(goto-char (match-end 0))))) (goto-char (match-end 0)))))
(defun org-babel-execute-subtree (&optional arg) (defun org-babel-execute-subtree (&optional arg)
"Replace EVAL snippets in the entire subtree." "Call `org-babel-execute-src-block' on every source block in
the current subtree."
(interactive "P") (interactive "P")
(save-excursion (save-excursion
(org-narrow-to-subtree) (org-narrow-to-subtree)