Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Eric Schulte writes: > I've just applied this patch. I don't think external dependencies are a > problem if they offload language integration work to a dedicated > external package. The more babel can re-use existing packages the > better, e.g., common lisp code blocks are just thin wrappers around > slime, but they work exceedingly well with almost no babel-side coding > or maintenance. Would you mind keeping the byte-compile clean? --8<---cut here---start->8--- Compiling /home/org-mode/lisp/ob-scheme.el... In org-babel-scheme-get-buffer-impl: ob-scheme.el:81:5:Warning: reference to free variable `geiser-impl--implementation' In org-babel-scheme-execute-with-geiser: ob-scheme.el:130:21:Warning: `message' called with 4 args to fill 3 format field(s) ob-scheme.el:133:15:Warning: assignment to free variable `geiser-repl--repl' ob-scheme.el:134:15:Warning: assignment to free variable `geiser-impl--implementation' In org-babel-execute:scheme: ob-scheme.el:163:25:Warning: reference to free variable `geiser-default-implementation' ob-scheme.el:164:30:Warning: reference to free variable `geiser-active-implementations' In end of data: ob-scheme.el:181:1:Warning: the following functions are not known to be defined: run-geiser, geiser-mode, geiser-eval-region, geiser-repl-exit --8<---cut here---end--->8--- Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf rackAttack: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Ah, apologies and thanks all around. Cheers, Greg Minshall writes: > hi, Eric, > > this patch isn't mine, but rather Michael Gauland's; i just wondered > where it had gone. > > cheers, Greg > >> here is the thread: >> http://comments.gmane.org/gmane.emacs.orgmode/64229 -- Eric Schulte http://cs.unm.edu/~eschulte
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Eric Schulte writes: > Thanks Greg for this patch! (Michael Gauland is the one to thank for the patch, and Greg for the heads up. Thanks to both!) -- Bastien
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
hi, Eric, this patch isn't mine, but rather Michael Gauland's; i just wondered where it had gone. cheers, Greg > here is the thread: > http://comments.gmane.org/gmane.emacs.orgmode/64229
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Bastien writes: > Hi Greg, > > Greg Minshall writes: > >> here is the thread: >> http://comments.gmane.org/gmane.emacs.orgmode/64229 > > Thanks. > > I'm reattaching the patch, with a reworked ChangeLog. > > (We could not apply it at the time because Michael didn't > have his copyright assignment.) > > I like geiser very much, but maybe this introduces too much > external dependencies. > > Eric, do you think we can go ahead and apply it? > I've just applied this patch. I don't think external dependencies are a problem if they offload language integration work to a dedicated external package. The more babel can re-use existing packages the better, e.g., common lisp code blocks are just thin wrappers around slime, but they work exceedingly well with almost no babel-side coding or maintenance. Thanks Greg for this patch! > > PS: The patch does not apply, we need to revert > http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=92e327 > first. Thanks for figuring out this conflict. -- Eric Schulte http://cs.unm.edu/~eschulte
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Greg Minshall writes: > hi, Bastien, > >>> hi. what happened to this patch? i don't see it anywhere. cheers! > >> Can you give a pointer to "this" patch? > > here is the thread: > http://comments.gmane.org/gmane.emacs.orgmode/64229 > > cheers, Greg > Hi Greg, Thanks for sending this along. 1. Have you completed the FSF assignment? I don't see you listed on http://orgmode.org/worg/org-contribute.html 2. This patch no longer applies cleanly, I get the following error output when trying to apply it to the current repo. 17:24 bagel:org-mode git am ~/64406-001.bin Applying: Use geiser for babel scheme evaluation. /home/eschulte/src/org-mode/.git/rebase-apply/patch:83: trailing whitespace. (or buffer /home/eschulte/src/org-mode/.git/rebase-apply/patch:87: trailing whitespace. (progn /home/eschulte/src/org-mode/.git/rebase-apply/patch:101: trailing whitespace. (let ((result /home/eschulte/src/org-mode/.git/rebase-apply/patch:226: trailing whitespace. error: patch failed: lisp/ob-scheme.el:65 error: lisp/ob-scheme.el: patch does not apply Patch failed at 0001 Use geiser for babel scheme evaluation. Once these are resolved we can apply this patch. Thanks! -- Eric Schulte http://cs.unm.edu/~eschulte
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Hi Greg, Greg Minshall writes: > here is the thread: > http://comments.gmane.org/gmane.emacs.orgmode/64229 Thanks. I'm reattaching the patch, with a reworked ChangeLog. (We could not apply it at the time because Michael didn't have his copyright assignment.) I like geiser very much, but maybe this introduces too much external dependencies. Eric, do you think we can go ahead and apply it? PS: The patch does not apply, we need to revert http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=92e327 first. >From bc33a46041086abd5d1fec321f104aa034823576 Mon Sep 17 00:00:00 2001 From: Michael Gauland Date: Wed, 9 Jan 2013 12:41:13 +1300 Subject: [PATCH] ob-scheme.el: Use geiser for babel scheme evaluation * ob-scheme.el (run-scheme, org-babel-scheme-eoe) (org-babel-scheme-cmd, scheme-program-name) (org-babel-prep-session:scheme) (org-babel-scheme-initiate-session): Deleted. (org-babel-execute-scheme): Rewritten to use geiser. (org-babel-scheme-repl-map, org-babel-scheme-cleanse-repl-map) (org-babel-scheme-get-session-buffer) (org-babel-scheme-set-session-buffer) (org-babel-scheme-get-buffer-impl, org-babel-scheme-get-repl) (org-bable-scheme-make-session-name) (org-babel-scheme-execute-with-geiser): New functions. --- lisp/ob-scheme.el | 192 - 1 files changed, 117 insertions(+), 75 deletions(-) diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el index c9fa44a..31e0cad 100644 --- a/lisp/ob-scheme.el +++ b/lisp/ob-scheme.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2010-2013 Free Software Foundation, Inc. -;; Author: Eric Schulte +;; Authors: Eric Schulte, Michael Gauland ;; Keywords: literate programming, reproducible research, scheme ;; Homepage: http://orgmode.org @@ -33,27 +33,16 @@ ;; - a working scheme implementation ;; (e.g. guile http://www.gnu.org/software/guile/guile.html) ;; -;; - for session based evaluation cmuscheme.el is required which is -;; included in Emacs +;; - for session based evaluation geiser is required, which is available from +;; ELPA. ;;; Code: (require 'ob) -(eval-when-compile (require 'cl)) - -(declare-function run-scheme "ext:cmuscheme" (cmd)) +(load-library "geiser-impl") (defvar org-babel-default-header-args:scheme '() "Default header arguments for scheme code blocks.") -(defvar org-babel-scheme-eoe "org-babel-scheme-eoe" - "String to indicate that evaluation has completed.") - -(defcustom org-babel-scheme-cmd "guile" - "Name of command used to evaluate scheme blocks." - :group 'org-babel - :version "24.1" - :type 'string) - (defun org-babel-expand-body:scheme (body params) "Expand BODY according to PARAMS, return the expanded body." (let ((vars (mapcar #'cdr (org-babel-get-header params :var @@ -65,70 +54,123 @@ ")\n" body ")") body))) -(defvar scheme-program-name) + +(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal) + "Map of scheme sessions to session names.") + +(defun org-babel-scheme-cleanse-repl-map () + "Remove dead buffers from the REPL map." + (maphash + (lambda (x y) + (when (not (buffer-name y)) + (remhash x org-babel-scheme-repl-map))) + org-babel-scheme-repl-map)) + +(defun org-babel-scheme-get-session-buffer (session-name) + "Look up the scheme buffer for a session; return nil if it doesn't exist." + (org-babel-scheme-cleanse-repl-map) ; Prune dead sessions + (gethash session-name org-babel-scheme-repl-map)) + +(defun org-babel-scheme-set-session-buffer (session-name buffer) + "Record the scheme buffer used for a given session." + (puthash session-name buffer org-babel-scheme-repl-map)) + +(defun org-babel-scheme-get-buffer-impl (buffer) + "Returns the scheme implementation geiser associates with the buffer." + (with-current-buffer (set-buffer buffer) +geiser-impl--implementation)) + +(defun org-babel-scheme-get-repl (impl name) + "Switch to a scheme REPL, creating it if it doesn't exist:" + (let ((buffer (org-babel-scheme-get-session-buffer name))) +(or buffer +(progn + (run-geiser impl) + (if name + (progn + (rename-buffer name t) + (org-babel-scheme-set-session-buffer name (current-buffer + (current-buffer) + +(defun org-babel-scheme-make-session-name (buffer name impl) + "Generate a name for the session buffer. + +For a named session, the buffer name will be the session name. + +If the session is unnamed (nil), generate a name. + +If the session is 'none', use nil for the session name, and +org-babel-scheme-execute-with-geiser will use a temporary session." + (let ((result + (cond ((not name) + (concat buffer " " (symbol-name impl) " REPL")) + ((string= name "none") nil) + (name +result)) + +(defun org-babel-scheme-execute-with-geiser (code output impl repl) + "Execute code in specified REPL. If the REPL doesn't exist, create it +using the given scheme implementation. + +Returns the output of executing the code if the output paramete
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
hi, Bastien, >> hi. what happened to this patch? i don't see it anywhere. cheers! > Can you give a pointer to "this" patch? here is the thread: http://comments.gmane.org/gmane.emacs.orgmode/64229 cheers, Greg
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Hi Greg, Greg Minshall writes: > hi. what happened to this patch? i don't see it anywhere. cheers! Can you give a pointer to "this" patch? Thanks! -- Bastien
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
hi. what happened to this patch? i don't see it anywhere. cheers!
Re: [O] [PATCH] Use geiser for babel scheme evaluation.
Hi Michael, Michael Gauland writes: > I've done the rename, un-dangled the parentheses, and prepared a > changelog: Thanks Michael. I ping'ed the FSF copyright clerk for some news, I hope he's not overwhelmed after Christmas holidays. Best, PS: Next time put the ChangeLog directly in the commit message, that's even quicker for me. -- Bastien
[O] [PATCH] Use geiser for babel scheme evaluation.
On 06/01/13 19:56, Bastien wrote: > Well, I'm afraid we'll have to go the clean way: just document the > deleted functions, the new ones, and the ones that have been > rewritten. No need to go too much into details. Also let's rename > `cleanse-org-babel-scheme-repl-map' to > `org-babel-scheme-cleanse-repl-map'. I've done the rename, un-dangled the parentheses, and prepared a changelog: Babel: Use geiser to manage scheme sessions * lisp/ob-scheme.el: Load the geiser library (run-scheme): Removed (org-babel-scheme-eoe): Removed (org-babel-scheme-cmd): Removed (scheme-program-name): Removed (org-babel-scheme-repl-map): Hash mapping session names to sessions. (org-babel-scheme-cleanse-repl-map): Remove dead sessions from map. (org-babel-scheme-get-session-buffer): Return buffer associated with a session. (org-babel-scheme-set-session-buffer): Record the buffer associated with a session. (org-babel-scheme-get-buffer-impl): Return the scheme implementation geiser associates with a buffer. (org-babel-scheme-get-repl): Switch to the scheme REPL buffer for a session, creating it if it doesn't exist. (org-bable-scheme-make-session-name): Generate a name for a session, if one was not specified. (org-babel-scheme-execute-with-geiser): Execute scheme code, creating the REPL if necessary. (org-babel-execute-scheme): Rewritten to use geiser. (org-babel-prep-session:scheme): Removed (org-babel-scheme-initiate-session): Removed This uses geiser to evaluate babel scheme source blocks, and generally improves scheme support. From bc33a46041086abd5d1fec321f104aa034823576 Mon Sep 17 00:00:00 2001 From: Michael Gauland Date: Wed, 9 Jan 2013 12:41:13 +1300 Subject: [PATCH] Use geiser for babel scheme evaluation. --- lisp/ob-scheme.el | 192 - 1 files changed, 117 insertions(+), 75 deletions(-) diff --git a/lisp/ob-scheme.el b/lisp/ob-scheme.el index c9fa44a..31e0cad 100644 --- a/lisp/ob-scheme.el +++ b/lisp/ob-scheme.el @@ -2,7 +2,7 @@ ;; Copyright (C) 2010-2013 Free Software Foundation, Inc. -;; Author: Eric Schulte +;; Authors: Eric Schulte, Michael Gauland ;; Keywords: literate programming, reproducible research, scheme ;; Homepage: http://orgmode.org @@ -33,27 +33,16 @@ ;; - a working scheme implementation ;; (e.g. guile http://www.gnu.org/software/guile/guile.html) ;; -;; - for session based evaluation cmuscheme.el is required which is -;; included in Emacs +;; - for session based evaluation geiser is required, which is available from +;; ELPA. ;;; Code: (require 'ob) -(eval-when-compile (require 'cl)) - -(declare-function run-scheme "ext:cmuscheme" (cmd)) +(load-library "geiser-impl") (defvar org-babel-default-header-args:scheme '() "Default header arguments for scheme code blocks.") -(defvar org-babel-scheme-eoe "org-babel-scheme-eoe" - "String to indicate that evaluation has completed.") - -(defcustom org-babel-scheme-cmd "guile" - "Name of command used to evaluate scheme blocks." - :group 'org-babel - :version "24.1" - :type 'string) - (defun org-babel-expand-body:scheme (body params) "Expand BODY according to PARAMS, return the expanded body." (let ((vars (mapcar #'cdr (org-babel-get-header params :var @@ -65,70 +54,123 @@ ")\n" body ")") body))) -(defvar scheme-program-name) + +(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal) + "Map of scheme sessions to session names.") + +(defun org-babel-scheme-cleanse-repl-map () + "Remove dead buffers from the REPL map." + (maphash + (lambda (x y) + (when (not (buffer-name y)) + (remhash x org-babel-scheme-repl-map))) + org-babel-scheme-repl-map)) + +(defun org-babel-scheme-get-session-buffer (session-name) + "Look up the scheme buffer for a session; return nil if it doesn't exist." + (org-babel-scheme-cleanse-repl-map) ; Prune dead sessions + (gethash session-name org-babel-scheme-repl-map)) + +(defun org-babel-scheme-set-session-buffer (session-name buffer) + "Record the scheme buffer used for a given session." + (puthash session-name buffer org-babel-scheme-repl-map)) + +(defun org-babel-scheme-get-buffer-impl (buffer) + "Returns the scheme implementation geiser associates with the buffer." + (with-current-buffer (set-buffer buffer) +geiser-impl--implementation)) + +(defun org-babel-scheme-get-repl (impl name) + "Switch to a scheme REPL, creating it if it doesn't exist:" + (let ((buffer (org-babel-scheme-get-session-buffer name))) +(or buffer +(progn + (run-geiser impl) + (if name + (progn + (rename-buffer name t) + (org-babel-scheme-set-session-buffer name (current-buffer + (current-buffer) + +(defun org-babel-scheme-make-session-name (buffer name impl) + "Generate a name for the session buffer. + +For a named session, the buffer name will be the session name. + +If the session is unnamed (nil), generate a name. + +If the session is 'none', use nil for th