Commit Graph

148 Commits

Author SHA1 Message Date
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