0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 22:47:56 +00:00

Starting to create `library of babel' branch.

This is intended to provide off-the-shelf data plotting and analysis
functions. Current idea is to introduce a new line, perhaps something
like #+babel or #+babel_lib, which will reference (a) some data
and (b) a source block to apply to the data. Code being stolen from
org-babel.el (conceivably some abstraction of some of those functions
could be done to avoid code duplication).
This commit is contained in:
Dan Davison 2009-06-12 20:26:28 -04:00
parent 8ec719aefb
commit 68c3fb2b52
2 changed files with 69 additions and 0 deletions

15
library-of-babel.org Normal file
View file

@ -0,0 +1,15 @@
#+title: The Library of Babel --- off-the-shelf functions for data analysis and plotting using org-babel
#+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
#+OPTIONS: H:3 num:nil toc:t
#+STARTUP: odd hideblocks
[[http://downlode.org/Etext/library_of_babel.html][Full text of Borges short story]]
* Plotting code
Plot column 2 (y axis) against column 1 (x axis). Columns 3 and beyond, if present, are ignored.
#+srcname: plot
#+begin_src R :var xy=__data__
plot(xy)
#+end_src
[[file:/tmp/tmp.org][tem org file]]

54
lisp/org-babel-lob.el Normal file
View file

@ -0,0 +1,54 @@
;;; org-babel-lob.el --- The Library of Babel: off-the-shelf functions for data analysis and plotting using org-babel
;; Copyright (C) 2009 Dan Davison, Eric Schulte
;; Author: Dan Davison, Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
;; Version: 0.01
;;; License:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; See org-babel.org in the parent directory for more information
;;; Code:
(require 'org)
(defvar org-babel-lob-regexp
(concat "#\\+babel[ \t]*"
"\\([ \t]+\\([^\n]+\\)\\)?\n") ;; match header arguments
"Regexp used to test when on a babel library line")
(defun org-babel-lob-execute-maybe ()
"Detect if this is a babel library line and if so
then run `org-babel-lob-execute'."
(interactive)
(let ((info (org-babel-get-src-block-info)))
(if info (progn (org-babel-execute-src-block current-prefix-arg info) t) nil)))
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-lob-call)
(defun org-babel-lob-execute ()
"Execute an org-babel library function."
(interactive)
(provide 'org-babel-lob)