Commit Graph

87 Commits

Author SHA1 Message Date
Ihor Radchenko c6c5474b7e
ob-exp: Preserve header arguments in source block after processing
* lisp/ob-exp.el (org-babel-exp-process-buffer): Fix infinite loop
when the inline src block replacement is the same as the existing src
block.
(org-babel-exp-code): Support new placeholder %header-args for
non-default header arguments.
(org-babel-exp-inline-code-template):
(org-babel-exp-code-template): Change the templates to include header
arguments.
* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
(ob-exp/exports-inline-code-double-eval-exports-both):
(ob-export/export-with-results-before-block): Adjust tests.
* etc/ORG-NEWS (=ox-org= preserves header non-default arguments in src
blocks): Document the breaking change.

This change fixes ox-org export for src blocks.  Previously src blocks
did not preserve their header arguments.  Now, non-default header
arguments are preserved.

Link: https://github.com/emacsorphanage/ox-pandoc/issues/37
2024-04-24 14:48:19 +03:00
Stefan Monnier 1a5e3f931c
testing: Make all files use `lexical-binding`
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.
2022-09-15 19:17:19 +08:00
Ihor Radchenko 3bbbf77f36
org-babel-exp-process-buffer: Improve performance
* lisp/ob-exp.el (org-babel-exp-src-block): New optional argument
providing ELEMENT at point.
(org-babel-exp-code-template): Use lower-case #+begin/#+end lines to
avoid triggering source code block changes when the blocks are
exported with :exports code and also contain lower-case
 #+begin/#+end.  We prefer lower-case default because other parts of
 Org, like `org-insert-structure-template' default to lower-case as
 well.
(org-babel-exp-process-buffer): Do no disable cache as changes are not
expected to be as frequent anymore.  Pass pre-calculated element at
point to inner function calls to `org-in-commented-heading-p',
`org-in-archived-heading-p', `org-element-context', and
`org-babel-exp-src-block'.  Do not force-replace source block contents
when no change is required.
* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
(ob-export/body-with-coderef):
(ob-exp/src-block-with-affiliated-keyword): Update tests according to
the new `org-babel-exp-code-template'.
2022-06-16 13:21:39 +08:00
Nicolas Goaziou 4941444f45 Merge branch 'maint' 2021-04-13 09:56:16 +02:00
Nicolas Goaziou bcc1b0f1bb ob-exp: Do not comma-escape inline source code
* lisp/ob-exp.el (org-babel-exp-code): Do not comma-escape inline
source code.
* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code): Add test.
2021-04-13 09:55:29 +02:00
Stefan Kangas 8cc992f7b2 Prefer HTTPS to HTTP for links to gnu.org 2021-03-21 14:29:13 -04:00
Kyle Meyer 5450d64202 ob-export: Give more informative error on unknown call reference
* lisp/ob-exp.el (org-babel-exp-process-buffer): Signal user-error
with an informative message rather than letting
org-babel-exp-do-export call fail due to an invalid INFO argument.
* testing/lisp/test-ob-exp.el (ob-exp/unknown-call-reference): Add
test.

Reported-by: Greg Minshall <minshall@umich.edu>
Ref: https://orgmode.org/list/628738.1616259666@apollo2.minshall.org
2021-03-21 13:41:31 -04:00
Bastien 07c6b11258 ob-shell.el: New option `org-babel-shell-results-defaults-to-output'
* lisp/ob-shell.el (org-babel-shell-results-defaults-to-output):
New option.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline): Fix test.

See <https://orgmode.org/list/CA+A2iZaziAfMeGpBqL6qGrzrWEVvLvC0DUw++T4gCF3NGuW-DQ@mail.gmail.com>
2020-09-07 19:30:04 +02:00
Bastien 3e191242dc Fix tests wrt 2f53429413
* testing/lisp/test-ob.el (test-ob/inline-src_blk-default-results-replace-line-1)
(test-ob/just-one-results-block)
(test-ob/org-babel-remove-result--results-default)
(test-ob/specific-colnames): Fix tests.

* testing/lisp/test-ob-tangle.el (ob-tangle/comment-links-at-left-margin): Ditto.

* testing/lisp/test-ob-shell.el (ob-shell/generic-uses-no-arrays)
(ob-shell/bash-uses-arrays)
(ob-shell/generic-uses-no-assoc-arrays)
(ob-shell/bash-uses-assoc-arrays, ob-shell/simple-list): Ditto.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline)
(ob-exp/exports-inline-code): Ditto.

* testing/examples/ob-shell-test.org (Generic shell: no arrays)
(Bash shell: support for arrays)
(Generic shell: no special handing)
(Bash shell: support for associative arrays)
(Generic shell: no special handing)
(Bash shell: support for associative arrays with lists): Ditto.
2020-09-06 22:37:32 +02:00
Bastien f584d37a67 Update copyright year 2019-01-01 11:50:56 +01:00
Nicolas Goaziou 17edaf8c14 "src block" -> "source block" in documentation and comments
* etc/ORG-NEWS (Maxima: new headers ~:prologue~ and ~:epilogue~):
(Texinfo exports inline source blocks as ~@code{}~):
(Default lexical evaluation of emacs-lisp source blocks):
* lisp/ob-clojure.el (org-babel-clojure-default-ns):
* lisp/ob-core.el (org-babel-named-src-block-regexp-for-name):
(org-babel-current-src-block-location):
(org-babel-mark-block):
(org-babel-insert-result):
* lisp/ob-emacs-lisp.el (org-babel-default-header-args:emacs-lisp):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/ob-lob.el (org-babel-lob-ingest):
* lisp/ob-ref.el:
* lisp/org-element.el (org-element-object-restrictions):
(org-element-src-block-parser):
(org-element-inline-src-block-parser):
* lisp/org-lint.el:
(org-lint--checkers):
* lisp/org-pcomplete.el (pcomplete/org-mode/block-option/src):
* lisp/org-src.el (org-edit-inline-src-code):
* lisp/org.el (org-ctrl-c-ctrl-c):
(org-in-src-block-p):
(org-fill-element):
* lisp/ox-html.el (org-html--textarea-block):
(org-html-format-code):
* lisp/ox-latex.el (org-latex-minted-options):
(org-latex-custom-lang-environments):
* lisp/ox-md.el:
* lisp/ox-odt.el (org-odt-format-code):
* lisp/ox.el (org-export-collect-listings):
* testing/lisp/test-ob-exp.el (ob-exp/src-block-with-affiliated-keyword):
* testing/lisp/test-ob.el (test-ob/preserve-results-indentation):
  Correct "src block" occurrences when they do not specifically refer
  to the element type `src-block'.
2018-09-20 11:23:49 +02:00
Nicolas Goaziou 85418667a6 Merge branch 'maint' 2018-02-04 00:31:47 +01:00
Nicolas Goaziou 248bc9631b org-element: Revert regexp change for inline source blocks and babel calls
* lisp/org-element.el (org-element-inline-babel-call-parser):
(org-element-inline-src-block-parser): Revert commit
7efa0f2879.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
* testing/lisp/test-org-element.el (test-org-element/inline-src-block-parser):
Update tests.

Reported-by: Greg Minshall <minshall@acm.org>
<http://lists.gnu.org/r/emacs-orgmode/2018-02/msg00002.html>
2018-02-04 00:30:00 +01:00
Nicolas Goaziou 485f218510 Merge branch 'maint' 2018-01-30 10:12:32 +01:00
Nicolas Goaziou 7efa0f2879 Fix inline src and inline babel calls parsing
* lisp/org-element.el (org-element-inline-babel-call-parser):
(org-element-inline-src-block-parser): Tolerate any prefix before the objects.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
* testing/lisp/test-org-element.el (test-org-element/inline-src-block-parser):
Update tests.

Reported-by: Greg Minshall <minshall@acm.org>
<http://lists.gnu.org/r/emacs-orgmode/2018-01/msg00489.html>
2018-01-30 10:11:02 +01:00
Nicolas Goaziou 99dbca3d4f Remove `org-babel-use-quick-and-dirty-noweb-expansion'
* 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.
2017-10-26 13:09:23 +02:00
Nicolas Goaziou 64bfa2d931 Remove `inline-only' option for `org-export-use-babel'
* lisp/ob-exp.el (org-export-use-babel): Remove `inline-only' option.
(org-babel-exp-process-buffer): Ignore `inline-only' value.

* doc/org.texi (Exporting code blocks): Remove documentation.

* testing/lisp/test-ob-exp.el (ob-export/babel-evaluate): Remove tests.
2017-08-26 10:32:26 +02:00
Nicolas Goaziou 8590c79b3a Fix some failing tests
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-headers):
(test-ob-exp/org-babel-exp-src-blocks/w-no-file): Fix test.

These tests fail when "htmlize" is not available on the machine.
2017-08-19 18:56:31 +02:00
Nicolas Goaziou 36c7cfe9eb Merge branch 'maint' 2017-03-18 10:29:33 +01:00
Nicolas Goaziou b72920344f ob-exp: Fix export of src blocks with pathological name
* lisp/ob-exp.el (org-babel-exp-process-buffer): Discard false
  positives.
* testing/lisp/test-ob-exp.el (ob-exp/src-block-with-affiliated-keyword):
  New test.

Reported-by: Skip Collins <skip.collins@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/112797>
2017-03-18 10:28:15 +01:00
Charles Berry 3b5ce449c4 Replace `org-export-babel-evaluate' with `org-export-use-babel'
* lisp/ob-exp.el (org-babel-exp-process-buffer): Change variable
  name `org-export-babel-evaluate' to `org-export-use-babel'.  Also
  change the name in its `defcustom' and set the `:safe' key.

* lisp/ox-icalendar.el (org-icalendar-export-current-agenda): Change
  variable name.

* lisp/ox.el (org-export-as): Change variable name.

* doc/org.texi (Exporting code blocks): Change variable name.  Amplify
   the explanation of what the variable does.  Add variable index entry.

* testing/lisp/test-ob-exp.el: Change variable name.

* testing/lisp/test-ob-lob.el: Change variable name.

* testing/lisp/test-ox.el: Change variable name.

Users were often confused that setting this variable to `nil' will
cause header arguments to be ignored in addition to preventing code
from being evaluated.  It is hoped that the documentation changes and
the name `org-export-use-babel' will better convey that everything
babel does can be switched off with this variable.
2016-11-13 15:29:33 -08:00
Nicolas Goaziou 3b3fc520aa Fix coderef handling in source blocks
* lisp/ob-core.el (org-babel--normalize-body): Do not remove coderef.
(org-babel-get-src-block-info): Add coderef label information, when
available, to the return value.
(org-babel-execute-src-block): Expand noweb and remove coderefs
non-destructively.
* lisp/ob-lob.el (org-babel-lob-get-info): Adapt to new INFO.

* testing/lisp/test-ob-exp.el (ob-export/body-with-coderef):
* testing/lisp/test-ob.el (test-ob/evaluate-body-with-coderefs): Add
  tests.

Reported-by: Thibault Marin <thibault.marin@gmx.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/108888>
2016-08-28 11:56:14 +02:00
Nicolas Goaziou de24694f05 Turn org-mode into Org or Org mode
Use Org or Org mode instead of org-mode or Org-mode according to
"Documentation standards".
2016-08-23 22:13:56 +02:00
Nicolas Goaziou cfaf0d54d7 ox: Remove `org-export-execute-babel-code'
* lisp/ox.el (org-export-execute-babel-code): Remove function.
(org-export-as): Replace previous function with
`org-babel-exp-process-buffer'.
* lisp/ob-exp.el (org-babel-exp-process-buffer): Change signature.
  Copy buffer before evaluating code.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
(ob-exp/exports-inline-code-double-eval):
(ob-exp/exports-inline-code-eval-code-once):
(ob-exp/exports-inline-code-double-eval-exports-both):
(ob-export/export-with-results-before-block):
(ob-export/export-src-block-with-switches):
(ob-export/export-src-block-with-flags):
(ob-export/export-and-indentation):
(ob-export/export-under-commented-headline):
(ob-export/reference-in-post-header):
(ob-export/babel-evaluate):
(org-test-with-expanded-babel-code):
* testing/lisp/test-ob-lob.el (test-ob-lob/export-lob-lines):
(test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export): Apply
change.

This patch merges `org-export-execute-babel-code' within
`org-babel-exp-process-buffer', removing one level of indirection.  Now,
all the Babel evaluation is on the Babel side.
2016-06-18 22:11:14 +02:00
Nicolas Goaziou ec615b192d Fix `org-export-babel-evaluate' handling
* lisp/ob-exp.el (org-babel-exp-process-buffer): Handle
  `org-export-babel-evaluate' handling.
(org-babel-exp-results): Ignore `org-export-babel-evaluate' since it is
handled as a higher level.

* lisp/ox.el (org-export-as): Allow to short-circuit babel evaluation if
  `org-export-babel-evaluate' is nil.

* testing/lisp/test-ob-exp.el (ob-export/babel-evaluate): New test.

Reported-by: Nicolas Richard <nrichard@ulb.ac.be>
<http://permalink.gmane.org/gmane.emacs.orgmode/106767>
2016-04-28 17:29:14 +02:00
Kyle Meyer 2fc29a1796 Fix "it's" typos
* lisp/ob-C.el (org-babel-expand-body:cpp):
(org-babel-expand-body:C++):
(org-babel-expand-body:D):
(org-babel-expand-body:C):
(org-babel-C-expand-C++):
(org-babel-C-expand-C):
(org-babel-C-expand-D):
* lisp/ob-exp.el (org-babel-exp-src-block):
* lisp/ob-fortran.el (org-babel-expand-body:fortran):
* testing/org-test.el (org-test-buffer):
Correct "it's" typo in docstring.

* doc/org.texi:
Correct "it's" typos.
2016-02-03 23:33:28 -05:00
Nicolas Goaziou 0d24086657 Update some copyright years 2015-02-16 01:40:07 +01:00
Charles Berry 90e18aed9c testing/*: Inline result tests modified to follow current schema
* test/examples/babel.org: Miscellaneous fixes for new inline src
block schema.  Return a scalar to avoid unwanted error.  Return a raw
result from `src_emacs-lisp' to make checking results cleaner than
dealing with `results' macro.

* testing/lisp/test-ob-exp.el: Wrap some expected results in
  `{{{results(' and ')}}}' and drop `=%s=' formatting of others.

* testing/lisp/test-ob-lob.el: Wrap some expected results in
   `{{{results(' and ')}}}'.

* testing/lisp/test-ob.el: Wrap some expected results in `{{{results('
  and ')}}}'.

* testing/lisp/test-ob.el
  (test-org-babel/org-babel-get-inline-src-block-matches,
  test-org-babel/inline-src_blk-results-silent): Tests of inline src
  block matches (and `org-ctrl-ctrl-c') conform to the `:begin' and
  `:end' properties of `org-element-context'.

* testing/lisp/test-ob.el
  (test-org-babel/inline-src_blk-default-results-replace-line-1,
  test-org-babel/inline-src_blk-default-results-replace-line-2):
  Inline results are self replacing.
2015-01-29 12:05:31 -08:00
Aaron Ecay fda70440f4 test: Fixes for running tests interactively.
* testing/examples/babel.org: Change spaces to dashes in  #+name
lines.

* testing/lisp/test-ob-exp.el (org-test-with-expanded-babel-code):
(ob-exp/evaluate-all-executables-in-order):
(ob-exp/exports-inline-code):
(ob-exp/exports-inline):
(ob-exp/exports-inline-code-double-eval):
(ob-exp/exports-inline-code-eval-code-once):
(ob-exp/exports-inline-code-double-eval-exports-both):
(ob-exp/use-case-of-reading-entry-properties):
(ob-exp/export-from-a-temp-buffer):
(ob-export/export-with-results-before-block):
(ob-export/export-under-commented-headline):
* testing/lisp/test-ob-lob.el (test-ob-lob/export-lob-lines):
* testing/lisp/test-ob.el (test-org-babel/inline-src_blk-default-results-replace-line-1):
(test-org-babel/inline-src_blk-default-results-replace-line-2):
(test-org-babel/inline-src_blk-manual-results-replace):
(test-org-babel/inline-src_blk-results-scalar):
(test-org-babel/inline-src_blk-results-verbatim):
(test-org-babel/inline-src_blk-preceded-punct-preceded-by-point):
* testing/lisp/test-ox.el (test-org-export/export-scope):
Bind ‘org-babel-inline-result-wrap’ and/or ‘org-export-babel-evaluate’
so tests work when users have customized these variables.

* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
Add ‘org-trim’ where an extra newline was creeping in.

* testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments):
Neutralize org-babel-insert-result, which was stomping on the buffer
contents and disrupting the test

* testing/lisp/test-org-element.el (test-org-element/block-switches):
Replace (should (and ...)) with multiple (should ...).  This gives
more precise indications of what is wrong when a test fails.
(test-org-element/link-parser): Require org-docview.

* testing/lisp/test-org-timer.el (test-org-timer/other-timer-error):
Add the error type for ‘should-error’.

* testing/lisp/test-ox.el (test-org-export/set-title):
(test-org-export/handle-options):
(test-org-export/with-timestamps):
(test-org-export/comment-tree):
(test-org-export/handle-inlinetasks): Let
‘org-export-filter-body-functions’ and
‘org-export-filter-final-output-functions’ to nil where an empty
string is the expected result.  ‘org-export-filter-apply-functions’
treats an empty string as special, and changes it to nil.  This
creates test failures when the user has customized these variables.

* testing/org-test.el (org-test-with-temp-text): Let ‘org-mode-hook’
to nil.
(org-test-table-target-expect): Require ert since this function calls
some of its should* functions.
2015-01-22 01:52:49 -05:00
Achim Gratz 7070545599 Merge branch 'maint' 2014-09-20 21:55:09 +02:00
Achim Gratz 1113e3e027 test-ob-exp: fix failing test
* testing/lisp/test-ob-exp.el (ob-exp/export-from-a-temp-buffer):
  Check for the correct expected output so the test stops failing.
2014-09-20 21:54:21 +02:00
Nicolas Berthier 6f0843d8a3 ob-core: Preserve inline-ness of source blocks when inserting results
* lisp/ob-core.el (org-babel-insert-result): Preserve inline-ness of
source blocks.

* testing/lisp/test-ob-exp.el: Update newly passing tests.
2014-08-22 14:39:39 +02:00
Nicolas Berthier 795c004396 ob: Support for exporting inline source code
* lisp/ob-exp.el (org-babel-exp-inline-code-template): New
customizable variable to export inline source code (similar to
`org-babel-exp-code-template').
(org-babel-exp-code): New `type' argument to differentiate between
inline and standard code blocks.

* lisp/ob-core.el (org-babel-inline-src-block-regexp): Allow empty set
of switches and header arguments as in "src_sh[]{echo foo;}".  Also
permit spaces before them.

* testint/lisp/test-org-element.el
(test-org-element/inline-src-block-parser): Test extended syntax for
inline source code.

* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code): New
function for testing inline source code handling.  Also add three new
failing tests exhibiting unexpected results with ":results code"
switches.

* testing/lisp/test-ob.el
(test-org-babel/org-babel-get-inline-src-block-matches): Test for
inline source blocks with empty header arguments.

* testing/examples/babel.org: New sections for testing (i) exported
inline source code (used by `ob-exp/exports-inline-code'); (ii)
parsing inline source blocks with empty header arguments (used by
`test-org-babel/org-babel-get-inline-src-block-matches').

Until now pieces of inline source code were handled as standard code
blocks during export.  These changes enable them to be exported.
2014-08-22 14:39:38 +02:00
Nicolas Goaziou df10309489 ob-ref: Properly resolve references in ":post" arguments
* lisp/ob-core.el (org-babel-exp-reference-buffer): New variable, as
  a replacement for `org-current-export-file'.
(org-babel-check-confirm-evaluate): Use new variable.
* lisp/ob-exp.el (org-babel-exp-in-export-file): Use new variable.
(org-babel-exp-get-export-buffer): Remove function.
(org-babel-exp-process-buffer): Change signature.
* lisp/ob-ref.el (org-babel-ref-resolve): Use new variable during
  export in order to properly resolve references.
* lisp/ox.el (org-export-execute-babel-code): Use new variable.

* contrib/lisp/org-wikinodes.el (org-wikinodes-process-links-for-export):
  Remove a cond branch as it is always
  false (`org-current-export-file' couldn't be a string).

* testing/lisp/test-ob-lob.el (test-ob-lob/export-lob-lines): Update
  test.
* testing/lisp/test-ob.el (test-ob/eval-header-argument): Update test.
* testing/lisp/test-ob-exp.el (ob-export/reference-in-post-header):
  New test.

During export, Babel executes sequentially all blocks in the buffer
being exported.  This can lead to modifications preventing some
references from being resolved.  As a workaround, Babel stores
a pristine copy of the buffer in a variable so it can always find
needed references.

Before this patch, the variable storing this copy was
`org-current-export-file' and was dynamically bound in "ox.el".  It
was used to resolve noweb references (`org-babel-expand-noweb-references')
but not regular references (`org-babel-ref-resolve').

Now, the variable is `org-babel-exp-reference-buffer' and it is bound
from `org-babel-exp-process-buffer'.  It is used to resolve all
references.  In particular, this allows to use references in :post
header.

Thanks to Jarmo Hurri for reporting it.
2014-03-19 21:34:56 +01:00
Nicolas Goaziou 05f69e5bf8 ob-exp: During export ignore Babel code under commented headlines
* lisp/ob-exp.el (org-babel-exp-process-buffer): Skip code under
  a commented headline.
* testing/lisp/test-ob-exp.el (ob-export/export-under-commented-headline):
  New test.
2014-03-15 19:40:13 -06:00
Nicolas Goaziou ac2f516edf ob-exp: Do not ignore `org-src-preserve-indentation'
* lisp/ob-exp.el (org-babel-exp-process-buffer): Also check
  `org-src-preserve-indentation' to know when to preserve indentation.
* testing/lisp/test-ob-exp.el (ob-export/export-and-indentation): New
  test.

Thanks to John Hendy for reporting it.
2014-02-01 21:52:43 +01:00
Nicolas Goaziou 63a2a403a9 ob-exp: Fix switches handling upon exporting
* lisp/ob-exp.el (org-babel-exp-code-template): Include switches in
  template.
(org-babel-exp-code): Provide %switches placeholder.
* testing/lisp/test-ob-exp.el (ob-export/export-src-block-with-switches):
  New test.
(ob-export/export-src-block-with-flags): Fix indentation.

This fixes dde6af3a62.  The confusion
came from the fact that "flags" placeholder had two meanings:
the :flags value and the block's switches (e.g., "-n").  This patch
separates these two meanings.
2014-01-29 09:01:43 +01:00
Nicolas Goaziou b79462ba98 ob-exp: Fix a failing test
* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
  Fix a test
2014-01-20 17:25:34 +01:00
Nicolas Goaziou dde6af3a62 ob-exp: Fix export of src blocks with flags
* lisp/ob-exp.el (org-babel-exp-code): Fix export of src blocks with
  flags.
* testing/lisp/test-ob-exp.el (ob-export/export-src-block-with-flags):
  New test.

Thanks to Giuseppe Lipari for reporting it.
2014-01-20 14:20:06 +01:00
Nicolas Goaziou 3f9a6916aa ob-exp: Fix code execution in some corner cases
* lisp/ob-exp.el (org-babel-exp-process-buffer): Make processing more
  robust when results are inserted before source block or when source
  block is followed by multiple blank lines.
* testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block):
  Add test.
2014-01-18 15:32:41 +01:00
Bastien Guerry 7d9a883b50 Update copyright years again.
Hint: copyright years are all updated in Emacs.
2014-01-07 14:18:17 +01:00
Bastien Guerry 0beda99171 Revert "Update copyright years."
This reverts commit 21105594fc.
2014-01-05 06:28:07 +01:00
Bastien Guerry 21105594fc Update copyright years. 2014-01-04 18:56:11 +01:00
Nicolas Goaziou 9154c70a04 Export back-ends: Apply changes to export functions
* contrib/lisp/ox-confluence.el (org-confluence-export-as-confluence):
* contrib/lisp/ox-deck.el (org-deck-export-as-html,
  org-deck-export-to-html):
* contrib/lisp/ox-freemind.el (org-freemind-export-to-freemind):
* contrib/lisp/ox-groff.el (org-groff-export-to-groff,
  org-groff-export-to-pdf):
* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-as-latex,
  org-koma-letter-export-to-latex, org-koma-letter-export-to-pdf):
* contrib/lisp/ox-rss.el (org-rss-export-as-rss,
  org-rss-export-to-rss):
* contrib/lisp/ox-s5.el (org-s5-export-as-html,
  org-s5-export-to-html):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-export):
* lisp/ob-haskell.el:
* lisp/ox-ascii.el (org-ascii-export-as-ascii,
  org-ascii-export-to-ascii):
* lisp/ox-beamer.el (org-beamer-export-as-latex,
  org-beamer-export-to-latex, org-beamer-export-to-pdf):
* lisp/ox-html.el (org-html-export-as-html, org-html-export-to-html):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-latex.el (org-latex-export-as-latex,
  org-latex-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
* lisp/ox-md.el (org-md-export-as-markdown,
  org-md-export-to-markdown):
* lisp/ox-odt.el (org-odt-export-to-odt):
* lisp/ox-org.el (org-org-export-as-org, org-org-export-to-org):
* lisp/ox-publish.el (org-publish-org-to):
* lisp/ox-texinfo.el (org-texinfo-export-to-texinfo,
  org-texinfo-export-to-info):
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-file):
2013-08-07 16:11:42 +02:00
Michael Brand f7e6f1589d Babel: use NAME for src block calls in ERT
* testing/examples/babel.org(use case of reading entry properties):
Adapt to use the new introduced #+NAME for src block calls.
* testing/lisp/test-ob-exp.el(ob-exp/use-case-of-reading-entry-properties):
Adapt to use the new introduced #+NAME for src block calls.
2013-07-01 08:10:11 -06:00
Eric Schulte 22b27789a9 mark a test as expected to fail 2013-06-30 17:53:57 -06:00
Michael Brand b01871f23e Babel: use case of reading entry properties as an ERT
* testing/examples/babel.org: Add test entry for ERT.
* testing/lisp/test-ob-exp.el(ob-exp/use-case-of-reading-entry-properties):
Add expected source block results for ERT.
2013-06-26 11:09:21 -06:00
Nicolas Goaziou 1cac3127c2 Fix tests related to export
* lisp/ob-exp.el (org-babel-exp-process-buffer): Renamed from
  `org-export-blocks-preprocess'.
* lisp/ox.el (org-export-execute-babel-code): Apply previous renaming.
* testing/org-test.el (org-test-at-id): Make sure the function returns
  the value of the last form in its body.
* testing/lisp/test-ob-exp.el: Fix tests.
* testing/lisp/test-ob-lob.el: Fix tests.
2013-02-06 23:06:31 +01:00
Bastien Guerry 60b23bdeac Merge branch 'maint'
Conflicts:
	contrib/lisp/htmlize.el
	etc/schema/od-manifest-schema-v1.2-os.rnc
	etc/schema/od-schema-v1.2-os.rnc
	lisp/org-exp-blocks.el
2013-01-01 16:06:17 +01:00
Bastien Guerry 98cd4687a2 Update copyright years.
Happy new year!
2013-01-01 16:04:24 +01:00