1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

babel: safer modification of `call-process-region'

This commit is contained in:
Eric Schulte 2010-04-04 17:08:27 -06:00
parent c94c915b02
commit 8d405783cb

View File

@ -226,27 +226,28 @@ block."
(if (boundp 'call-process-region-original) call-process-region-original
(symbol-function 'call-process-region)))
result)
;; (message "params=%S" params) ;; debugging
(flet ((call-process-region (&rest args)
(apply 'org-babel-tramp-handle-call-process-region args)))
(unless (member lang org-babel-interpreters)
(error "Language is not in `org-babel-interpreters': %s" lang))
(if (and (not arg) new-hash (equal new-hash old-hash))
(save-excursion ;; return cached result
(goto-char (org-babel-where-is-src-block-result nil info))
(move-end-of-line 1) (forward-char 1)
(setq result (org-babel-read-result))
(message (replace-regexp-in-string "%" "%%" (format "%S" result))) result)
(setq result (funcall cmd body params))
(if (eq result-type 'value)
(setq result (if (and (or (member "vector" result-params)
(member "table" result-params))
(not (listp result)))
(list (list result))
result)))
(org-babel-insert-result result result-params info new-hash)
(run-hooks 'org-babel-after-execute-hook)
result))))
(unwind-protect
(flet ((call-process-region (&rest args)
(apply 'org-babel-tramp-handle-call-process-region args)))
(unless (member lang org-babel-interpreters)
(error "Language is not in `org-babel-interpreters': %s" lang))
(if (and (not arg) new-hash (equal new-hash old-hash))
(save-excursion ;; return cached result
(goto-char (org-babel-where-is-src-block-result nil info))
(move-end-of-line 1) (forward-char 1)
(setq result (org-babel-read-result))
(message (replace-regexp-in-string "%" "%%" (format "%S" result))) result)
(setq result (funcall cmd body params))
(if (eq result-type 'value)
(setq result (if (and (or (member "vector" result-params)
(member "table" result-params))
(not (listp result)))
(list (list result))
result)))
(org-babel-insert-result result result-params info new-hash)
(run-hooks 'org-babel-after-execute-hook)
result))
(setq call-process-region 'call-process-region-original))))
(defun org-babel-load-in-session (&optional arg info)
"Load the body of the current source-code block. Evaluate the