Previously "R" could overshadow "Ruby", and "C" could overshadow
"Clojure", causing blocks of the longer language name to fail to
load. This issue has now been fixed
This deals with external process :results value mode for R, ruby,
python, perl and clojure: if the shell process has a non-zero exit
code, a buffer containing stderr is displayed.
Prior to this commit,
OUTPUT-BUFFER nil
REPLACE 'replace
ERROR-BUFFER 'current-buffer
resulted in stdout going with stderr to the current buffer, contra the
docstring. With this change stdout is discarded in this case. The
docstring does stipulate that stdout always should go to *Shell
Command Output*; this change does not make that happen in this case.
At this commit, org-babel-shell-command-on-region is a direct copy of
shell-command-on-region. In addition to switching to use the org-babel
version, we change the argument passed so that they agree with the
docstring of s-c-o-r.
Despite the change in arguments, the same behaviour results because
s-c-o-r does not behave as documented in emacs23. Future commits will
be able to fix these bugs in the org-babel version, as necessary.
This change fixes a bug in the remote execution branch, involving the
way that org-babel-tramp-handle-call-process-region is used
to (conditionally) handle calls to call-process-region. When
org-babel-execute-src-block called itself recursively (e.g. when
resolving a reference to another src block), a circular binding of
symbols and values resulted.
When using ':results value' in certain situations, results are written
to file by the foreign language process and subsequently read from
file by emacs into an elisp table structure. If the foreign language
process is running remotely, then the results are written
remotely. These changes ensure that in that case, an appropriate
remote file name is constructed to read the remote data.
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.
This introduces a new header argument :dir. For the duration of source
block execution, default-directory is set to the value of this header
argument. Consequences include:
- external interpreter processes run in that directory
- new session processes run in that directory (but existing ones are unaffected)
- relative paths for file output are relative to that directory
The name of a directory on a remote machine may be specified with
tramp syntax (/user@host:path), in which case the interpreter
executable will be sought in tramp-remote-path, and if found will
execute on the remote machine in the specified remote directory.
So, for example since the following <<example>> noweb reference
appears behind the SQL comment syntax the entire inserted body will
also be SQL commented
-- <<example>>
expands to
-- this is the
-- multi-line body of example
Note that noweb replacement text which does *not* contain any
newlines will not be affected by this change, so it is still
possible to use inline noweb references.
Thanks to Sébastien Vauban for this idea.
Insertion of new results was failing if the block was followed by
end-of-buffer. Also, if the block was followed by non-empty lines, the
\#+resname was being inserted away from column 0.
pressing tab while on the front of a results line will fold the
results in the same manner as tabbing on the front of a block will
fold the block. To automatically hide all blocks when entering a
new file add the `org-babel-result-hide-all' function to your
`org-mode-hook'
"results" is now an acceptable alias for "resname". Org-babel
will begin inserting results using the "results" option however
either option will remain viable moving forward.
The initial `org-babel-hash-show' characters of the hash will
remain visible. Pressing C-c C-c with the point on one of these
initial characters will copy the hash to the kill ring, should you
need to know it for any particular reason.
This can be overridden with the use of the header argument :cache on
the block, or subtree level. To set the global behavior to caching
add the following to your emacs init
(setq org-babel-default-header-args
(delete '(:nocache) org-babel-default-header-args))
This commit expands the #+resname: line to include a sha1 hash of
the contents of the source-code block (including header arguments).
This hash is saved in raw text in the resname line. When a source
block is evaluated it's hash is recalculated and checked against the
hash in it's results line, if they are equal the current results are
returned with no recalculation.
Optional prefix argument when evaluating a source block will force
re-calculation.
caching behavior can be inhibited through the use of the :nocache
header argument. for global inhibition of caching add :nocache to
the `org-babel-default-header-args' variable.