* lisp/ob-core.el (org-babel-result-to-file): When file path in the
result contains attachment dir, reduce the path to relative file name
when generating attachment: link.
* testing/lisp/test-ob.el (test-ob-core/dir-attach): Add test.
Reported-by: Johan Tolö <johan@toloe.se>
Link: https://orgmode.org/list/875yesnia6.fsf@toloe.se
* lisp/ob-core.el (org-babel-read-list): Return a simple list instead
of list of lists. Document this in the docstring.
* testing/lisp/test-ob-java.el (ob-java/read-return-list):
(ob-java/read-list-return-array):
(ob-java/read-return-list-with-package): Fix tests assuming previous
behavior.
* testing/lisp/test-ob.el (test-ob/simple-variable-resolution): Add
new tests.
* etc/ORG-NEWS (List references in source block variable assignments
are now proper lists): Document the change.
This commit fixes the broken promise in the manual section 16.4
Environment of a Code Block where the named references to lists should
be converted to simple lists consisting of the top-level items.
The inconsistency existed for a while and possibly lurked into some
third-party packages. So, announcement in NEWS is required.
Reported-by: Alain.Cochard@unistra.fr
Link: https://orgmode.org/list/87pmdqfao4.fsf@localhost
* testing/lisp/test-ob.el (test-ob/org-babel-results-indented-list):
Add a regression test for the recent change to ob-core list formatting
in e700578799.
* lisp/ob-ref.el (org-babel-ref-resolve): When the result an empty
list, then treat it as a list, not as the symbol nil.
* testing/lisp/test-ob.el (test-ob/post-header-arguments): Add new
test.
* etc/ORG-NEWS (Post-processing code blocks can return an empty list):
Document change in behavior.
* lisp/ob-core.el (org-babel-expand-noweb-references): Do not rely on
reference cache being populated as a condition that all the references
in buffer have been processed. Set this information explicitly.
* testing/lisp/test-ob.el (test-ob/noweb-expansion): Add new test.
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables. For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.
Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?
I found some suspicious code, for which I added FIXMEs.
There are also a few changes to the main files.
* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined. [ Needed to get
the tests to pass. ]
* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it). Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.
* lisp/org.el (org-log-beginning): Add FIXME.
* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.
* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.
* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded. Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.
* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler. Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.
* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.
* testing/lisp/test-org-timer.el: Require `org-timer`.
* testing/lisp/test-org-table.el: Require `ox`.
* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded. Also require `capture`, and
add missing `provide` statement.
* testing/lisp/test-org-pcomplete.el: Require `org`.
* testing/lisp/test-org-list.el: Require `org-list` and `org`.
* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.
* testing/lisp/test-org-footnote.el: Require `org-footnote`.
* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded. Also require `org` and
`org-inlinetask`.
* testing/lisp/test-org-duration.el: Require `org-duration`.
* testing/lisp/test-org-datetree.el: Require `org-datetree`.
* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.
* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.
* testing/lisp/test-org-archive.el: Require `org-archive`.
* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.
* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.
* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.
* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.
* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.
* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.
* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded. Use `with-current-buffer`.
* testing/lisp/test-ob-julia.el: Require `ob-core`.
* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.
* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.
* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.
* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
* lisp/ob-ref.el (org-babel-ref-resolve): Add support for
`named-block[]' syntax, resolving to the contents of a named-block.
* lisp/ob-core.el (org-babel-read-element): Read a code block into its
contents, like other blocks.
* testing/listp/test-ob.el (test-ob/block-content-resolution): Test
block content resolution.
* doc/org-manual.org: Document syntax.
* etc/ORG-NEWS: Document syntax.
* ob-core.el (org-babel-merge-params): Specifying the symbol 'attach`
or string "'attach" as the value of the `:dir' header now functions as
":dir (org-attach-dir nil t) :mkdirp t".
(org-babel-result-to-file): Optional TYPE argument accepts symbol
'attachment to fixup up paths under `(org-attach-dir)' and use the
link type "attachment:" when that is detected.
(org-babel-insert-result): Pass symbol `attachment' as TYPE to
`org-babel-result-to-file'.
* org-attach.el (org-attach-dir): Added autoload header to simplify
dependencies necessary to support this feature (called in
`org-babel-merge-params').
* test-ob.el (test-ob-core/dir-attach): Added unit test for the new
attach feature.
* lisp/org-clock.el (org-clock-in):
(org-clock-find-position):
(org-clock-out):
* lisp/org.el (org-add-planning-info):
(org-scan-tags):
(org-global-tags-completion-table):
(org-make-tags-matcher):
(org-tags-expand):
(org--property-local-values):
(org-read-date-analyze):
(org-revert-all-org-buffers):
(org-beginning-of-line): Make sure that we inherit invisible state
when inserting text.
(org-sort-entries): Preserve invisible state after replace-match.
(org-log-beginning): Do not try to move by visible lines.
* lisp/org-macs.el (org-preserve-local-variables): Do not try to
preserve overlays.
* lisp/ox.el (org-export--generate-copy-script): Preserve folding
properties in export buffer.
* testing/lisp/test-ob.el (test-ob/preserve-results-indentation): Fix
test failure.
* testing/lisp/test-org.el (test-org/meta-return):
(test-org/custom-properties): Use new folding.
* lisp/ob-core.el (org-babel-disassemble-tables,
org-babel-gnuplot-process-vars): Use `proper-list-p' check instead of
`listp'.
(org-babel-disassemble-tables): Check list length before trying to
remove hline from a table assignment.
* testing/lisp/test-ob.el (test-ob/cons-cell-as-variable): Add the
test.
* doc/org-manual.org (Type): Document empty vector argument for
file-desc.
* etc/ORG-NEWS (New argument for ~file-desc~ babel header): Add entry
to NEWS.
* lisp/ob-core.el (org-babel--file-desc): Add new function to evaluate
file description value.
(org-babel-execute-src-block): Correctly evaluate file description
when executing src block.
(org-babel-insert-result): Correctly evaluate file description value
when inserting the result of src block execution into the buffer.
* testing/lisp/test-ob.el (test-ob/file-desc-header-argument): Add
test case for new behavior.
* lisp/ob-core.el (org-babel-import-elisp-from-file): Don't try to
convert empty file to a table.
* testing/lisp/test-ob.el (test-ob/import-elisp-from-file): Add tests.
If org-babel-import-elisp-from-file is called with an empty file
(which many ob- libraries do when there are no results), feeding that
to org-table-import leads to a beginning-of-buffer error. Before
14878f3f9 (ob-core: Display warning on failure to read results,
2020-05-21), this error was hard to notice because, after catching it,
it was reported as a quickly buried message. After that commit, it is
displayed as a warning, which is not appropriate for the common and
unproblematic case of empty results.
Avoid the warning by only doing the table conversion if the file has
content. Another option would be to do the table conversion but add a
beginning-of-buffer arm to the surrounding condition-case. However,
that risks swallowing other sources of that error.
Reported-by: Colin Baxter <m43cap@yandex.com>
<https://orgmode.org/list/878se3nhbj.fsf@yandex.com>
* ob-core.el (org-babel-execute-src-block): Source code block header
argument `:file-mode' can set file permissions if `:file' argument is
provided.
(org-babel-common-header-args-w-values): Add `:file-mode' to common
header arguments.
TINYCHANGE
* lisp/ob-core.el (org-babel-check-confirm-evaluate): Expand noweb
references in the body passed to org-confirm-babel-evaluate.
* testing/lisp/test-ob.el (test-ob/check-eval-noweb-expanded): New
test.
When noweb references are set to be expanded for evaluation,
org-confirm-babel-evaluate should receive the expanded body so that it
can make its decision based on what actually will be evaluated
(without resorting to calling org-babel-get-src-block-info itself).
Note that this results in up to three calls to
org-babel-expand-noweb-references. Possible ways to avoid this are
discussed at the thread referenced below.
Reported-by: Tom Gillespie <tgbugs@gmail.com>
https://orgmode.org/list/CA+G3_PNi3uMvBiWgBdKuC3C6VJt1T1j-RKH43LRqYbr+4NS8ZA@mail.gmail.com/
* lisp/ob-core.el (org-babel-result-end): Handle results in special
blocks.
* testing/lisp/test-ob.el (test-ob/replace-special-block-result): New
test.
* lisp/ob-core.el (org-babel-execute-src-block): Fix behaviour of
":dir path" when ":mkdirp" is not defined.
* testing/lisp/test-ob.el (test-ob-core/dir-mkdirp): Add a test case.
TINYCHANGE
* lisp/ob-core.el (org-babel-execute-src-block): Make directory if
":dir path" does not exist when ":mkdirp yes" exist.
* doc/org-manual.org (Header arguments): Document it.
* testing/lisp/test-ob.el: Add a specific testing file for ob-core.el,
and add a testing for ":mkdir yes" work with :dir header argument
usage.
* lisp/ob-core.el (org-babel--string-to-number): Fix the regular expression.
* testing/lisp/test-ob.el (test-ob/string-to-number): Test cases.
If people write the data in the form "0001"", it means that he wants to
treat it as a string.
TINYCHANGE
> #+name: TBL
> | id | name | age |
> |------|--------|-----|
> | 0001 | Apollo | 16 |
> | 0002 | Bmw | 16 |
>
> #+BEGIN_SRC emacs-lisp :results value pp :var tbl=TBL
> (mapc 'print tbl)
> #+END_SRC
>
> #+RESULTS:
> : (("0001" "Apollo" 16)
> : ("0002" "Bmw" 16))
TINYCHANGE
* lisp/ob-core.el (org-babel-execute-src-block): ":results file" must
be specified in order to return a file.
(org-babel-merge-params): :file and :file-ext no longer imply :results
file.
* testing/lisp/test-ob.el (test-ob/indented-cached-org-bracket-link):
(test-ob/result-file-link-type-header-argument):
(test-ob/result-graphics-link-type-header-argument): Update tests.
Deducing the results from some other arguments is not obvious.
Moreover, it prevents users from setting, e.g., :file-ext, in a node
property, as every block would then create a file.
Reported-by: Alex Fenton <alex@pressure.to>
<http://lists.gnu.org/r/emacs-orgmode/2018-05/msg00469.html>
* lisp/ob-core.el (org-babel-execute-src-block): Handle "link" :results
format.
* doc/org-manual.org: Add document for new result format "link".
* testing/lisp/test-ob.el (test-ob/result-file-link-type-header-argument):
New test.
* testing/lisp/test-ob.el (test-ob/org-babel-remove-result--results-list):
Removed the inner list. Expectation "- (quote (4 5))" did not match
the result "- '(4 5)". I think this difference is not worth testing
in this test.
* lisp/ob-core.el (org-babel-expand-noweb-references): Get :noweb-ref
from definition instead of point of call.
* testing/lisp/test-ob.el (test-ob/noweb-expansion-1):
(test-ob/noweb-expansion-2): Merge tests. Add test.
* lisp/ob-core.el (org-babel-use-quick-and-dirty-noweb-expansion):
Remove variable.
(org-babel-expand-noweb-references): Update function.
* doc/org.texi (noweb-ref): Document new behaviour.
(Noweb reference syntax): Delete reference to removed variable.
`org-babel-use-quick-and-dirty-noweb-expansion' main use is to speed
up Noweb expansion when expanding only by name. By distinguishing
name and reference expansion, we no longer need this variable. In the
first case, the expansion is quicker anyway, and in the second case,
we most certainly need an accurate expansion.