Always call org-confirm-babel-evaluate from the head of the code
block being evaluated so that the info may be found with
e.g., (org-babel-get-src-block-info 'light)
* lisp/ob-core.el (org-babel-check-confirm-evaluate): Call
org-confirm-babel-evaluate from code block head.
* lisp/ob-core.el (org-babel-insert-header-arg): Optional arguments
for usage from Emacs Lisp programs. In addition this function will
now insert header arguments in the correct place instead of at the
current point.
This patch is based off of a request and an initial patch supplied by
Daniele Pizzolli.
* lisp/ob-core.el (org-babel-remove-result): Added an option to keep
the results keyword when removing the content of results.
* lisp/ob-core.el (org-babel-default-header-args): It is likely that
someone meant to set :padlines to "yes", but accidentally set
:padnewlines to "yes". Either way lets just remove this which
shouldn't have any functional effect.
Thanks to Rick Frankel for help debugging this problem.
* lisp/ob-core.el (org-babel-merge-params): When merging parameters, if
a variable is replaced with a new value, then delete colnames/rownames
for the original value of that variable.
* lisp/ob-core.el (org-babel-check-confirm-evaluate): Return result of
evaluating the function pointed to by`org-confirm-babel-evaluate'
when it is a functionp and its value as a variable otherwise.
This fixes a regression introduced in 5fe486807e and restores the fix
applied earlier in 8d272b0d3b (and then replaced by a cond form in
ece347e32c, which later got factored out again).
* lisp/ob-core.el (org-babel-find-named-result): Call lines are not
results.
(org-babel-where-is-src-block-result): Don't implicitly name the
results of call lines.
* lisp/ob-exp.el (org-babel-exp-non-block-elements): There is now
another element on the call line info list.
* lisp/ob-lob.el (org-babel-lob-get-info): Return the name (if any)
at the end of the info list.
(org-babel-lob-execute): Pass the name through to execution.
* lisp/ob-core.el (org-babel-get-rownames),
lisp/org-table.el (org-table-transpose-table-at-point): Replace the
inadvertent use of mapcar* (from cl) by plain mapcar and direct cons
manipulation.
The error was not caught at compilation time since both source files
require cl during compilation for using cl macros. These were the
only uses of mapcar* in Org, but I didn't check for other cl
_functions_ (as opposed to macros, which would need to be checked if
their implementation uses cl functions).
* lisp/ob-core.el (org-babel-execute-src-block): Ensure that the
location is set before anything else is done.
* lisp/ob-ref.el (org-babel-ref-parse): Evaluate Emacs Lisp values in
header arguments at the location of the original code block.
* testing/lisp/test-ob.el (test-ob/location-of-header-arg-eval): Test
defending the new header argument evaluation behavior.
* lisp/ob-core.el (org-babel-params-from-properties): Use
`org-babel-current-src-block-location' for evaluating new-style
header-argument properties. Remove superfluous save-match-data
clauses. Comment which properties get evaluated where.
* lisp/ob-gnuplot.el (org-babel-expand-body:gnuplot): Use new header
arguments.
* lisp/ob-core.el (org-babel-common-header-args-w-values): Mention new
header arguments.
(org-babel-expand-body:generic): Use new header arguments.
* doc/org.texi (Specific header arguments): Document new header
arguments.
* lisp/ob-core.el (org-babel-read-result): More robust matching of
examplized ranges.
(org-babel-result-end): More robust matching of examplized ranges.
The `org-babel-params-from-properties' command was calling
`org-babel-merge-params', the output of which was then being fed back
to another call to `org-babel-merge-params'. The merge params
function is not designed to allow this form of recursive calling, and
as a result many variables were being set to empty values.
The first noticed side effect of this bug was the breakage of the
org-babel-load-file command, which relies on default header
arguments (namely :tangle), which were overwritten by the bug above.
The fix involved having the `org-babel-params-from-properties'
function return a list of alists, which may then all be handed to the
top-level merge-params call.
* lisp/ob-core.el (org-babel-params-from-properties): Now returns a list
of alists and does *not* call `org-babel-merge-params'.
(org-babel-parse-src-block-match): Handle new list of lists output of
`org-babel-params-from-properties'.
(org-babel-parse-inline-src-block-match): Handle new list of lists
output of `org-babel-params-from-properties'.
* lisp/ob-exp.el (org-babel-exp-src-block): Handle new list of lists
output of `org-babel-params-from-properties'.
(org-babel-exp-non-block-elements): Handle new list of lists output of
`org-babel-params-from-properties'.
* lisp/ob-lob.el (org-babel-lob-execute): Handle new list of lists
output of `org-babel-params-from-properties'.
* lisp/ob-core.el (org-babel-insert-header-arg,
org-babel-parse-src-block-match): Replace `if' with empty else part
by `when' for readability. (org-babel-params-from-properties):
Inquire for language specific and default header properties.
Language specific header properties take precedence over default
header properties and old-style header property specifications.
This allows for header arguments to be specified as
properties (including inheritance).
#+PROPERTY: header-args :cache "no"
#+PROPERTY: header-args:R :session "*R-property*"
:PROPERTIES:
:header-args: :cache "yes"
:header-args:R: :session "*R-drawer*"
:END:
* doc/org.texi (Top): Documentation for new tangle-mode header argument.
(Specific header arguments): Documentation for new tangle-mode header
argument.
(rownames): Documentation for new tangle-mode header argument.
(tangle-mode): Documentation for new tangle-mode header argument.
* lisp/ob-core.el (org-babel-common-header-args-w-values): Adding the
new :tangle-mode header argument.
(org-babel-read): Read values starting with a "#" character as emacs
lisp.
* lisp/ob-tangle.el (org-babel-tangle): Use the new :tangle-mode header
argument.
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src): Use the
new :tangle-mode header argument.
* lisp/ob-core.el (org-babel-where-is-src-block-head): return
point-marker instead of point.
(org-babel-current-exec-src-block-head): new global variable which is
bound during `org-babel-execute-src-block-maybe'
(org-babel-get-src-block-info): return a list of 7 elements, last
being the header location
Evaluation backends might need to use the exact location of the block in
original org file. For example when inserting the correct source
references for visual debugging. With this patch the information on
current block is available in `org-babel-current-exec-src-block-head'.
* lisp/ob-core.el (org-babel-parse-inline-src-block-match),
lisp/ob-exp.el (org-babel-exp-src-block): Give header arguments from
properties priority over default header arguments.
The previous commit e79e8943de did fix this only in
ob-core.el (org-babel-parse-src-block-match). It was already correct
in ob-lob.el (org-babel-lob-execute).
* lisp/ob-core.el (org-babel-inline-result-wrap): Defcustom controlling
the wrapping of inline results.
(org-babel-examplize-region): Use new defcustom controlling the
wrapping of inline results.
* org-agenda.el (org-agenda-write):
* ob-core.el (org-babel-expand-src-block): Use
`org-called-interactively-p'.
Thanks to Jason L Wright for reporting this.
* lisp/ob-core.el (org-babel-execute-src-block): Return nil in case of
`:results none'. Also run `org-babel-after-execute-hook' in this
circumstance.
Previously, the code returned the string "results silenced" in the case
of =:results none=, as this is the return value of the call to
`message'; additionally, the after-execute hook was not being run.
* ob-core.el (org-babel-insert-result): Fix bug when inserting
results as a list: ensure we split a string containing "\n".
Thanks to Sébastien Vauban for reporting this.
* lisp/ob-core.el (org-babel-when-in-src-block): New macro.
(org-babel-execute-src-block-maybe)
(org-babel-expand-src-block-maybe)
(org-babel-load-in-session-maybe, org-babel-pop-to-session-maybe):
Use it.
org-babel-get-src-block-info is a potentially expensive operation, which
is why its ‘light’ argument exists. But in any case, it is overkill to
query the whole info, if all that is needed is whether point is in a
block or not. Factor the simplified common code out into a macro.
* lisp/ob-core.el (org-babel-execute-src-block): Use `copy-tree'
to prevent setf from modifying users variables withing let-bound
`info' variable.
Otherwise, the setf calls in this function can reach into and change
other configuration variables, such as the library of babel.
* lisp/ob-core.el (org-babel-execute-src-block): Make sure we process
file results before they are passed to the post-processing code block,
and not afterwards. Tangles these two header arguments in the code,
but makes for more intuitive behavior and enables important use cases.
* lisp/ob-core.el (org-babel-common-header-args-w-values): Add :post to
the list of header arguments.
(org-babel-execute-src-block): Post process results when the :post
header argument has been supplied.
* doc/org.texi (var): Remove the "Alternate argument syntax" section
from the documentation.
* lisp/ob-core.el (org-babel-src-name-w-name-regexp): Update the regexp
used to match code block names.
(org-babel-get-src-block-info): Remove the code used to parse this
alternate variable specification syntax.
* lisp/ob-core.el (org-babel-temp-file): For remote hosts, modify the prefix
and leave `temporary-file-directory' unchanged.
The reason setting `temporary-file-directory' doesn't work here is
because `make-temp-file' recursively calls itself (indirectly).
Modifying `temporary-file-directly', affects the recursive calls as well,
which results in a "No such file file or directory" error.
The fix is to leave `temporary-file-directory' unaltered, for remote
hosts, and instead modifying the 'prefix' argument to `make-temp-file'
appropriately.
TINYCHANGE
* lisp/ob-core.el (org-babel-confirm-evaluate-answer-no): Dynamically
scoped variable, if bound non-nil the confirmation dialog will not
be initiated and denial of evaluation is assumed.
The new variable `org-babel-confirm-evaluate-answer-no´ can be bound
to suppress the user interaction as is needed for async export, as
discussed in http://thread.gmane.org/gmane.emacs.orgmode/67719
multiple changes to remove overly long lines.
* lisp/ob-core.el (org-babel-execute-src-block): A cond makes it more
clear that we definitely do not execute without user confirmation.
(org-babel-where-is-src-block-result): Overly long line.
* lisp/ob-core.el (org-babel-check-confirm-evaluate): New macro to
establish bindings based on INFO.
* lisp/ob-core.el (org-babel-check-evaluate): New defsubst that checks
if the evaluation of a code block is disabled. Refactors the first
part of the original function `org-babel-confirm-evaluate´.
* lisp/ob-core.el (org-babel-confirm-evaluate): New defsubst that
checks if the user should be queried and returns the answer. Keeps
the second part of the original function `org-babel-confirm-evaluate´.
* lisp/ob-core.el (org-babel-execute-src-block): Do not ask for
confirmation if the cached result is current.
* lisp/ob-core.el (org-babel-confirm-evaluate): Re-implement using
bindings for common subexpressions.
There was a minor bug in the reporting of an aborted evaluation as
"disabled" when no export was happening and eval-no-export was t since
the state of the export was not checked again.
* lisp/ob-core.el (org-babel-call-process-region-original): Change
declaration into definition with nil initial value at the beginning
of the file and drop the later definition. Add comment that the
dynamic scoping of this variable is done for tramp.
Reverting "Fix a typo I introduced while editing Achim's commit 091bf0"
Reverting "ob-core.el: Do not ask for confirmation if cached value is current"
This reverts commit 091bf02514.
* ob-core.el (org-babel-execute-src-block): Do not run
`org-babel-confirm-evaluate´ if source block has a cache and the
cache value is current (there is no evaluation involved in this
case).
* lisp/org.el (org-reverse-string): Add `org-reverse-string' to
reverse a string.
* lisp/org-id.el(org-id-new, org-id-decode): Replace
`org-id-reverse-string' by `org-reverse-string'.
* lisp/ob-core.el(org-babel-trim): Replace `org-babel-reverse-string'
by `org-reverse-string' and declare it.
TINYCHANGE
* add a header-row delimiter to the tables returned from mysql
* add new sql-specific header args for the database connection, and implements them for mysql
* add support for :colnames (mysql only)
* (minor) add an edebug spec to org-babel-result-cond to allow edebugging through it
* add some doc about what header args are used
The syntax of result hashes with times are now as show below.
#+RESULTS[<TIME> HASH]:
* lisp/ob-core.el (org-babel-result-regexp): Simplified regexp given new
time hash layout.
(org-babel-current-result-hash): New match string.
(org-babel-hide-hash): New match string.
(org-babel-where-is-src-block-result): New match string, and inserting
hashes in the new format.
* ob-core.el (org-babel-next-src-block)
(org-babel-previous-src-block): Rewrite using
`org-next-block'.
* org.el (org-next-block, org-previous-block): New navigation
commands.
(org-mode-map): Bind the new commands to C-c C-F and C-c C-B
respectively.
Thanks to Bill White for suggesting this.
* ob-core.el (org-ts-regexp): Remove duplicate defconst'ing.
(org-babel-result-regexp): Don't use `org-ts-regexp', use a
regexp string directly.
This is not the best solution, we should be able to use
`org-ts-regexp' here, but the dependencies makes it hard.
So let's not define org-ts-regexp twice, just use a raw
regexp instead, and add a FIXME warning about this.
suggested by Thomas Alexander Gerds
* lisp/ob-core.el (org-babel-result-regexp): Now matching time stamp as
well.
(org-babel-hash-show-time): Variable controlling the display of time
stamps.
(org-babel-current-result-hash): With hash time stamps.
(org-babel-hide-all-hashes): With hash time stamps.
(org-babel-where-is-src-block-result): With hash time stamps.
* lisp/ob.el: Only use the :wrap argument up to the first space when creating
the #+END_ directive.
Using an option like ":wrap SRC fundamental" was generating and end marker of
"#+END_SRC fundamental", which caused the new exporter to fail to handle to
block properly.
Patch from Michael Gauland.