Commit Graph

177 Commits

Author SHA1 Message Date
Nicolas Goaziou 6626dfb30b ob: Fix RESULTS indentation
* lisp/ob-core.el (org-babel-parse-src-block-match): Compute indentation
  taking into consideration tab width.
(org-babel-where-is-src-block-result): Do not assume indentation
consists of white space characters only.

* testing/lisp/test-ob.el (test-ob/preserve-results-indentation): Add
  test.

Reported-by: Jarmo Hurri <jarmo.hurri@iki.fi>
<http://permalink.gmane.org/gmane.emacs.orgmode/100403>
2015-08-23 23:41:56 +02:00
Paul Eggert 3a81c7ee6f Backport commit 0c856a2 from Emacs master branch
* lisp/ob-core.el (org-babel-check-evaluate)
(org-babel-confirm-evaluate):
* lisp/ob-fortran.el (org-babel-fortran-var-to-fortran):
* lisp/ox-latex.el (org-latex-compile):
* lisp/ox-man.el (org-man-compile):
* lisp/ox-odt.el (org-odt-template):
* lisp/ox-texinfo.el (org-texinfo-compile):
Change (message (format ...)) to (message ...), and likewise
for ‘error’.  This lessens the probability of confusion when the
output of ‘format’ contains ‘%’.

Fix some confusion with ‘format’
0c856a2c459016f1f9cce173f5b2b49be36e3452
Paul Eggert
Wed Aug 5 19:07:28 2015 -0700
2015-08-05 23:29:43 -04:00
Kyle Meyer 6f9184a294 Merge branch 'maint' into backport-master 2015-07-26 23:56:50 -04:00
Paul Eggert 6df6806311 Backport commit dfc2ef1 from Emacs master branch
Fix minor quoting problems in doc strings
dfc2ef11a84d33eab916ff87b8537f8e28c05c92
Paul Eggert
Thu May 28 00:22:03 2015 -0700
2015-07-26 23:29:31 -04:00
Dmitry Antipov d77b7c6c7b Backport commit 9c3883b from Emacs master branch
* lisp/org-mouse.el (org-mouse-do-remotely): Prefer point-marker to
  copy-marker of point.
* lisp/ob-core.el (org-babel-insert-result): Prefer point-min-marker and
  point-max-marker.

Conflicts:
  lisp/org-mouse.el
2015-07-26 23:29:30 -04:00
Nicolas Goaziou e900ebed08 ob-core: Small refactoring
* lisp/ob-core.el (org-babel-params-from-properties): Refactor code to
  avoid nesting `mapcar' calls.
2015-06-17 11:55:57 +02:00
Bjarte Johansen 041ca4b6f4 ob-core: Do not return results on writing to file
* ob-core (org-babel-result-cond): Add "file" as a param that returns
  a scalar result.

When writing the result to file we do not need to first convert the
data to a table since it is just converted back when
org-babel-execute-src-block serializes the result to file.
2015-05-26 23:54:53 +02:00
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