浏览代码

beginning to add sessions

Eric Schulte 16 年之前
父节点
当前提交
517253a2d0
共有 6 个文件被更改,包括 55 次插入5 次删除
  1. 1 0
      lisp/org-babel-init.el
  2. 3 1
      lisp/org-babel-script.el
  3. 46 0
      lisp/org-babel-session.el
  4. 1 1
      lisp/org-babel-shell.el
  5. 2 1
      lisp/org-babel.el
  6. 2 2
      org-babel.org

+ 1 - 0
lisp/org-babel-init.el

@@ -36,6 +36,7 @@
 (require 'org-babel-ref)
 (require 'org-babel-exp)
 (require 'org-babel-table)
+(require 'org-babel-session)
 
 ;; language specific files
 (require 'org-babel-script)

+ 3 - 1
lisp/org-babel-script.el

@@ -34,7 +34,7 @@
 (defun org-babel-script-add-interpreter (var cmds)
   (set-default var cmds)
   (mapc (lambda (cmd)
-          (setq org-babel-interpreters (cons cmd org-babel-interpreters))
+          (org-babel-add-interpreter cmd)
           (eval
            `(defun ,(intern (concat "org-babel-execute:" cmd)) (body params)
               ,(concat "Evaluate a block of " cmd " script with org-babel. This function is
@@ -65,6 +65,8 @@ executed through org-babel."
   :group 'org-babel
   :set 'org-babel-script-add-interpreter)
 
+(mapc #'org-babel-add-interpreter org-babel-script-interpreters)
+
 (defun org-babel-script-execute (cmd body params)
   "Run CMD on BODY obeying any options set with PARAMS."
   (message (format "executing %s code block..." cmd))

+ 46 - 0
lisp/org-babel-session.el

@@ -0,0 +1,46 @@
+;;; org-babel-session.el --- session management for org-babel
+
+;; Copyright (C) 2009 Eric Schulte, Dan Davison
+
+;; Author: Eric Schulte, Dan Davison
+;; 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:
+
+;; Org-Babel evaluates code in the context of consistent sessions.
+;; This file will hold functions for interacting with these sections.
+;;
+;; For more information see org-babel.org in the top level directory.
+
+;;; Code:
+(require 'org-babel)
+
+(defcustom org-babel-session-defaults nil
+  "An a-list associating each org-babel interpreter with a
+default session buffer."
+  :group 'org-babel
+  :type 'alist)
+
+
+
+(provide 'org-babel-session)
+;;; org-babel-session.el ends here

+ 1 - 1
lisp/org-babel-shell.el

@@ -34,7 +34,7 @@
 (defun org-babel-shell-add-interpreter (var cmds)
   (set-default var cmds)
   (mapc (lambda (cmd)
-          (setq org-babel-interpreters (cons cmd org-babel-interpreters))
+          (org-babel-add-interpreter cmd)
           (eval
            `(defun ,(intern (concat "org-babel-execute:" cmd)) (body params)
               ,(concat "Evaluate a block of " cmd " shell with org-babel. This function is

+ 2 - 1
lisp/org-babel.el

@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; See rorg.org in the parent directory for more information
+;; See org-babel.org in the parent directory for more information
 
 ;;; Code:
 (require 'org)
@@ -72,6 +72,7 @@ then run `org-babel-execute-src-block'."
 `org-babel-src-block-regexp' appropriately."
   (unless (member interpreter org-babel-interpreters)
     (setq org-babel-interpreters (cons interpreter org-babel-interpreters))
+    (add-to-list 'org-babel-session-defaults (cons interpreter (format "org-babel-%s" interpreter)))
     (org-babel-set-interpreters 'org-babel-interpreters org-babel-interpreters)))
 
 (defcustom org-babel-interpreters '()

+ 2 - 2
org-babel.org

@@ -115,7 +115,8 @@ and the results to be collected in the same table.
 
 
 * Tasks [22/36]
-** TODO Create objects in top level (global) environment in R? [0/5]
+** TODO Create objects in top level (global) environment [0/5]
+*sessions*
 
 *** initial requirement statement [DED]
    At the moment, objects created by computations performed in the
@@ -284,7 +285,6 @@ org-mode core
 This should be implemented in the org-mode core
      
 
-
 *** DEFERRED send code to inferior process
 Another thought on this topic: I think we will want users to send
 chunks of code to the interpreter from within the *Org Edit Src*