babel: Allow shell-command-on-region to execute remotely
commit2056d7d419aabfc9a5fd59674f66e58862f14e32
authorDan Davison <davison@stats.ox.ac.uk>
Sun, 21 Feb 2010 05:34:23 +0000 (21 00:34 -0500)
committerDan Davison <davison@stats.ox.ac.uk>
Sat, 27 Feb 2010 19:14:08 +0000 (27 14:14 -0500)
tree8737e549b338d81abf8a0b197eccafdb6a70c591
parentb3d5a1eb3984bec91e32965343e7564bb8ac64ee
babel: Allow shell-command-on-region to execute remotely
These changes solve two problems: both are discussed in the following thread

http://lists.gnu.org/archive/html/tramp-devel/2010-02/msg00025.html

of which a summary follows.

Firstly, shell-command-on-region does not work with tramp in the same
way that shell-command does. I.e. whereas

(let ((default-directory "/user@remote-host:"))
  (shell-command "hostname" t))

gives the remote hostname,

(let ((default-directory "/user@remote-host:"))
  (shell-command-on-region (point) (mark) "hostname" t))

does not.

The reason is that shell-command-on-region calls call-process-region,
which does not use a tramp handler for remote files. However, such a
file handler does exist (unused) in the tramp sources:
tramp-handle-call-process-region. There is a slight problem in that
there is a bug in that function definition in current tramp (which has
persisted because the function is not normally used).

Therefore, we define an org-babel version of
tramp-handle-call-process-region which fixes the bug, and we bind
call-process-region to org-babel-tramp-handle-call-process-region for
the duration of org-babel-execute-src-block.
contrib/babel/lisp/org-babel.el