From 68c3fb2b523ebe3cb8b06393785397041b4d82bb Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 12 Jun 2009 20:26:28 -0400 Subject: [PATCH] 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). --- library-of-babel.org | 15 ++++++++++++ lisp/org-babel-lob.el | 54 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 library-of-babel.org create mode 100644 lisp/org-babel-lob.el diff --git a/library-of-babel.org b/library-of-babel.org new file mode 100644 index 000000000..f888620bd --- /dev/null +++ b/library-of-babel.org @@ -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]] diff --git a/lisp/org-babel-lob.el b/lisp/org-babel-lob.el new file mode 100644 index 000000000..3bcc9499c --- /dev/null +++ b/lisp/org-babel-lob.el @@ -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)