Commit Graph

373 Commits

Author SHA1 Message Date
Carsten Dominik b35b9914e6 Revert "Use `add-to-invisibility-spec' directly"
This reverts commit c2e5b13a2d.
2010-04-18 19:38:10 +02:00
Carsten Dominik c2e5b13a2d Use `add-to-invisibility-spec' directly 2010-04-18 19:26:30 +02:00
Carsten Dominik f45e6a28b1 Use the normal overlay API, not Org's one 2010-04-18 16:49:58 +02:00
Eric Schulte 70ba21e699 babel: new function `org-babel-tangle-publish' allows for tangling during project publish 2010-04-11 23:58:44 -06:00
Eric Schulte 7cbb35920d org-babel-c: new header argument ":main no" allows inhibiting main wrap 2010-04-10 15:54:40 -06:00
Eric Schulte 99a07f1d4a org-babel-c: cleaning up header arguments 2010-04-10 15:43:31 -06:00
Eric Schulte 0e8c9f7a49 org-babel: no longer over evaluating header arguments 2010-04-10 15:43:19 -06:00
Eric Schulte 3386a702f8 org-babel: all languages now returning lists as pure emacs-lisp, not quoted emacs-lisp 2010-04-10 15:15:06 -06:00
Dan Davison 59d499ff51 babel: Allow table to end neatly with terminal hline
Prior to this, a terminal hline would leave dangling empty cells:

 #+TBLNAME: A
 |---+---+---|
 | a | b | c |
 |---+---+---|

 #+begin_src emacs-lisp :var tab=A
 tab
 #+end_src

 #+results:
 |---+---+---|
 | a | b | c |
 |---+---+---|
 |   |   |   |
2010-04-10 16:49:40 -04:00
Dan Davison 8c827ba5ba babel: Allow output tables to start with 'hline 2010-04-10 16:12:28 -04:00
Eric Schulte 98b4ae28a9 babel: allow lisp quoted expansion of variable values when starting with ` 2010-04-09 19:06:07 -06:00
Dan Davison f846663ce6 babel: Do not add indentation to perl code.
Thanks to Łukasz Stelmach.
2010-04-09 08:45:18 -04:00
Dan Davison 0f83b2d203 babel: allow disabling of noweb expansion during tangling 2010-04-08 16:14:28 -04:00
Dan Davison 38d6bf3f6c babel: allow assigning of variables when preparing R session
This is already in place for other languages, but seems to have been
forgotten for R.
2010-04-08 15:26:08 -04:00
Eric Schulte caaf755192 babel: org-babel-latex adjusts to the new org latex setup 2010-04-07 22:43:37 -06:00
Dan Davison e48b8bf577 babel: return string results from matlab as strings
Thanks to Bob Jansen
2010-04-07 18:44:58 -04:00
Dan Davison f03c981fc0 babel: return string results from octave as strings
Thanks to Darlan Cavalcante
2010-04-07 15:51:04 -04:00
Eric Schulte 8d405783cb babel: safer modification of `call-process-region' 2010-04-04 17:15:12 -06:00
Eric Schulte 8ef104195f babel: use wildcard "*" characters in `org-babel-ref-index-list' to index entire ranges 2010-04-02 08:46:13 -06:00
Dan Davison 40a8933ba6 babel: allow R to produce svg format output 2010-04-01 18:45:59 -04:00
Dan Davison 3637efe647 babel: Don't use language major-mode when expanding noweb references
There is no longer any need for the language major mode.
2010-03-30 10:20:18 -04:00
Dan Davison e32c066874 babel: check that language major-mode is available during tangling 2010-03-30 10:20:10 -04:00
Eric Schulte 2675848d37 babel: org-babel-c now responds to :cmdline header argument 2010-03-29 12:26:53 -06:00
Eric Schulte e8a125bed7 babel: now taking headline properties into account for lob calls 2010-03-28 16:53:00 -06:00
Dan Davison a23ca4529f babel: Get rid of parameter inheritance by reference blocks 2010-03-27 18:49:00 -04:00
Dan Davison 36351d26a9 Merge branch 'master' of git://repo.or.cz/org-mode 2010-03-27 16:18:27 -04:00
Dan Davison 47571965d4 babel: don't process emacs-lisp params twice 2010-03-27 15:59:53 -04:00
Eric Schulte 8ecc86d49e babel: better variable initialization for org-babel-c 2010-03-27 08:20:38 -06:00
Eric Schulte fc28dd538b babel: shorter language names no longer shadow larger names
Previously "R" could overshadow "Ruby", and "C" could overshadow
  "Clojure", causing blocks of the longer language name to fail to
  load. This issue has now been fixed
2010-03-26 20:54:16 -06:00
Eric Schulte 22e4cd9b6d babel: org-babel-c more robust, better error messages and c++ support 2010-03-26 19:35:31 -06:00
Eric Schulte b61019489c babel: org-babel-C now displays compilation error messages 2010-03-26 17:12:43 -06:00
Eric Schulte e3fbc98b26 babel: removed errant reference to R from org-babel.el 2010-03-26 16:28:25 -06:00
Eric Schulte 17790c7dad babel: limited initial support for C and similar languages 2010-03-26 16:28:23 -06:00
Eric Schulte f400632f94 babel: when passing values from a table an extra '$' prefix forces literal
thanks to Maurizio Vitale for the suggestion.  This allows literal
  values to be passed to code blocks through `sbe' without forcing the
  use of quotes inside the table.
2010-03-25 11:09:38 -06:00
Eric Schulte 727aa263cb babel: src block regexps are more robust to embedded "[begin|end]_src" in block body 2010-03-22 15:19:33 -06:00
Eric Schulte 32bbd3f3bb babel: variable references which look like lisp forms are now evaluated
for example, the following simple example
    #+begin_src emacs-lisp :var two=(+ 1 1)
      (sqrt two)
    #+end_src

    #+results:
    : 1.4142135623730951

  Or this more interesting usage, which pulls variable values from
  headline properties
    *** example headline w/property
        :PROPERTIES:
        :special:  89
        :last-name: schulte
        :END:

    #+begin_src emacs-lisp :var special=(string-to-number (org-entry-get nil "special" t))
      (+ special 1)
    #+end_src

    #+results:
    : 90

    #+begin_src emacs-lisp :var last-name=(org-entry-get nil "last-name" t))
      (message "hello %s" last-name)
    #+end_src

    #+results:
    : hello schulte
2010-03-22 15:19:32 -06:00
Dan Davison abf0a50d1b babel: Ensure that inline code blocks produce string output on export 2010-03-19 10:08:16 -04:00
Dan Davison adb2f3f590 babel: Add octave and matlab support 2010-03-18 14:45:39 -04:00
Dan Davison aa0e4b86ce babel: Fix org-babel-load-file
This was broken by 29a2ab0047
2010-03-18 14:30:54 -04:00
Dan Davison 73d8e57685 babel: Allow tramp syntax when supplying :tangle filename
Patch by Rémi Vanicat.
2010-03-17 21:03:21 -04:00
Dan Davison 29a2ab0047 babel: when tangling do not add extension if filename supplied 2010-03-17 20:09:06 -04:00
Dan Davison 6976d9fc79 babel: org-babel-switch-to-session [C-c M-b z]
org-babel-pop-to-session is an alias of this
2010-03-16 12:57:28 -04:00
Dan Davison 485781ed40 babel: set default-directory in org-babel-pop-to-session 2010-03-13 14:02:47 -05:00
Dan Davison f4ae431706 babel: Make code block params available when initiating session 2010-03-13 14:02:31 -05:00
Dan Davison 215d11c092 babel: New hook org-babel-after-execute-hook
Runs at the end of org-babel-execute-src-block
2010-03-13 14:02:22 -05:00
Dan Davison ba4d698fa1 babel: Provide notification of errors during code execution
This deals with external process :results value mode for R, ruby,
python, perl and clojure: if the shell process has a non-zero exit
code, a buffer containing stderr is displayed.
2010-03-05 11:32:18 +00:00
Dan Davison 4e9a2d4efd babel: Fix bug in shell-command-on-region
Prior to this commit,

OUTPUT-BUFFER nil
REPLACE 'replace
ERROR-BUFFER 'current-buffer

resulted in stdout going with stderr to the current buffer, contra the
docstring. With this change stdout is discarded in this case. The
docstring does stipulate that stdout always should go to *Shell
Command Output*; this change does not make that happen in this case.
2010-03-05 11:32:11 +00:00
Dan Davison 05986e95ea babel: Introduce org-babel copy of shell-command-on-region
At this commit, org-babel-shell-command-on-region is a direct copy of
shell-command-on-region. In addition to switching to use the org-babel
version, we change the argument passed so that they agree with the
docstring of s-c-o-r.

Despite the change in arguments, the same behaviour results because
s-c-o-r does not behave as documented in emacs23. Future commits will
be able to fix these bugs in the org-babel version, as necessary.
2010-03-05 11:32:04 +00:00
Dan Davison ed7b8bfcca babel: clojure: read results remotely when necessary 2010-03-03 22:00:08 +00:00
Dan Davison 54c7b04734 babel: clojure: use shell-command-on-region 2010-03-03 21:59:32 +00:00
Dan Davison a8c1a49b77 babel: Read perl results remotely when necessary. 2010-03-03 16:11:04 +00:00
Dan Davison 9c36b20a25 babel: make output file links track changed directory 2010-03-02 14:51:01 +00:00
Dan Davison 486bc2fe64 babel: Use file-name-as-directory to form default-directory 2010-03-02 14:51:01 +00:00
Eric Schulte f0f511916a babel: org-babel-oz.el now uses unix-style newline characters 2010-03-01 08:31:05 -07:00
Dan Davison 44c8487e2d babel: fix bug with remote working directory
This change fixes a bug in the remote execution branch, involving the
way that org-babel-tramp-handle-call-process-region is used
to (conditionally) handle calls to call-process-region. When
org-babel-execute-src-block called itself recursively (e.g. when
resolving a reference to another src block), a circular binding of
symbols and values resulted.
2010-02-27 18:19:18 -05:00
Dan Davison 322fe431c5 babel: Write R input data remotely when necessary. 2010-02-27 18:19:09 -05:00
Eric Schulte a705bf5925 babel: wrapped `org-babel-make-remote-file-name' in conditional as `org-babel-maybe-remote-file' 2010-02-27 18:18:37 -05:00
Dan Davison 24cdeea122 babel: read remote results from remote files
When using ':results value' in certain situations, results are written
to file by the foreign language process and subsequently read from
file by emacs into an elisp table structure. If the foreign language
process is running remotely, then the results are written
remotely. These changes ensure that in that case, an appropriate
remote file name is constructed to read the remote data.
2010-02-27 14:14:08 -05:00
Dan Davison 2056d7d419 babel: Allow shell-command-on-region to execute remotely
These changes solve two problems: both are discussed in the following thread

http://lists.gnu.org/archive/html/tramp-devel/2010-02/msg00025.html

of which a summary follows.

Firstly, shell-command-on-region does not work with tramp in the same
way that shell-command does. I.e. whereas

(let ((default-directory "/user@remote-host:"))
  (shell-command "hostname" t))

gives the remote hostname,

(let ((default-directory "/user@remote-host:"))
  (shell-command-on-region (point) (mark) "hostname" t))

does not.

The reason is that shell-command-on-region calls call-process-region,
which does not use a tramp handler for remote files. However, such a
file handler does exist (unused) in the tramp sources:
tramp-handle-call-process-region. There is a slight problem in that
there is a bug in that function definition in current tramp (which has
persisted because the function is not normally used).

Therefore, we define an org-babel version of
tramp-handle-call-process-region which fixes the bug, and we bind
call-process-region to org-babel-tramp-handle-call-process-region for
the duration of org-babel-execute-src-block.
2010-02-27 14:14:08 -05:00
Dan Davison b3d5a1eb39 babel: working directories and remote execution
This introduces a new header argument :dir. For the duration of source
block execution, default-directory is set to the value of this header
argument. Consequences include:

- external interpreter processes run in that directory
- new session processes run in that directory (but existing ones are unaffected)
- relative paths for file output are relative to that directory

The name of a directory on a remote machine may be specified with
tramp syntax (/user@host:path), in which case the interpreter
executable will be sought in tramp-remote-path, and if found will
execute on the remote machine in the specified remote directory.
2010-02-27 14:14:08 -05:00
Dan Davison 5f8a57ad48 babel: change implementation of external R process evaluation
Use shell-command-on-region, bringing R into line with ruby, python,
clojure, shell. In addition to consistency (and perhaps efficiency),
this will also be preferable in the case of a remote R process because
it means that transfer of the input to the remote process is dealt
with automatically by tramp.
2010-02-27 14:14:08 -05:00
Eric Schulte 522f30bc9f babel: tiny doc tweak 2010-02-27 14:14:07 -05:00
Dan Davison cc7052540b babel: allow point to move to end of comint buffer 2010-02-27 14:14:07 -05:00
Dan Davison 283ebcb43b babel: New const variable org-babel-header-arg-names
This is used when checking for babel header args in org properties.
2010-02-27 14:14:07 -05:00
Dan Davison 82d7585810 babel: Tighten result and source line regexps
Anchored to beginning of line, with optional whitespace indenting.
2010-02-25 17:58:46 -05:00
Dan Davison 5833fbd358 babel: Make colnames header arg expect use "yes" for true. 2010-02-25 17:58:46 -05:00
Dan Davison 4064c31fa7 babel: get rid of unused variable 2010-02-25 17:58:46 -05:00
Dan Davison fc693eb5e2 babel: treat python tuples as lists 2010-02-25 17:58:45 -05:00
Dan Davison a95c05773e babel: Fix unquoting of strings
Before this change we have

 #+begin_src ruby :results value :session
 ["1", "3"]
 #+end_src

 #+results:
 : 1", "3

 After, we have

 #+begin_src ruby :results value :session
 ["1", "3"]
 #+end_src

 #+results:
 | 1 | 3 |
2010-02-25 17:58:45 -05:00
Dan Davison 6f62066ac6 babel: Fix export bug.
Introduced at 747f425f00
2010-02-25 15:12:47 -05:00
Eric Schulte 8625e5c0bc babel: gnuplot can now return it's string output -- when session is set to "none" 2010-02-23 08:16:25 -07:00
Dan Davison a2d94ffc8e babel: prevent quoting of strings in shell variables 2010-02-23 07:31:43 -07:00
Eric Schulte 753d1402d8 babel: avoid infinite loop in org-babel-execute-buffer -- Thanks to Stephan Schmitt 2010-02-16 13:34:09 -07:00
Eric Schulte 574f1b590e babel: adding support for the OZ programming language -- Thanks to Torsten Anders!
For information on the OZ programming language see
  http://www.mozart-oz.org/, for information on using Org-babel with
  OZ see the OZ specific documentation on Worg at
  http://orgmode.org/worg/org-contrib/babel/languages/org-babel-doc-oz.php
2010-02-16 13:28:08 -07:00
Dan Davison 1e96482389 babel: check pdf file existence before deleting 2010-02-15 10:29:56 -07:00
Dan Davison 747f425f00 babel: only add srcname property for source blocks which actually have names 2010-02-15 10:07:23 -07:00
Eric Schulte 692c569215 babel: smarter `org-babel-ref-split-args' -- fixes bug parsing indexed function-style args 2010-02-14 11:48:28 -07:00
Eric Schulte 25f76ffa44 babel: now including source code block arguments w/source name on export
This change provides for better export of named source-code blocks,
  with specific support for more attractive html export.  The arguments
  are included with the source code name, and both the source code name
  and code body are wrapped in a div to support styling with css.  For
  example the following CSS can be used to associate a source-code block
  name with it's code body, and to slightly indent the body.

.org-src-container {
  border-left: 4px solid gray;
  padding: 0.5em 0.5em 0.5em 1em; }
  .org-src-container pre {
    margin-left: 1em; }
2010-02-10 13:34:00 -07:00
Eric Schulte 2531d704c0 babel: now able to reference links as results 2010-02-09 20:30:28 -07:00
Eric Schulte db1fe2a619 babel: greatly simplified block exportation 2010-02-09 19:09:19 -07:00
Eric Schulte df418de954 babel-clojure: slight change allowing strings to be passed in as variables 2010-02-08 13:17:37 -07:00
Eric Schulte 2829f77e2b babel: org-babel-load-file no longer fails when `file-truename' returns nil 2010-02-08 13:17:06 -07:00
Eric Schulte b59ebe6ec2 babel: org-babel-load-file will no longer strip portions of file names which appear to be extensions 2010-02-07 11:42:55 -07:00
Eric Schulte a60a83fbb6 babel: better handling of table in shell scripts 2010-02-07 10:17:20 -07:00
Eric Schulte 047ac8ab1b babel: shell command used by org-babel-sh is now configurable using the org-babel-sh-command variable 2010-02-07 09:36:56 -07:00
Eric Schulte e4bc599745 org-babel-latex: allow pdf/png generation directly from latex source blocks 2010-02-06 09:54:10 -07:00
Eric Schulte 3ce4962447 babel: added :shebang and :comments header arguments for finer control over tangled output 2010-02-05 19:04:50 -07:00
Eric Schulte 131441dbd2 babel: load-file works for symlinks -- Thanks to Martin Kühl 2010-02-04 09:43:11 -07:00
Dan Davison 21849af58b babel: can now tangle files without extensions 2010-01-28 09:58:52 -07:00
Eric Schulte b59a57e890 babel: bug fix related to "no longer overwriting non-babel src blocks" commit
this fixes a bug introduced in commit
  d154f27947
2010-01-25 23:54:03 -07:00
Eric Schulte d154f27947 babel: no longer overwriting non-babel src blocks org-exp-blocks: adding progress-marker local variable
the progress-marker local variable set inside of a let in
  org-exp-blocks is used to constrain searches in org-babel-exp to
  ensure that a babel block doesn't overwrite non-babel src blocks
2010-01-18 13:36:27 -07:00
Eric Schulte aa72dfc54f babel: implement org-babel-load-session:* for R, clojure, gnuplot, python, ruby and sh 2010-01-11 10:14:30 -07:00
Eric Schulte 1e8107faf7 babel: improve doc strings for org-babel-execute-buffer and org-babel-execute-subtree 2010-01-11 08:47:29 -07:00
Joel Boehland baa98c1f14 Added support to name the slime-output-buffer (slime-repl) to the name of the respective org-babel session
Signed-off-by: Joel Boehland <joel.boehland@evocomputing.com>
2010-01-09 14:25:18 -07:00
Eric Schulte 682d7a3193 babel: fixed bug where :exports was forced to "results" whenever :file was set 2010-01-09 12:44:02 -07:00
Joel Boehland 7121a5e9c8 babel: add session support for clojure 2010-01-06 17:38:35 -07:00
Eric Schulte cd587c7148 babel: now exports source code block names
When exporting to html the source-code block name will be included
   as a <label> immediately preceding the exported code.  This <label>
   is decorated with the 'org-src-name' css class.

   When exporting to LaTeX with the listings package the source-code
   block name will be included as a listings \title for the code
   block.  Currently the name will not be exported when the listings
   package is not in use.
2010-01-05 08:33:08 -07:00
Eric Schulte 0d82a1f2bc babel: fixed type in org-babel-keys 2010-01-01 15:55:11 -07:00
Eric Schulte da03a848e5 babel: now correctly combining nested tangle header arguments 2009-12-30 17:37:03 -07:00
Eric Schulte 2a2a76c2a3 babel: typo 2009-12-30 17:05:05 -07:00
Eric Schulte e9acf4276e babel: adding keys bindings for org-babel functions in org-babel-keys.el 2009-12-30 16:15:55 -07:00
Eric Schulte 80d41a9121 babel: inheriting properties from higher levels, tracking more properties 2009-12-28 18:04:25 -07:00
Eric Schulte 126f7a3582 org-babel: :cache header argument now uses standard "yes" "no" arguments 2009-12-22 10:11:23 -07:00
Eric Schulte 4815da4b16 org-babel: noweb references are not activated by default 2009-12-18 13:35:30 -07:00
Eric Schulte 0ec408cd9a org-babel: no quotes around strings in table output -- Thanks to Francesco Pizzolante 2009-12-18 11:10:03 -07:00
Eric Schulte 904a37a850 babel: noweb insertions are now placed behind the line prefix of the <<>> reference
So, for example since the following <<example>> noweb reference
  appears behind the SQL comment syntax the entire inserted body will
  also be SQL commented

-- <<example>>

  expands to

-- this is the
-- multi-line body of example

  Note that noweb replacement text which does *not* contain any
  newlines will not be affected by this change, so it is still
  possible to use inline noweb references.

  Thanks to Sébastien Vauban for this idea.
2009-12-17 11:22:00 -07:00
Eric Schulte 0969873888 org-babel-gnuplot: variable expansion in gnuplot source-code with '$' character
Variable names in gnuplot source code preceded by the '$' character
  will be expanded to their value before the code is executed.  For
  example the following will results in the evaluation of 'plot
  sin(x)' by gnuplot.

  "sin(x)"

  plot $fun
2009-11-30 21:01:43 -07:00
Benjamin Andresen c1ee488f45 org-babel-screen: now parsing it's own parameters 2009-11-30 07:20:51 -07:00
Eric Schulte dc5c41fbdc org-babel: fixed typo in reference resolution for #+results: lines 2009-11-29 10:00:19 -07:00
Dan Davison 4cbedbff1a org-babel: Fix insertion of new results
Insertion of new results was failing if the block was followed by
end-of-buffer. Also, if the block was followed by non-empty lines, the
\#+resname was being inserted away from column 0.
2009-11-27 20:28:27 -07:00
Eric Schulte bec1643a40 org-babel-sh: fixed session-based evaluation for sh blocks 2009-11-27 12:31:28 -07:00
Eric Schulte 4b6d270b16 org-babel: bug fix, now possible to evaluate source blocks before the first heading 2009-11-20 19:38:23 -07:00
Eric Schulte 5b749d2fe9 org-babel: fixing documentation of `org-babel-tangle-langs' 2009-11-20 10:43:15 -07:00
Eric Schulte 222f5c23e8 org-babel: results are now foldable
pressing tab while on the front of a results line will fold the
  results in the same manner as tabbing on the front of a block will
  fold the block.  To automatically hide all blocks when entering a
  new file add the `org-babel-result-hide-all' function to your
  `org-mode-hook'
2009-11-20 10:43:14 -07:00
Eric Schulte 45cce02402 org-babel: caching bugfixes
- the match-string was thrown off by an earlier commit
  - now sorting the parameters to ensure consistent order when
  - generating hashes
2009-11-20 10:43:06 -07:00
Dan Davison 2f05cf41ff org-babel: allow header arg values to be lisp forms.
This allows e.g.

:file (format "%s/images/pca-scatter.png" dir)
2009-11-20 10:42:54 -07:00
Dan Davison bf6089d8de org-babel: allow aliases for #+lob
This introduces #+call as an alias for #+lob.
2009-11-20 10:42:53 -07:00
Eric Schulte 91661d2f3b org-babel: #+srcname: can now be called #+source: or #+function:
source name regular expression has been extracted into a variable
  and multiple aliases are allowed.
2009-11-20 10:42:51 -07:00
Eric Schulte 2f8d30a578 org-babel: now using #+results instead of #+resname
"results" is now an acceptable alias for "resname".  Org-babel
    will begin inserting results using the "results" option however
    either option will remain viable moving forward.
2009-11-20 10:42:50 -07:00
Eric Schulte f4f38bd33a org-babel: results hashes are now hidden (for the most part)
The initial `org-babel-hash-show' characters of the hash will
   remain visible.  Pressing C-c C-c with the point on one of these
   initial characters will copy the hash to the kill ring, should you
   need to know it for any particular reason.
2009-11-20 10:42:48 -07:00
Eric Schulte 403c92f676 org-babel: set default behavior to non-caching in `org-babel-default-header-args'
This can be overridden with the use of the header argument :cache on
  the block, or subtree level.  To set the global behavior to caching
  add the following to your emacs init

  (setq org-babel-default-header-args
        (delete '(:nocache) org-babel-default-header-args))
2009-11-20 10:42:47 -07:00
Eric Schulte 1453f0294d org-babel: Hash based caching of results in buffer
This commit expands the #+resname: line to include a sha1 hash of
  the contents of the source-code block (including header arguments).
  This hash is saved in raw text in the resname line.  When a source
  block is evaluated it's hash is recalculated and checked against the
  hash in it's results line, if they are equal the current results are
  returned with no recalculation.

  Optional prefix argument when evaluating a source block will force
  re-calculation.

  caching behavior can be inhibited through the use of the :nocache
  header argument.  for global inhibition of caching add :nocache to
  the `org-babel-default-header-args' variable.
2009-11-20 10:42:33 -07:00
Eric Schulte 4646bacfde org-babel-exp: fixed export bug
the problem is that we were searching back to the previous source
  block before source block execution.
2009-11-16 09:23:19 -07:00
Eric Schulte 1d2bab1fb8 org-babel: variable values are now indexable
it is now possible to only assign a portion of a value to a variable
  in a source block.  So for example the following will only assign
  the second and third lines of the table 'example-table' to the
  variable 'data'

  :var data=example-table[1:2]

  and the following will only assign the second column of the first row

  :var data=example-table[0,1]

  note that all indices are 0 based

  it is possible to index into the results of source-code blocks as
  well as tables.  any number of dimensions can be indexed as long as
  they are separated by ','s and ranges can be indexed using the ':'
  operator.  for more information on indexing behavior see
  `org-babel-ref-index-list'
2009-11-14 20:18:12 -07:00
Eric Schulte d4a43d28e7 org-babel-exp: bug fix, once again allowing export of non-babel source blocks 2009-11-13 10:47:11 -07:00
Eric Schulte 56a81ee65a org-babel: no longer consumes src-block reference strings during export
Before this change to `org-babel-src-block-regexp' any strings
  following src-block switches were being removed during export.
2009-11-12 18:31:55 -07:00
Dan Davison a9069d8dfd org-babel: more robust version of :results value for python and perl.
In ':results value' ('functional') mode, a return statement is now
required in python and perl code.
2009-11-11 16:09:05 -05:00
Joel Boehland 838363f047 Change defn to def for session level variable declarations. Trim trailing whitespace. 2009-11-11 11:52:51 -07:00
Dan Davison 3547a6b64d org-babel: further cleaning of parameter-passing to language files
Also update docstrings of language execution functions to reflect
changes.
2009-11-10 15:23:26 -07:00
Eric Schulte 0fa68a53ba org-babel: language specific files using cleaner parameter passing 2009-11-10 15:23:18 -07:00
Eric Schulte 082fb84c34 org-babel: cleaner passing of parameter to language specific files 2009-11-10 15:23:00 -07:00
Eric Schulte 28881fa29d org-babel: added `org-babel-noweb-error-langs' to raise errors when noweb references can't be resolved 2009-11-10 08:59:17 -07:00
Eric Schulte 97e21c5b09 org-babel-clojure: one list tiny fix 2009-11-09 22:44:13 -07:00
Eric Schulte 103e0c4bf5 org-babel-clojure: minor bug fixes 2009-11-09 22:24:06 -07:00
Joel Boehland 78a3c5d57b org-babel-clojure: Added clojure language support to org-babel 2009-11-09 22:23:38 -07:00
Dan Davison bf3281692f org-babel-tangle: Save buffer at outset. 2009-11-09 09:32:05 -07:00
Dan Davison bec4551d8b org-babel: Add support for perl
Session-based evaluation is not supported.
2009-11-09 09:32:04 -07:00
Dan Davison 3ec02a953d org-babel-python: Silent bug fix.
The code worked because the unintended extra parentheses didn't cause problems.
2009-11-09 09:32:02 -07:00
Dan Davison 6875d4d8e3 org-babel: file output for ruby and python
With this change, if :file <filepath> is specified, ruby and python
blindly output a link to <filepath>. Responsibility for creating the
contents in <filepath> lies with the python/ruby code.
2009-11-09 09:32:01 -07:00
Dan Davison 210f85ce49 org-babel: store noweb-expanded code body in 'info' data structure 2009-11-09 09:32:00 -07:00
Eric Schulte e3bf0b4a81 org-babel-haskell: org-babel-haskell-export-to-lhs now optionally preserves indentation
based either on the value of org-src-preserve-indentation or the
    presence of the -i switch
2009-11-04 17:46:55 -07:00
Eric Schulte 260007e61f org-babel-tangle: now careful to only add one shebang per file 2009-11-04 15:18:50 -07:00
Eric Schulte cd405fad22 org-babel-tangle: now conservative about whitespace insertion around tangled blocks 2009-11-04 15:14:45 -07:00
Dan Davison 43bd90ef81 org-babel: new header argument :results_switches
If present this should be followed by org-mode block switches to be
inserted with the results block.
2009-11-04 14:55:10 -07:00
Dan Davison ea2cd9b1c8 org-babel: make info structure available when removing/inserting results
This also eliminates two extra calls to org-babel-get-src-block-info.
2009-11-04 14:55:09 -07:00
Dan Davison f01fb927e1 org-babel: read results contained in generic org blocks 2009-11-02 06:50:28 -07:00
Dan Davison 13d670744e org-babel: set case-fold-search t when reading results 2009-11-02 06:50:26 -07:00
Dan Davison 43cd1aa2b9 org-babel: trim trailing newline from noweb-referenced material 2009-11-01 14:39:17 -05:00
Dan Davison 8b33a47410 org-babel: match multiple noweb references on same line correctly. 2009-11-01 14:38:17 -05:00
Dan Davison 3cf02c1afa org-babel: allow regexp to be supplied in org-babel-trim, as per docstring. 2009-11-01 14:36:47 -05:00
Dan Davison c84903f1b3 org-babel: export of functional-style source blocks
A "functional-style" source block is one in which the name is followed
immediately by a parenthesised argument. An example is the following
"function", which generates n uniform random numbers:

\#+srcname: rand(n)
\#+begin_src R
runif(n)
\#+end_src

With these changes, such source blocks are passed over to the export
machinery in the following form:

\#+begin_src org-babel-lob
<function-def-keyword> rand(n):
\#+end_src
\#+begin_src R <switches>
<indent>runif(n)
\#+end_src

where <function-def-keyword> is the value of
org-babel-function-def-export-keyword, which defaults to "function",
<switches> are the src block switches that belonged to the original
block, and <indent> is the whitespace indent of the function body, the
width of which is determined by org-babel-function-def-export-indent.
org-babel-lob is a simple major mode responsible for fontification of
the blocks corresponding to the function definition line (as opposed
to the function body).
2009-11-01 10:05:42 -05:00
Dan Davison 75299025d6 org-babel: use org-babel-get-src-block-info during export 2009-11-01 10:05:42 -05:00
Dan Davison 872d9157d9 org-babel: include functional-style args in org-babel-get-src-block-info list
This adds a new terminal (sixth) element to the list returned from
org-babel-get-src-block-info. It is used when exporting the code of
"functional style" code blocks, i.e. those in which the name of the
block is followed by a parenthesised argument list (or an empty pair
of parentheses).
2009-11-01 10:05:42 -05:00
Dan Davison d97f767632 org-babel: avoid inserting blank line at bottom of exported code blocks 2009-11-01 10:05:42 -05:00
Dan Davison 64cd40700e org-babel: Reinstate switches when exporting blocks of code 2009-11-01 10:05:42 -05:00
Dan Davison a0d03014ab org-babel: internal change: defer breaking up of info list in org-babel-exp.el 2009-11-01 10:05:42 -05:00
Dan Davison 72691f1ff7 org-babel: Single function to return all source block info.
- org-babel-get-src-block-info returns the name of the block as a new
  fifth element.

- org-babel-get-src-block-info incorporates the parenthesised variable
  references into the header arg list, with precendence given to
  explicit :var references, as before.

- remove function org-babel-get-src-block-name

- remove function org-babel-get-src-block-function-args

org-babel-get-src-block-function-args now returns a list
  (lang body params-alist switches srcname)
where, unless a non-nil value for the optional argument is passed,
params-alist contains any :var entries acquired from the parenthesised
argument list following the srcname.
2009-11-01 10:05:42 -05:00
Dan Davison dcc669f20a org-babel: parse src block switches
The switches are flags like -n and must *precede* the first colon
after the language (i.e. precede the first header argument). So the
general src block syntax is
\#+begin_src lang <switches> :header1 val1 :header2 val2 ...
...

org-babel-get-src-block-info now returns a list
(lang body params-alist switches)
2009-11-01 10:05:41 -05:00
Dan Davison c7d3844bd9 org-babel: annotate org-babel-src-block-regexp with comments for clarity 2009-11-01 10:05:41 -05:00
Dan Davison c6fb5d94d0 org-babel: update authorship records 2009-11-01 10:05:41 -05:00
Dan Davison 7cea83d870 org-babel-exp: ensure presence of `org-current-export-file' before resolving foreign file references 2009-10-29 09:00:50 -06:00
Eric Schulte e01839a826 org-babel-latex: initial support for exporting latex from org-babel 2009-10-28 16:13:53 -06:00
Eric Schulte f4d5b6dd49 org-babel noweb reference evaluation
noweb references which include ()s are now evaluated.  It is
  possible to pass arguments to the noweb references using the existing
  lob argument syntax.  So after this commit the following

<<example-block>>

  will insert the body of "example-block", and the following

<<example-block()>>

  will insert the results of "example-block", and the following

<<example-block(a=9)>>

  will insert the results of "example-block" with argument "a" set to
  the literal value of 9
2009-10-28 16:13:33 -06:00
Dan Davison 962a1e0608 org-babel: fix inline source block regexp
This satisfies the requirements that
1. the src_lang{} construct is preceded by whitespace
2. this whitespace is not consumed by the replacement text
2009-10-26 21:51:43 -06:00
Dan Davison 512b376bb5 org-babel: allow multiple spaces/tabs between "src" and lang 2009-10-26 21:51:42 -06:00
Dan Davison 2f82ee771a org-babel: use %s to format inline result when it is a string.
This avoids returning quote characters with the string.
2009-10-26 21:51:41 -06:00
Dan Davison 3fa8c7dfff org-babel: enforce canonical (lang body params) order of arguments 2009-10-26 21:51:39 -06:00
Eric Schulte 1771e61cfc org-babel-exp: simplification of org-babel-lob-mode 2009-10-25 12:52:17 -06:00
Eric Schulte 6851f07f92 org-babel-exp: adding org-babel-lob-mode for fontification of lob lines 2009-10-25 10:47:12 -06:00
Dan Davison 70a5963563 org-babel: avoid false positive matches for inline and #+lob constructs
This forces the #+lob regexp to match at the beginning of a line (with
optional preceding whitespace), and requires inline code blocks to be
surrounded by some whitespace.
2009-10-25 10:47:07 -06:00
Dan Davison 5f1ea1ce70 org-babel: By default, don't use session for inline blocks 2009-10-25 10:47:06 -06:00
Dan Davison ed0f4a36e9 org-babel: Export code and/or results of #+lob function calls.
Currently, python fontification is used for export of these lines, due
to some similarity between python function call syntax and #+lob call
syntax. This is implemented as a language type "babel", mapped to
python in org-src-lang-modes.
2009-10-24 15:27:43 -06:00
Eric Schulte 824c8c0dba org-babel: behaviour-neutral changes anticipating subsequent work on export
merging original change by Dan Davison which generalizes the types
  of blocks exported by org-babel to include the following types
  - inline
  - lob
  - block
2009-10-23 16:02:29 -06:00
Eric Schulte 6ef0dd44bd org-babel-exp: exporting inline src blocks now respects different :results type 2009-10-23 16:02:28 -06:00
Eric Schulte 4539c8998c org-babel-exp when exporting blocks, don't return results as string
rather execute normally using org-babel-insert-results to insert the
  results in the buffer
2009-10-23 16:02:27 -06:00
Eric Schulte 62c8d0a835 org-babel: foreign-file references work, export is fully functional
1) source blocks can now reference source-blocks in other files using
   the filename:sourcename syntax

2) on export all references are now made to explicitly point to the
   original buffer using the filename:sourcename syntax.  This ensures
   that all references are correctly resolved on export, even when the
   referenced source block has already been processed.
2009-10-23 16:02:24 -06:00
Eric Schulte 540fa74513 org-babel-exp.el is now working for inline blocks 2009-10-23 16:02:23 -06:00
Dan Davison c168c6ccaa org-babel: improve prompt when choosing file to tangle 2009-10-20 10:17:42 -04:00
Dan Davison 32cfddf7b1 org-babel: fix #+lob line regexp 2009-10-20 09:48:03 -04:00
Dan Davison 68a1240db8 org-babel: ensure that result is returned when using :results output
One half of this patch is a revert of c167a4ac32.

These changes are necessary so that :results output works correctly
with #+lob calls. For example the following example did not work:

--------------------------------------------------
3. :results output org -> doesn't work with #+lob:
--------------------------------------------------
\#+srcname: randthree(n,max)
\#+begin_src ruby
number = n
maximum = max
puts "* Random numbers\n" +
"Here are some random numbers: " +
(1..number).collect {|x| (rand * maximum).ceil }.join(", ") +
"."
\#+end_src

\#+lob: randthree(n=3,max=10) :results output org
2009-10-20 09:24:15 -04:00
Dan Davison 64c26c6561 org-babel: remove prompt characters from R output
When evaluating R code in a persistent session, lines of output
typically start with a single prompt character. However, under certain
circumstances, lines start with a concatenation of (primary and
secondary) prompt characters separated by spaces. This seems to be
related to having blank lines in the input. This fix ensures that all
such prompt characters are removed from the output.
2009-10-19 23:34:13 -04:00
Dan Davison 4dba8ad21f org-babel: a bug in reference-resolution caused by a typo 2009-10-19 23:33:13 -04:00
Dan Davison 0d10946cff org-babel: nested calls inherit header args from enclosing scopes
And when merging header args, those from enclosing scopes take
precedence. For example, output to file from a source block is
implemented by (a) sending the output to file, and (b) having the
source block return the file name as its result. Before this change,
the file name returned could be set by a referenced source block (a
nested call), regardless of the value of the :file header arg of the
top-level source block.
2009-10-19 23:33:03 -04:00
Dan Davison 6c0c2039dd org-babel: make [:file filename] imply [:exports results]
Unless :exports is already none or both. This allows users to export
file output simply by adding a [:file filename] header arg.
2009-10-19 23:32:22 -04:00
Dan Davison 286bf35fe5 org-babel: bugfix: tighten up regexp
Prior to this, reference resolution could fail with quoted
strings. E.g. this didn't work:

\#+srcname: py-id(a=1)
\#+begin_src python
  a
\#+end_src

\#+lob: py-id(a="1")
2009-10-19 23:32:14 -04:00
Dan Davison 5219f4a410 org-babel: make org-babel-tangle-file interactive 2009-10-19 21:45:15 -04:00
Dan Davison 351f52192d org-babel: extend the way header args are taken from properties
This change allows org-file-properties to supply header args, and also
allows property inheritance if it has been enabled. Header-args
aquired from the item (or by inheritance) have precedence over those
aquired from org-file-properties.
2009-10-19 21:45:01 -04:00
Dan Davison 8ca34cba0b org-babel: alter R tangling defaults
Use "#!/usr/bin/env Rscript", and use ".R" instead of ".r".
2009-10-19 21:44:41 -04:00
Dan Davison 8b52bf09e0 org-babel: capture graphical output from R
If a [:file filename.ext] header arg is provided, then all graphical
output from the source block is captured on disk, and output of the
source block is a link to the resulting file, as with the
graphics-only languages such as gnuplot, ditaa, dot, asymptote. An
attempt is made to find a graphics device corresponding to the file
extension (currently .png, .jpg, .jpeg, .tiff, .bmp, .pdf, .ps,
.postscript are recognised); if that fails, png format output is
created.

Additionally, values for several arguments to the R graphics
device can be passed using header args:

:width :height :bg :units :pointsize
:antialias :quality :compression :res :type
:family :title :fonts :version :paper :encoding
:pagecentre :colormodel :useDingbats :horizontal

Arguments to the R graphics device that are not supported as header
args can be passed as a string in R argument syntax, using the header
arg :R-dev-args

An example block is (although both bg and fg can be passed directly as
header args)

\#+begin_src R :file z.pdf :width 8 :height 8 :R-dev-args bg="olivedrab", fg="hotpink"
  plot(matrix(rnorm(100), ncol=2), type="l")
\#+end_src
2009-10-19 21:44:28 -04:00
Eric Schulte 4d374b27d2 org-babel: :noweb header argument now expands noweb references before source-block evaluation 2009-10-19 12:12:19 -06:00
Eric Schulte 3db817fb02 org-babel: now supports pp results (emacs-lisp, ruby, python) 2009-10-18 16:18:34 -06:00
Eric Schulte c167a4ac32 org-babel: emacs-lisp now returns nothing when ":results output" 2009-10-18 16:18:27 -06:00
Eric Schulte 4abe8f7ea0 org-babel: added "table" results header argument as more readable alias for "vector" 2009-10-18 12:13:42 -06:00
Eric Schulte 28e6ff8d66 org-babel: adding python support (along the same lines as ruby) 2009-10-16 17:05:31 -06:00
Eric Schulte 770305a650 org-babel: adding ruby support for returning "code" results 2009-10-16 17:05:13 -06:00
Eric Schulte 430a3bf6ad org-babel: "code" results type for returning results in of source code syntax
This includes the required changes to org-babel.el and a
language-specific implementation for emacs-lisp.  The emacs-lisp
changes are from a patch by Benny Andresen.
2009-10-16 17:04:55 -06:00
Eric Schulte b0c1758c2a org-babel: dot improvements
for more information on the dot family of tools see
http://www.graphviz.org/
2009-10-14 16:03:40 -06:00
Eric Schulte 0444ca8661 org-babel: haskell lhs2tex export now responds to prefix argument 2009-10-09 11:44:27 -06:00
Dan Davison e079584e56 org-babel: make tangling honour org-src-preserve-indentation
This allows python code to be tangled (i.e. extracted) correctly by
org-babel-tangle. Previously, if e.g. methods of a class were in
separate blocks, then they would be incorrectly indented as top-level
functions in the tangled output.
2009-10-08 12:29:37 -04:00
Eric Schulte c0d54a9a6b org-babel: Haskell lhs export: ensure all \[begin|end]{code} statements start at the first column 2009-10-07 16:01:24 -06:00