emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Erik Iverson <eriki@ccbr.umn.edu>
To: Emacs-orgmode@gnu.org
Subject: [babel] some lisp/slime progress
Date: Sun, 20 Feb 2011 20:22:54 -0600	[thread overview]
Message-ID: <4D61CC7E.7030109@ccbr.umn.edu> (raw)

Hello,

I recently posted on the inability of ob-lisp.el to
submit multiple forms to a running CL session and return
the result.

http://permalink.gmane.org/gmane.emacs.orgmode/37325

I have made some progress in fixing this, but it *required
defining a new function in SLIME, so I do not post this
as a patch to org-mode, since it depends on more than
org-mode*.  I don't know if this is something that truly
belongs in SLIME, so I may follow-up on that mailing list.

NB: this only works when :session is specified.

In SLIME swank.lisp, I define:

(defslimefun interactive-eval-region-orgmode (string)
   (with-buffer-syntax ()
     (with-retry-restart (:msg "Retry SLIME interactive evaluation request.")
       (list (format nil "~{~S~^~%~}" (eval-region string))))))


Then, in ob-lisp.el, apply the following patch.

diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
index 600b79e..2980cc8 100644
--- a/lisp/ob-lisp.el
+++ b/lisp/ob-lisp.el
@@ -78,7 +78,11 @@ This function is called by `org-babel-execute-src-block'"
       (if session
           ;; session evaluation
           (save-window-excursion
-           (cadr (slime-eval `(swank:eval-and-grab-output ,full-body))))
+	   (with-temp-buffer
+	     (insert full-body)
+	     (slime-eval
+	      `(swank:interactive-eval-region-orgmode
+	   	,(buffer-substring-no-properties (point-min) (point-max))))))
         ;; external evaluation
         (let ((script-file (org-babel-temp-file "lisp-script-")))
           (with-temp-file script-file

Then, things like the following work, where I assume you've already
started M-x slime.

#+begin_src emacs-lisp :session

(defvar test1 "test1 value")
(defvar test2 "test2 value")
test2

#+end_src

#+results:
: test2 value


Best Regards,
--Erik Iverson

             reply	other threads:[~2011-02-21  2:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-21  2:22 Erik Iverson [this message]
2011-02-21  2:28 ` [babel] some lisp/slime progress Erik Iverson
2011-03-31  6:14   ` [Orgmode] " Eric Schulte
2011-03-31  6:37     ` Eric Schulte
2011-02-21 17:02 ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D61CC7E.7030109@ccbr.umn.edu \
    --to=eriki@ccbr.umn.edu \
    --cc=Emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).