Commit Graph

161 Commits

Author SHA1 Message Date
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
Achim Gratz 0fcfafe331 ob-core: Rename cache? to cache-p, add binding for cache-current-p
* lisp/ob-core.el (org-babel-execute-src-block): Rename cache? to
  cache-p, add binding for cache-current-p and use it.
2013-02-27 23:48:02 +01:00
Achim Gratz eee580c8b3 Revert "ob-core.el: Do not ask for confirmation if cached value is current"
Reverting "Fix a typo I introduced while editing Achim's commit 091bf0"
Reverting "ob-core.el: Do not ask for confirmation if cached value is current"

This reverts commit 091bf02514.
2013-02-27 22:10:05 +01:00
Bastien Guerry bdce4dbf9b Fix a typo I introduced while editing Achim's commit 091bf0
Thanks to Achim for reporting this!
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=091bf0
2013-02-27 13:29:23 +01:00
Achim Gratz 091bf02514 ob-core.el: Do not ask for confirmation if cached value is current
* ob-core.el (org-babel-execute-src-block): Do not run
`org-babel-confirm-evaluate´ if source block has a cache and the
cache value is current (there is no evaluation involved in this
case).
2013-02-27 09:44:27 +01:00
Eric Schulte f51fd88554 Return expanded code on programmatic calls
* lisp/ob-core.el (org-babel-expand-src-block): Return value of expanded
  code block on non-interactive calls.
2013-02-24 09:50:46 -07:00
Grégoire Jadi 67febc3600 Unify `org-id-reverse-string' and `org-babel-reverse-string' into `org-reverse-string'
* lisp/org.el (org-reverse-string): Add `org-reverse-string' to
  reverse a string.
* lisp/org-id.el(org-id-new, org-id-decode): Replace
  `org-id-reverse-string' by `org-reverse-string'.
* lisp/ob-core.el(org-babel-trim): Replace `org-babel-reverse-string'
  by `org-reverse-string' and declare it.

TINYCHANGE
2013-02-13 16:29:09 +01:00
Bastien Guerry 019a8dee21 ob-core.el (org-babel-insert-result): Fix bug when inserting an empty string as the result
* ob-core.el (org-babel-insert-result): Fix bug when inserting
an empty string as the result.
2013-02-12 17:49:06 +01:00
Eric Schulte 728c0eb693 bring back org-ts-regep fix lost in merge
* lisp/ob-core.el (org-babel-result-regexp): Bring back Bastien's
  hackish fix from commit c17e07e9 which was accidentally dropped in a
  merge.
2013-02-09 16:05:44 -07:00
Gary Oberbrunner e2b17ccc52 Improvements to Org SQL support
* add a header-row delimiter to the tables returned from mysql
 * add new sql-specific header args for the database connection, and implements them for mysql
 * add support for :colnames (mysql only)
 * (minor) add an edebug spec to org-babel-result-cond to allow edebugging through it
 * add some doc about what header args are used
2013-02-09 14:11:45 -07:00