Commit Graph

270 Commits

Author SHA1 Message Date
Bjarte Johansen b6934e3471 ob-core: Fix indented cached result returning nil
Fix a problem where a source block would return nil oif the result was
cached and it was indented.

* lisp/ob-core.el (org-babel-execute-src-block): Move point to the the
 first character of the result instead of the beginning of the line.

* testing/lisp/test-ob.el
 (test-org-babel/indented-cached-org-bracket-link): Added test to
 to see if the indented cached result returns what it should return.
2015-05-26 10:19:42 +02:00
Nicolas Goaziou 275bb10d76 ob-core: Register :file-ext as allowed header argument
* lisp/ob-core.el (org-babel-common-header-args-w-values):
  Allow :file-ext.

Reported-by: Rainer M Krug <Rainer@krugs.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/97786>
2015-05-22 18:53:38 +02:00
Nicolas Goaziou ed74e5bb9b ob-core: Allow never-export as :eval value
* lisp/ob-core.el (org-babel-common-header-args-w-values): Allow
  "never-export" as :eval value.
2015-05-19 15:38:08 +02:00
Nicolas Goaziou 49a656a409 ob-core: Remove `org-babel-src-name-w-name-regexp'
* lisp/ob-core.el (org-babel-get-src-block-info):
(org-babel-src-block-names): Use
`org-babel-named-src-block-regexp-for-name' instead.
2015-05-01 14:51:57 +02:00
Nicolas Goaziou cec47a635e ob-core: Change `org-babel-named-src-block-regexp-for-name' signature
* lisp/ob-core.el (org-babel-named-src-block-regexp-for-name): Allow
  to match any name.
2015-05-01 14:51:56 +02:00
Nicolas Goaziou 4aeb622336 ob-core: Use `org-next-block'
* lisp/ob-core.el (org-babel-find-named-block):
(org-babel-src-block-names): Use `org-next-block'.
2015-05-01 14:05:46 +02:00
Nicolas Goaziou a4f4343110 ob-core: Fix regexp
* lisp/ob-core.el (org-babel-named-src-block-regexp-for-name): NAME
  needs no be the last affiliated keyword.
2015-05-01 14:03:26 +02:00
Nicolas Goaziou 2e2f68467c ob-core: Update allowed values for :eval header arg
* lisp/ob-core.el (org-babel-common-header-args-w-values):
  Recognize :eval no.

Reported-by: Thomas S. Dye <tsd@tsdye.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/97303>
2015-04-28 22:10:21 +02:00
Nicolas Goaziou 96c53376cc ob-core: Update allowed values for :eval header arg
* lisp/ob-core.el (org-babel-common-header-args-w-values): Add allowed
  values for :eval arg.

Reported-by: Thomas S. Dye <tsd@tsdye.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/97272>
2015-04-28 09:50:35 +02:00
Nicolas Goaziou 1493151b3f ob-core: Improper lists are returned in fixed-width areas
* lisp/ob-core.el (org-babel-insert-result): Improper lists are
  removeable.

When a list cannot be turned into a table, return it in a fixed-width
area so that it can be removed.

Suggested-by: Charles C. Berry <ccberry@ucsd.edu>
<http://permalink.gmane.org/gmane.emacs.orgmode/95430>
2015-02-25 14:41:13 +01:00
Nicolas Goaziou ad7b7efcdc ob-core: Fix inserting improper lists
* lisp/ob-core.el (org-babel-insert-result): Fix output when result is
  an improper list, which cannot be turned into a table.

* testing/lisp/test-ob.el (test-ob/org-babel-insert-result--improper-lists):
  New test.

Reported-by: Daniele Pizzolli <dan@toel.it>
<http://permalink.gmane.org/gmane.emacs.orgmode/95348>
2015-02-23 18:44:52 +01:00
Nicolas Goaziou 7745ef04c9 ob-core: Allow spaces in NAME
* lisp/ob-core.el (org-babel-src-name-w-name-regexp): Allow spaces as
  NAME value.

Suggested-by: Joost Helberg <joost@snow.nl>
<http://permalink.gmane.org/gmane.emacs.orgmode/95175>
2015-02-18 15:02:22 +01:00
Nicolas Goaziou 0d24086657 Update some copyright years 2015-02-16 01:40:07 +01:00
Rainer M. Krug b95f7aa823 ob-core.el: Fix numeric error and add header-args
* lisp/ob-core.el (org-babel-view-src-block-info): when a property
  value was numeric, an error was raised. Fixed by converting property
  value to string before evauation.

* lisp/ob-core.el (org-babel-view-src-block-info): Add property string
  "header args" to output of org-babel-view-src-block-info to make
  debugging of header-args setting problems easier.

* lisp/ob-core.el (org-babel-view-src-block-info): Add property string
  for language specific "header args:LANG" to output of org-babel-view-src-block-info to make
  debugging of header-args setting problems easier.
2015-02-13 00:39:35 +01:00
Charles Berry 37fc8667e0 ob-core.el: inline src block removal bugfix
* ob.core.el (org-babel-remove-inline-result): Removing an inline src
  block result removes all whitespace preceding it. The function is
  now `interactive'.

  * ob-core.el (org-babel-insert-result): The call to
  `org-babel-remove-inline-result' preceeds insertion of whitespace
  and setting location of local variable `inlinep'.

  Daniele Pizzolli reported that cleaning a buffer by evaluating
  `org-babel-remove-inline-result' can leave unwanted whitespace.  That
  bug is fixed, and the function is made `interactive'.
2015-01-30 19:27:54 -08:00
Nicolas Goaziou e33637551d ob-core: Silence byte-compiler 2015-01-30 00:24:22 +01:00
Charles Berry 85ff663ce4 lisp/ob-core.el: Inline source block / babel call results are replaceable
* lisp/ob-core.el (org-babel-remove-inline-result): Delete results of
  current inline src block or inline babel call if it is wrapped in a
  "{{{results(.*)}}}" macro call.

* lisp/ob-core.el (org-babel-get-lob-one-liner-matches): Ensure that
  the point ends up on the same line as, and just before, `call_'
  before setting match-data.

* ob-core.el (org-babel-get-inline-src-block-matches): Use
  `org-element-context' and friends to find inline-src-block.  When
  point is in an inline-src-block (including white space determined by
  :post-blank) set match-data and return `t'.

* lisp/ob-core.el (org-babel-insert-result): Delete any `results'
  macro following current inline src block or babel call; insert
  current value in 'results' macro possibly wrapping RESULT in an
  export snippet or inline source block first.  Use of `:results list'
  or `:results table', or use of a multiline RESULT (after stripping a
  trailing newline) or a list RESULT from an inline src block or babel
  call throws an error.
2015-01-29 12:05:31 -08:00
Nicolas Goaziou 61eedb852f ob-core: Fix error messages
* lisp/ob-core.el (org-babel--script-escape-inner,
  org-babel-script-escape): Error messages do not end with a full
  stop.
2015-01-24 23:20:46 +01:00
Aaron Ecay fa5fd63516 babel: fix up org-babel-script-escape
* lisp/ob-core.el (org-babel--script-escape-inner): New function.
(org-babel-script-escape): Use it.
* testing/lisp/test-ob.el (test-org-babel/script-escape): New test.
2015-01-23 14:36:40 -05:00
Aaron Ecay d45b5a7884 babel: Fix bug in org-babel-get-inline-src-block-matches.
* lisp/ob-core.el (org-babel-get-inline-src-block-matches): Use
`org-looking-at-p' instead of `thing-at-point'.

The latter could give odd results depending on the syntax table.  In
particular, for me (thing-at-point 'word) was returning src_foo in
this context.
2015-01-22 00:44:42 -05:00
Nicolas Goaziou b5072890c3 Fix "Args out of range" when demarcating blocks
* lisp/ob-core.el (org-babel-demarcate-block): Return value from
  `org-babel-where-is-src-block-head' may be nil.

Reported-by: Sébastien Vauban
<http://permalink.gmane.org/gmane.emacs.orgmode/93978>
2015-01-13 17:18:12 +01:00
Nicolas Goaziou fdb0092830 ob-core: Refactor `org-babel-where-is-src-block-head'
* lisp/ob-core.el (org-babel-where-is-src-block-head): Refactor.  In
  particular, do not return a marker, ever.  Also update docstring.
* testing/lisp/test-ob.el (test-ob/org-babel-remove-result--results-org):
  Fix tests containing invalid Org syntax.
2015-01-13 17:16:45 +01:00
Nicolas Goaziou 4947d25c7c ob-core: Add safety test for results keyword value
* lisp/ob-core.el (org-babel-results-keyword): Add safety test.  Fix
  docstring.
2014-12-24 10:35:20 +01:00
Nicolas Goaziou be05318515 ob-core: Fix docstring
* lisp/ob-core.el (org-babel-results-keyword): NAME cannot be used for
  results, as it is a reserved affiliated keyword.
2014-12-24 10:29:44 +01:00
Nicolas Goaziou aa0bfcdcdb Merge branch 'maint'
Conflicts:
	lisp/ob-core.el
2014-12-14 09:41:38 +01:00
Nicolas Goaziou 89a0acc75e ob-core: Source blocks are case-insensitive
* lisp/ob-core.el (org-babel-map-src-blocks,
  org-babel-map-inline-src-blocks): Make sure to ignore case when
  looking for source blocks.

Reported-by: Christopher Genovese <genovese@cmu.edu>
<http://permalink.gmane.org/gmane.emacs.orgmode/93454>
2014-12-14 09:39:08 +01:00
Nicolas Goaziou d0c14a12fd ob-core: Tiny fix
* lisp/ob-core.el (org-babel-active-location-p): Use appropriate
  accessor.
2014-12-14 09:36:50 +01:00
Nicolas Goaziou 203bf5870f org-src: Unify source editing tools
* lisp/org-src.el (org-src-strip-leading-and-trailing-blanklines,
  org-edit-src-force-single-line, org-edit-src-picture,
  org-edit-src-from-org-mode, org-edit-src-allow-write-back-p,
  org-edit-src-beg-marker, org-edit-src-end-marker,
  org-edit-src-overlay, org-edit-src-block-indentation,
  org-edit-src-saved-temp-window-config, org-edit-src-code-timer):
  Remove variables.
(org-src--allow-write-back-p, org-src--beg-marker,
org-src--block-indentation, org-src--code-timer, org-src--end-marker,
org-src--end-marker, org-src--from-org-mode, org-src--overlay,
org-src--saved-temp-window-config, org-src--type,
org-src--babel-info): New variables.

(org-src--construct-edit-buffer-name, org-src--edit-buffer,
org-src--source-buffer, org-src--get-lang-mode, org-src--coordinates,
org-src--goto-coordinates, org-src--element-contents-area,
org-src--make-source-overlay, org-src--on-element-p,
org-src--contents-for-write-back, org-src--edit-element,
org-edit-table.el, org-edit-export-block): New functions.
(org-edit-src-find-buffer, org-src-construct-edit-buffer-name,
org-src-tangle, org-src-in-org-buffer): Remove functions.

(org-edit-src-code, org-edit-fixed-width-region, org-edit-src-abort,
org-edit-src-save): Use new functions and variables.
(org-edit-src-exit): Use new functions and variables.  Change
signature.

* lisp/org.el (org-edit-special, org-indent-line, org-indent-region):
  Use new functions and variables.

* lisp/ob-core.el (org-babel-do-in-edit-buffer): Remove useless check.
(org-babel-expand-src-block): Apply signature change.

This patches resolves discrepancies between source editing tools and
globally simplifies process (auto-save feature, region
preservation...).  It introduces export block editing.  It also moves
internal variables and functions into an appropriate namespace and
delete some unused functions.
2014-11-24 00:07:39 +01:00
Nicolas Goaziou 7f97406542 Bump Emacs version
* lisp/ob-core.el (org-babel-examplize-region):
* lisp/ob-exp.el (org-babel-exp-inline-code-template):
* lisp/org-table.el (org-table-copy-increment):
(org-table-formula-create-columns):
* lisp/org.el (org-agenda-ignore-drawer-properties):
(org-agenda-ignore-properties):
* lisp/ox-ascii.el (org-ascii-list-margin):
* lisp/ox-html.el (org-html-format-headline-function):
(org-html-format-inlinetask-function):
* lisp/ox-latex.el (org-latex-hyperref-template):
(org-latex-custom-id-as-label):
(org-latex-format-inlinetask-function):
(org-latex-known-warnings):
* lisp/ox-odt.el (org-odt-format-headline-function):
(org-odt-format-inlinetask-function):
* lisp/ox-texinfo.el (org-texinfo-format-headline-function): Bump
  Emacs version.
2014-10-24 11:56:09 +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
Aaron Ecay 107a2c83ba ob-core.el: add :output-dir header arg to org-babel-common-header-args-w-values
* lisp/ob-core.el (org-babel-common-header-args-w-values): Add
:output-dir'.

Otherwise tthis property is not inherited correctly from
subtree-/file-level properties.
2014-08-06 00:04:52 -04:00
Bastien Guerry da8b695b2b ob-core.el (org-babel-insert-header-arg): Tiny message fix
* ob-core.el (org-babel-insert-header-arg): Tiny message fix.
2014-07-27 23:25:41 +02:00
Eric Schulte 6900ec41e3 customizable parameter to raise more noweb errors
* lisp/ob-core.el (org-babel-noweb-error-all-langs): Raise noweb
  errors regardless of language.
  (org-babel-expand-noweb-references): Make use of the new
  `org-babel-noweb-error-all-langs' variable.
2014-06-12 19:39:32 -04:00
Achim Gratz 5bf928bae7 Merge branch 'maint'
Conflicts:
	lisp/ob-core.el
	lisp/org.el
	lisp/ox.el
2014-05-28 16:23:08 +02:00
Achim Gratz 790f5b4d3a ob-core, ob-exp, ob-haskell, ob-python: declarations for org-src-preserve-indentations
* lisp/ob-core.el: Add comment to forward declaration of
  'org-src-preserve-indentations'.
* lisp/ob-exp.el: Require org-src to import
  'org-src-preserve-indentations'.
* lisp/ob-haskell.el, lisp/ob-python.el: Remove superfluous forward
  declaration of 'org-src-preserve-indentations', since it gets
  imported by other requires.
2014-05-28 14:52:14 +02:00
Achim Gratz 61b8091596 ob-core:forward declare org-every
* lisp/ob-core.el (org-every): Forward declare 'org-every'.
2014-05-28 14:47:23 +02:00
Bastien Guerry b69243d44b Merge branch 'maint' 2014-05-21 15:04:36 +02:00
Ian Kelling 7d6cc7f0bf Fix error prone babel table output format detection
* ob-core.el (org-babel-insert-result): Test all list elements against
listp and (eq element 'hline) instead of checking just the first.

org-babel table output uses different formatting for a list of lists,
but detects it incorrectly causing an error. An example of a block
causing an error is an emacs lisp source block containing just 1 line:
'((1) 2)
2014-05-21 15:04:23 +02:00
Bastien Guerry cb8366cd21 ob-core.el (org-babel-demarcate-block): Fix case
* ob-core.el (org-babel-demarcate-block): Upcase or downcase
the inserted #+begin_src and #+end_src depending on the
current case of #+begin_src and #+end_src.

Thanks to Alexander Baier for reporting this.
2014-05-20 17:40:01 +02:00
Aaron Ecay 1be3c409c2 babel: fixes for commit 08e2596
* lisp/ob-core.el (org-babel-graphical-output-file): Use `user-error'
instead of `error'.

* lisp/ob-maxima.el (org-babel-execute:maxima, org-babel-maxima-expand):
* lisp/ob-octave.el (org-babel-execute:octave): Guard
`org-babel-graphical-output-file' with `ignore-errors'.
2014-05-15 23:26:30 -04:00
Bastien Guerry 7893cddc88 ob-core.el (org-babel-do-in-edit-buffer): Tiny code cleanup
* ob-core.el (org-babel-do-in-edit-buffer): Tiny code cleanup.
2014-05-15 11:50:06 +02:00
Aaron Ecay 08e2596718 ob-core.el: allow the auto-generation of output file names for src blocks.
* lisp/ob-core.el (org-babel-generate-file-param): New function.
(org-babel-get-src-block-info): Use it.
(org-babel-merge-params): Handle :file-ext.
(org-babel-graphical-output-file): error if no :file or :file-ext.
* testing/lisp/test-ob.el (test-org-babel/file-ext-and-output-dir):
New test.
* doc/org.texi (Specific header arguments): Add doc for :file-ext and
:output-dir header args.
* lisp/ob-R.el (org-babel-expand-body:R): Don’t calculate
graphics-file.
(org-babel-execute:R): Only look for a graphics-file if needed.
2014-05-11 16:33:22 -04:00
Aaron Ecay 935b69e065 Replace org-babel-*-graphical-output-file with generic version
* lisp/ob-core.el (org-babel-graphical-output-file): New generic function.
* lisp/ob-R.el (org-babel-R-graphical-output-file): Delete specific version.
(org-babel-expand-body:R): Use generic version.
* lisp/ob-maxima.el (org-babel-maxima-graphical-output-file): Delete
specific version.
(org-babel-maxima-expand): Use generic version.
* lisp/ob-octave.el (org-babel-octave-graphical-output-file): Delete
specific version
(org-babel-execute:octave): Use generic version.
2014-04-22 15:31:15 -04:00
Aaron Ecay c7dff7105b ob-core.el: Replace a use of remove with remq
* lisp/ob-core.el (org-babel-del-hlines): Use `remq' for `remove'
2014-04-22 15:30:12 -04:00
Bastien Guerry 4ea6c690fd Minor updates on org-trim, org-babel-chomp and org-babel-trim
* org.el (org-trim): Make a defsubst, use `replace-regexp-in-string'.

* ob-core.el (org-babel-chomp, org-babel-trim): Fix docstrings.
2014-04-19 14:43:28 +02:00
Bastien Guerry 9e4113994c Revert "Alias `org-babel-trim' and `org-babel-chomp' to `org-trim' and `org-trim-trailing'."
This reverts commit 7925d42d43.
2014-04-19 14:36:00 +02:00
Bastien Guerry 7925d42d43 Alias `org-babel-trim' and `org-babel-chomp' to `org-trim' and `org-trim-trailing'.
* org.el (org-trim): Rewrite and make a defsubst.

* org-bibtex.el (org-bibtex-get): Use `org-trim' instead of
`org-babel-trim'.

* ob-core.el (org-babel-trim): Delete and alias to `org-trim'.
(org-babel-chomp): Delete and alias to `org-trim-trailing'.
(org-trim-trailing): New defsubst.
(org-babel-examplize-region): Fix version.
2014-04-18 15:11:42 +02:00
Michael Weylandt 255dd41afd Org babel: Add function and keybinding to remove result blocks
* ob-core.el (org-babel-remove-result-one-or-many): New function.

* ob-keys.el (org-babel-key-bindings): Add a keybinding for the
new function `org-babel-remove-result-one-or-many'.

TINYCHANGE
2014-04-17 08:41:05 +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
Eric Schulte 28ddf07a56 update named code block regexp for indentation
Previously didn't work if #+header lines intervening between the
  name and the block were indented.
2014-03-07 08:28:42 -07:00
Bastien Guerry 6a388c135f ob-core.el: Some renaming.
* ob-core.el (org-babel-insert-result): Use `org-babel-examplify-region'.
(org-babel-capitalize-examplize-region-markers): Rename to
`org-babel-capitalize-example-region-markers'.
(org-babel-examplize-region): Mark obsolete and rename to
`org-babel-examplify-region'.
2014-02-07 10:19:50 +01:00
Eric Schulte e583eaa8f1 fix bug when results butt up against headline
* lisp/ob-core.el (org-babel-examplize-region): Don't treat
  exampleized regions adjoining headlines as inline examples.
2014-02-06 14:30:30 -07:00
Eric Schulte cd3bc12a29 named and caching call lines working
* lisp/ob-core.el (org-babel-current-result-hash): Additional info
  argument so that named call line results may be found.
  (org-babel-set-current-result-hash): Additional info argument so
  that named call line results may be found.
* lisp/ob-lob.el (org-babel-lob-execute): Passing info to hash finding
  functions so that named results may be found.
2014-01-18 13:40:57 -07:00
Nicolas Goaziou b8028c607d Merge branch 'maint' 2014-01-09 21:37:11 +01:00
Nicolas Goaziou 81ce406d8f ob-core: Speed improvement
* lisp/ob-core.el (org-babel-get-inline-src-block-matches): Do not
  compute line number if all is needed is to know if we're on the
  first one.
2014-01-09 21:36:25 +01:00
Bastien Guerry f8e1745440 Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-07 14:19:03 +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 c41f5075ac Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-05 06:36:11 +01:00
Bastien Guerry 0beda99171 Revert "Update copyright years."
This reverts commit 21105594fc.
2014-01-05 06:28:07 +01:00
Bastien Guerry 096ff7e078 Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-04 18:58:12 +01:00
Bastien Guerry 21105594fc Update copyright years. 2014-01-04 18:56:11 +01:00
Eric Schulte ea993c6d8c fixed insertion of results with hashes
No longer overwrites intervening #+ lines.

* lisp/ob-core.el (org-babel-where-is-src-block-result): Fixed
  insertion of results with hashes.
2013-12-13 15:06:06 -07:00
Eric Schulte 031d2565f7 don't change code block body during sha1 hashing
* lisp/ob-core.el (org-babel-sha1-hash): Don't change code block body
  during sha1 hashing.
2013-12-10 11:11:27 -07:00
Eric Schulte ed64845fd6 fix bug introduced by e6a6fed
* lisp/ob-core.el (org-babel-sha1-hash): Don't reference non-existent
  params variable.
2013-12-10 11:00:29 -07:00
Eric Schulte e6a6fed934 expanded noweb references when calculating hashes
The bulk of the new code in org-babel-sha1-hash is borrowed from
org-babel-expand-src-block.

* lisp/ob-core.el (org-babel-sha1-hash): Expanded noweb references
  when calculating hashes.
2013-12-10 00:36:16 -07:00
Bastien Guerry 487c74580c Fix bug when commenting source code.
* org.el (org-babel-do-in-edit-buffer): Declare.
(org-babel-load-file, org-insert-comment)
(org-comment-or-uncomment-region): Don't require 'ob-core.
(org-mode-map): Remap `comment-dwim' to `org-comment-dwim'.
(org-comment-dwim): New command.

* ob-core.el (org-babel-do-in-edit-buffer): Make an autoload.

See http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00154.html
for a discussion about this bug.
2013-12-06 10:45:35 +01:00
Eric Schulte 8c98879d7c declare function to appease compiler
* lisp/ob-C.el (org-remove-indentation): Declare function to appease
  compiler.
* lisp/ob-core.el (org-remove-indentation): Declare function to
  appease compiler.
* lisp/ob-fortran.el (org-remove-indentation): Declare function to
  appease compiler.
2013-11-23 17:02:22 -07:00
Eric Schulte 39070b7fc7 sometimes remove common indentation when trimming
* lisp/ob-C.el (org-babel-C-execute): Remove common indentation when
  trimming.

* lisp/ob-core.el (org-babel-read-result): Remove common indentation
  when trimming.
  (org-babel-update-block-body): Remove common indentation when
  trimming.

* lisp/ob-fortran.el (org-babel-execute:fortran): Remove common
  indentation when trimming.

* lisp/ob-tangle.el (org-babel-process-comment-text): Better default
  to process tangled comments.
2013-11-23 15:57:29 -07:00
Eric Schulte 89a35bc147 inline src block parser set "switches" in info
* lisp/ob-core.el (org-babel-parse-inline-src-block-match): Inline src
  block parser set "switches" in info, otherwise later offset are broken.
2013-11-22 08:28:29 -07:00
Eric Schulte bbcf17b969 set location info parameter for inline src blocks
* lisp/ob-core.el (org-babel-execute-src-block): Set location info
  parameter for inline src blocks.
  (org-babel-get-src-block-info): Set location info parameter for
  inline src blocks.
2013-11-22 08:28:29 -07:00
Eric Schulte 060d79f080 whitespace fixes 2013-11-22 08:28:29 -07:00
Bastien Guerry 9214000c21 Merge branch 'maint'
Conflicts:
	doc/org.texi
2013-11-17 09:17:39 +01:00
Bastien Guerry a6210cc9c2 Backport Paul's fixes from Emacs trunk (1/2)
See http://article.gmane.org/gmane.emacs.diffs/123123
2013-11-17 09:12:41 +01:00
Eric Schulte d840b84bbc Don't skip call lines searching for results
This fixes a bug noticed by Rick Frankel in which two subsequent
  #+call: lines will both update the same results.  Before this commit
  both of the following call lines would update the same result.

      #+name: call-me
      #+BEGIN_SRC emacs-lisp :var v="nil"
      v
      #+END_SRC

      #+call: call-me("one")

      #+call: call-me(v="two")

      #+RESULTS:
      : one

  Now both lines are given their own result.

      #+name: call-me
      #+BEGIN_SRC emacs-lisp :var v="nil"
      v
      #+END_SRC

      #+call: call-me("one")

      #+RESULTS:
      : one

      #+call: call-me(v="two")

      #+RESULTS:
      : two
2013-11-13 21:13:11 -07:00
Eric Schulte c67e3cda15 default to preserving hlines in call lines
* lisp/ob-core.el (org-babel-default-inline-header-args):
  Added (:hlines "yes") to the default value.
2013-11-13 21:13:11 -07:00
Bastien Guerry 487057fc26 Fix conflicts from previous merge 2013-11-12 21:11:23 +01:00
Bastien Guerry 71884cc039 Merge branch 'maint'
Conflicts:
	lisp/ob-C.el
	lisp/ob-clojure.el
	lisp/ob-core.el
	lisp/ob-lisp.el
	lisp/org-clock.el
2013-11-12 21:00:49 +01:00
Bastien Guerry f95641c443 Backport changes from Emacs revs 115081 and 115082
2013-11-12  Stefan Monnier  <monnier@iro.umontreal.ca>

	Address some byte-compiler warnings.
	* ob-abc.el (org-babel-expand-body:abc): Use dolist.
	(org-babel-execute:abc): Fix regexp quoting.
	* ob-calc.el (org--var-syms): Rename from `var-syms'.
	* ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding.
	* ob-table.el (sbe): Move debug declaration.
	* org-clock.el (org--msg-extra): Rename from `msg-extra'.
	* org.el (org-version): Avoid var name starting with _.
	(org-inhibit-startup, org-called-with-limited-levels)
	(org-link-search-inhibit-query, org-time-was-given)
	(org-end-time-was-given, org-def, org-defdecode, org-with-time):
	* org-colview.el (org-agenda-overriding-columns-format):
	* org-agenda.el (org-agenda-multi, org-depend-tag-blocked)
	(org-agenda-show-log-scoped):
	* ob-python.el (py-which-bufname, python-shell-buffer-name):
	* ob-haskell.el (org-export-copy-to-kill-ring):
	* ob-exp.el (org-link-search-inhibit-query):
	* ob-R.el (ess-eval-visibly-p):
	* ob-core.el (org-src-window-setup): Declare before use.
	(org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'.
	* ox-odt.el (org-odt-hfy-face-to-css):
	* org-src.el (org-src-associate-babel-session, org-src-get-lang-mode):
	* org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex)
	(org-bibtex-check):
	* ob-tangle.el (org-babel-tangle, org-babel-spec-to-string)
	(org-babel-tangle-single-block, org-babel-tangle-comment-links):
	* ob-table.el (sbe):
	* ob-sqlite.el (org-babel-sqlite-expand-vars):
	* ob-sql.el (org-babel-sql-expand-vars):
	* ob-shen.el (org-babel-execute:shen):
	* ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate):
	* ob-scala.el (org-babel-scala-evaluate):
	* ob-ruby.el (org-babel-ruby-table-or-string)
	(org-babel-ruby-evaluate):
	* ob-python.el (org-babel-python-table-or-string)
	(org-babel-python-evaluate-external-process)
	(org-babel-python-evaluate-session):
	* ob-picolisp.el (org-babel-execute:picolisp):
	* ob-perl.el (org-babel-perl-evaluate):
	* ob-maxima.el (org-babel-execute:maxima):
	* ob-lisp.el (org-babel-execute:lisp):
	* ob-java.el (org-babel-execute:java):
	* ob-io.el (org-babel-io-evaluate):
	* ob-haskell.el (org-babel-execute:haskell):
	* ob-fortran.el (org-babel-execute:fortran):
	* ob-exp.el (org-babel-exp-code):
	* ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
	* ob-ditaa.el (org-babel-execute:ditaa):
	* ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash)
	(org-babel-parse-header-arguments, org-babel-reassemble-table)
	(org-babel-goto-src-block-head, org-babel-mark-block)
	(org-babel-expand-noweb-references, org-babel-script-escape)
	(org-babel-process-file-name):
	* ob-clojure.el (org-babel-execute:clojure):
	* ob-calc.el (org-babel-execute:calc):
	* ob-awk.el (org-babel-execute:awk):
	* ob-abc.el (org-babel-execute:abc):
	* ob-R.el (org-babel-expand-body:R):
	* ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...).

2013-11-12  Glenn Morris  <rgm@gnu.org>

	* ox-html.el (org-html-scripts): Add 2013 to copyright years.
	(org-html-infojs-template): Copyright holder to FSF.
2013-11-12 20:57:31 +01:00
Eric Schulte ac9d8012a4 fix compiler issues w/safe-header-args
* lisp/ob-core.el (org-every): Declared function for compiler.
  (org-babel-safe-header-args): Moved before first use.
  (org-babel-header-args-safe-fn): Moved before first use.
2013-10-30 11:58:50 -06:00
Aaron Ecay cba8718eac Mark some org-babel variables as safe locals under proper conditions
* lisp/ob-core.el (org-babel-inline-result-wrap,
org-babel-default-header-args,
org-babel-default-inline-header-args): mark as safe local variables
2013-10-30 11:23:34 -06:00
Eric Schulte 2eef1b4549 call org-confirm-babel-evaluate from code block
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.
2013-10-14 07:23:39 -06:00
Eric Schulte 5afd5d9785 optional arguments to org-babel-insert-header-arg
* 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.
2013-10-06 09:07:42 -06:00
Eric Schulte 01467ae083 remove leading newline when removing a result
This fixes a number of new test failures

* lisp/ob-core.el (org-babel-remove-result): Remove leading newline
  when removing a result.
2013-10-01 06:25:31 -06:00
Michael Albinus 89f10a11fb * ob-core.el (org-babel-local-file-name): Simplify. (org-babel-process-file-name): Apply `expand-file-name' first. (org-babel-remote-temporary-directory): New defcustom. (org-babel-temp-file): Use it. 2013-09-28 05:37:45 -06:00
Eric Schulte d089170905 named results when keeping keyword of rm'd results
* lisp/ob-core.el (org-babel-remove-result): Fix recent keep-keyword
  option to include named result blocks as well.
2013-09-20 16:29:10 -06:00
Eric Schulte 136bdc0e83 org-babel-remove-result option keep result keyword
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.
2013-09-20 15:09:43 -06:00
Carsten Dominik fa61eb64cf Declare a function in ob-core.el 2013-09-19 05:21:06 +02:00
Eric Schulte 39a97fcf03 rm meaningless ":padnewlines" from default header args
* 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.
2013-09-18 15:22:52 -06:00
Aditya Siram bbe8518118 Given a block with an empty body org-babel-src-block-regexp gobbled up everything until the ending delimiter of the next code block. Fixed this by making the body regexp non-greedy. 2013-09-14 09:25:05 -06:00
Eric Schulte 9a3d30626e condition code execution by org-element-context
Thanks to Nicolas Goaziou for suggesting this change.
2013-09-08 04:51:02 -06:00
Nicolas Goaziou 6fdc2361c9 ob-core: Fix wrong indentation of results
* lisp/ob-core.el (org-babel-get-src-block-info): Look for indentation
  value at the correct location.
* testing/lisp/test-ob.el: Add test.
2013-08-21 14:16:28 +02:00
Eric Schulte 184109d416 ob-core remove-if -> org-remove-if
* lisp/ob-core.el (org-babel-merge-params): Replace remove-if with
  org-remove-if.
2013-07-29 18:18:41 -06:00
Eric Schulte 99a8d97ffa don't modify missing header arguments during merge
* lisp/ob-core.el (org-babel-merge-params): More careful to check that
  the colname- and rowname-names header arguments exist during merge.
2013-07-29 07:58:22 -06:00
Eric Schulte 3142297d69 delete colnames/rownames for replaced variables
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.
2013-07-26 18:53:13 -06:00
Eric Schulte 4899c79e66 org-src-lang-modes in block demarcation options
* lisp/ob-core.el (org-babel-demarcate-block): Include
  org-src-lang-modes in block demarcation options.
2013-07-13 12:37:09 -06:00
Achim Gratz 8387b3b07e Merge branch 'maint' 2013-07-01 22:21:47 +02:00
Achim Gratz 8cf4ceb304 ob-core: fix regression when org-confirm-babel-evaluate is a functionp
* 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).
2013-07-01 22:20:48 +02:00
Eric Schulte 895bae8774 fix bug when replacing results hashes
* lisp/ob-core.el (org-babel-set-current-result-hash): Updated the
  match-string holding the hash data, and correct overlay maintenance.
2013-06-30 17:57:13 -06:00
Eric Schulte 884f5ced13 named call lines insert results like code blocks
* 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.
2013-06-30 17:46:32 -06:00
Bastien Guerry 5a36318511 Merge branch 'maint' 2013-06-28 09:13:41 +02:00
Achim Gratz 30581835bd do not use mapcar* for transposing tables
* 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).
2013-06-27 20:17:22 +02:00
Eric Schulte 685b296724 evaluate elisp header args at original call site
* 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.
2013-06-25 09:59:56 -06:00
Achim Gratz 90b168705e ob-core: evaluate header-args[:lang] properties at point of call
* 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.
2013-06-23 19:35:11 +02:00
Eric Schulte 56ac8f8b69 prolog and epilog header arguments
* 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.
2013-06-22 14:09:24 -06:00
Eric Schulte d34813c64a more robust matching of examplized ranges
* lisp/ob-core.el (org-babel-read-result): More robust matching of
  examplized ranges.
  (org-babel-result-end): More robust matching of examplized ranges.
2013-06-21 13:40:38 -06:00
Eric Schulte a79fd4be28 fix babel merge params bug from commit 693dda67
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'.
2013-06-20 09:53:56 -06:00
Achim Gratz 693dda67e6 ob-core: allow language specific header arguments in 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:
2013-06-10 20:53:19 +02:00
Eric Schulte 04a1b98e5e do not read #-prefix header-arg value as emacs lisp
* lisp/ob-core.el (org-babel-read): Do not read #-prefix header-arg
  value as emacs lisp.
2013-06-08 15:13:52 -06:00
Eric Schulte c3711b14d6 org-babel-current-exec-src-block-head -> org-babel-current-src-block-location
* lisp/ob-core.el (org-babel-current-src-block-location): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
(org-babel-execute-src-block): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
* lisp/ob-exp.el (org-babel-exp-results): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
* lisp/ob-lob.el (org-babel-lob-execute): Rename
  org-babel-current-exec-src-block-head to
  org-babel-current-src-block-location.
2013-06-08 13:19:38 -06:00
Eric Schulte 2a73e06a6d adding a new global tangle-mode header argument
* 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.
2013-06-08 12:29:02 -06:00
Eric Schulte d6a9f1aa29 org-babel-current-exec-src-block-head -> outermost
* lisp/ob-core.el (org-babel-execute-src-block): The
  org-babel-current-exec-src-block-head variable should point to the
  outermost code block.
2013-06-06 10:58:52 -06:00
Vitalie Spinu f301bbcc86 make src block location available to execution backends
* 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'.
2013-06-06 09:13:58 -06:00
Achim Gratz 3768cec391 Babel: complete fix for priority order of header arguments from e79e8943de
* 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).
2013-05-19 21:06:53 +02:00
Sebastien Vauban e79e8943de Fix priority order for inheriting header arguments
* ob-core.el (org-babel-parse-src-block-match): Fix order of list of header
arguments.
2013-05-06 16:32:22 -04:00
Eric Schulte f285b7ed3d Defcustom controlling the wrapping of inline results
* 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.
2013-04-26 09:38:33 -06:00
Bastien Guerry 267cbe5183 Merge branch 'maint' 2013-04-25 07:30:19 +02:00
Bastien Guerry dcb0ac48a8 Use `org-called-interactively-p' instead of `called-interactively-p'
* 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.
2013-04-25 07:30:04 +02:00
Aaron Ecay 7263b326d4 Add 'light argument to some uses of org-babel-get-src-block-info
* lisp/ob-core.el (org-babel-do-key-sequence-in-edit-buffer)
(org-babel-expand-noweb-references)
* lisp/ob-tangle.el (org-babel-tangle): Use 'light argument to
`org-babel-get-src-block-info'.
2013-04-21 23:45:27 -04:00
Aaron Ecay 9969d3feeb ob-core.el (org-babel-execute-src-block): fixes for :results none
* 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.
2013-04-21 23:45:27 -04:00
Bastien Guerry 3d994a602c ob-core.el (org-babel-insert-result): Fix bug when inserting results as a list: ensure we split a string containing "\n"
* 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.
2013-04-19 19:44:40 +02:00
Bastien Guerry 03920a01fa Merge branch 'master-apply-aaron-patch2'
Conflicts:
	lisp/ob-core.el
2013-04-18 12:28:03 +02:00
Aaron Ecay bf29482973 Clean up various org-babel-*-maybe commands
* 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.
2013-04-18 12:26:23 +02:00
Aaron Ecay 4d763f35f5 Fix bug in org-babel-execute-src-block
* 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.
2013-04-18 10:48:57 +02:00
Bastien Guerry 217d14ecc2 ob-core.el (org-babel-pop-to-session-maybe): Fix docstring
* ob-core.el (org-babel-pop-to-session-maybe): Fix docstring.
(org-babel-pop-to-session-maybe): Use true function's name,
not its alias.
2013-04-18 10:22:34 +02:00
Bastien Guerry cde4c876fb ob-core.el (org-babel-confirm-evaluate): Fix typo in docstring
* ob-core.el (org-babel-confirm-evaluate): Fix typo in
docstring.
2013-04-10 14:52:04 +02:00
Eric Schulte 6c11a0664e more restrictive elisp eval of header arguments
* lisp/ob-core.el (org-babel-read): More restrictive elisp eval of
  header arguments.
2013-04-09 10:35:50 -06:00
Eric Schulte 385ef25c6e don't over-evaluate result-params in macro
* lisp/ob-core.el (org-babel-result-cond): Don't over-evaluate
  result-params in macro.
2013-04-07 06:49:54 -06:00
Achim Gratz af6f32af1a fix commit df0c8a3bc4
* lisp/ob-core.el (org-babel-number-p): String match for any number
  moved first so that the match data for the length check does not
  become corrupted.
2013-04-07 11:16:45 +02:00
Eric Schulte 7117ad4f92 raw org and drawer imply verbatim results
This unifies the results handling across a number of different
  languages.  It is still possible to force tabular output by adding the
  ":results table" argument.

The following example demonstrates the results in shell python and perl.

** drawer and table
#+begin_src sh :results drawer table
 echo -e "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
| 1 |
| 2 |
| 3 |
:END:

#+begin_src perl :results drawer table
"1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
| 1 |
| 2 |
| 3 |
:END:

#+begin_src python :results drawer table
return "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
| 1\n2\n3 |
:END:

** drawer
#+begin_src sh :results drawer
 echo -e "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
1
2
3
:END:

#+begin_src perl :results drawer
"1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
1
2
3
:END:

#+begin_src python :results drawer
return "1\n2\n3"
#+end_src

#+RESULTS:
:RESULTS:
1
2
3
:END:

** raw
#+begin_src sh :results raw
 echo -e "1\n2\n3"
#+end_src

#+RESULTS:
1
2
3

#+begin_src perl :results raw
"1\n2\n3"
#+end_src

#+RESULTS:
1
2
3

#+begin_src python :results raw
return "1\n2\n3"
#+end_src

#+RESULTS:
1
2
3

* lisp/ob-core.el (org-babel-result-cond): The "raw", "org" and "drawer"
  :results header argument values preclude table processing unless the
  "table" argument is given as well.
2013-04-06 11:39:23 -06:00
Eric Schulte 3932efdf8e intuitive code block post processing w/file results
* 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.
2013-04-04 06:41:55 -06:00
Eric Schulte bde2348c9e read code block values with earmuffs as Emacs Lisp
* lisp/ob-core.el (org-babel-read): Read code block values with earmuffs
  as Emacs Lisp.
2013-04-04 06:41:55 -06:00
Eric Schulte d35ec18ab5 post header arg post-processes code block results
* 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.
2013-04-04 06:41:55 -06:00
Eric Schulte 2f39a704cf removing alternate code block variable syntax
* 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.
2013-04-03 09:17:00 -06:00
Eric Schulte 221da3ad27 cycle tables for :results org and :results wrap
* lisp/ob-core.el (org-babel-insert-result): Cycle tables for :results
  org and :results wrap.
2013-03-29 17:57:06 -06:00
Eric Schulte df0c8a3bc4 don't interpret single "-" as a number
* lisp/ob-core.el (org-babel-number-p): Don't interpret single "-" as a
  number.
2013-03-29 08:48:59 -06:00
Suhail Shergill 3b2abfce7b bugfix: fix `org-babel-execute-src-block' on remote hosts
* 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
2013-03-25 06:09:14 +01:00
Bastien Guerry 7610231952 ob-core.el (org-babel-hash-show-time): tiny Docstring enhancement
* ob-core.el (org-babel-hash-show-time): tiny Docstring enhancement.
2013-03-25 05:41:58 +01:00
Eric Schulte a461b0a444 allow comments between code blocks and un-named res
* lisp/ob-core.el (org-babel-where-is-src-block-result): Allow comments
  between code blocks and un-named results.
2013-03-17 19:57:01 -05:00
Achim Gratz 4f7d514f13 ob-core: allow auto-denial of source block evaluation
* 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
2013-03-09 23:09:15 +01:00
Eric Schulte d7758f565c refactor `org-babel-check-confirm-evaluate' macro
- meaningful variable names
- don't overly pollute the name space of the macro body

* lisp/ob-core.el (org-babel-check-confirm-evaluate): Refactoring.
2013-03-09 21:45:40 +01:00
Eric Schulte bc6564ab48 whitespace changes
spaces between lines, and fix overlong lines

* lisp/ob-core.el (org-babel-check-confirm-evaluate): Whitespace.
  (org-babel-confirm-evaluate): Whitespace.
2013-03-09 21:43:29 +01:00
Eric Schulte b0bccccb5c additional code block execution refactoring
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.
2013-03-09 21:43:18 +01:00
Achim Gratz be0883940d ob-core: refactor org-babel-confirm-evaluate, do not confirm evaluation if cache is current
* 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.
2013-03-09 21:33:19 +01:00
Achim Gratz 5fe486807e ob-core: reimplement org-babel-confirm-evaluate
* 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.
2013-03-09 21:31:01 +01:00
Eric Schulte 9dd13b2e1e fixed line over 80 chars long
* lisp/ob-core.el (org-babel-call-process-region-original): Fixed line
  over 80 chars long.
2013-03-09 21:30:35 +01:00
Achim Gratz 1ffd4f615a ob-core: do not declare and define org-babel-call-process-region-original
* 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.
2013-03-09 21:27:24 +01:00
Bastien Guerry 8a2e3e2a79 Add :version and :package-version
* ox.el (org-export-snippet-translation-alist)
(org-export-coding-system, org-export-in-background)
(org-export-async-init-file, org-export-invisible-backends)
(org-export-dispatch-use-expert-ui):
* ox-texinfo.el (org-texinfo-filename, org-texinfo-classes)
(org-texinfo-format-headline-function)
(org-texinfo-node-description-column)
(org-texinfo-active-timestamp-format)
(org-texinfo-link-with-unknown-path-format)
(org-texinfo-tables-verbatim)
(org-texinfo-table-scientific-notation)
(org-texinfo-text-markup-alist)
(org-texinfo-format-drawer-function)
(org-texinfo-format-inlinetask-function)
(org-texinfo-info-process):
* ox-man.el (org-man-tables-centered)
(org-man-table-scientific-notation)
(org-man-source-highlight, org-man-source-highlight-langs)
(org-man-pdf-process, org-man-logfiles-extensions):
* ox-html.el (org-html-allow-name-attribute-in-anchors)
(org-html-coding-system, org-html-divs):
* ox-ascii.el (org-ascii-text-width)
(org-ascii-headline-spacing, org-ascii-indented-line-width)
(org-ascii-paragraph-spacing, org-ascii-charset)
(org-ascii-underline, org-ascii-bullets)
(org-ascii-links-to-notes)
(org-ascii-table-keep-all-vertical-lines)
(org-ascii-table-widen-columns)
(org-ascii-table-use-ascii-art)
(org-ascii-format-drawer-function)
(org-ascii-format-inlinetask-function):
* org.el (org-modules, org-export-backends)
(org-highlight-latex-and-related, orgstruct-setup-hook):
* org-attach.el (org-attach-git-annex-cutoff):
* org-archive.el (org-archive-file-header-format):
* org-agenda.el (org-agenda-todo-ignore-time-comparison-use-seconds):
* ob-python.el (org-babel-python-hline-to)
(org-babel-python-None-to):
* ob-ditaa.el (org-ditaa-eps-jar-path):
* ob-core.el (org-babel-results-keyword): Add :version and
:package-version.

* ox-ascii.el: Use utf-8-emacs as the file coding system.
2013-03-05 16:38:33 +01:00
Bastien Guerry 2d2913ce4f ob-core.el (org-babel-load-in-session): Throw a useful error when there is no code block at point
* ob-core.el (org-babel-load-in-session): Throw a useful error
when there is no code block at point.
2013-03-02 15:28:51 +01:00
Achim Gratz 302d3780ec ob-core: add binding for merged-params to avoid multiple evaluation
* lisp/ob-core.el (org-babel-execute-src-block): Add binding for
  merged-params to avoid multiple evaluation of
  `org-babel-merge-params´.
2013-02-27 23:48:02 +01:00