emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] some lisp/slime progress
@ 2011-02-21  2:22 Erik Iverson
  2011-02-21  2:28 ` Erik Iverson
  2011-02-21 17:02 ` Eric Schulte
  0 siblings, 2 replies; 5+ messages in thread
From: Erik Iverson @ 2011-02-21  2:22 UTC (permalink / raw)
  To: Emacs-orgmode

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [babel] some lisp/slime progress
  2011-02-21  2:22 [babel] some lisp/slime progress Erik Iverson
@ 2011-02-21  2:28 ` Erik Iverson
  2011-03-31  6:14   ` [Orgmode] " Eric Schulte
  2011-02-21 17:02 ` Eric Schulte
  1 sibling, 1 reply; 5+ messages in thread
From: Erik Iverson @ 2011-02-21  2:28 UTC (permalink / raw)
  To: Emacs-orgmode


> 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

Er, not emacs-lisp, just lisp... like the following

#+begin_src lisp :session

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

#+end_src

#+results:
: test2 value

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [babel] some lisp/slime progress
  2011-02-21  2:22 [babel] some lisp/slime progress Erik Iverson
  2011-02-21  2:28 ` Erik Iverson
@ 2011-02-21 17:02 ` Eric Schulte
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2011-02-21 17:02 UTC (permalink / raw)
  To: Erik Iverson; +Cc: Emacs-orgmode

Erik Iverson <eriki@ccbr.umn.edu> writes:

> 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.
>

It looks like you've inserted an orgmode specific function into slime?
Maybe your slime patch could be changed to the introduction of a new
hook to which this org-mode specific function could be bound?  I imagine
the slime mailing list would know the best solution here.

>
> NB: this only works when :session is specified.
>

I think it is reasonable for the :session header argument to be added to
an `org-babel-default-header-args:lisp' variable defined in ob-lisp.
That would remove the need to constantly specify :session.  This is
similar to the ob-clojure approach, which by default always uses a slime
session.

>
> 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
>

Great, I look forward to playing with this as soon as I find some
time...

Thanks for sharing -- Eric

>
>
> Best Regards,
> --Erik Iverson

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Orgmode] [babel] some lisp/slime progress
  2011-02-21  2:28 ` Erik Iverson
@ 2011-03-31  6:14   ` Eric Schulte
  2011-03-31  6:37     ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2011-03-31  6:14 UTC (permalink / raw)
  To: Erik Iverson; +Cc: Emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]

Hi Erik,

I've had an opportunity to return to Babel support for common lisp
recently.  I just copied over the existing ob-clojure.el file to
ob-lisp.el and changed the clojure/swank specific parts.  The resulting
file seems to work after some initial tests and is exceedingly simple.

If this works for you as well, then I'd propose replacing the existing
ob-lisp.el with this new implementation.

Please let me know what you think.

Thanks -- Eric


[-- Attachment #2: ob-lisp.el --]
[-- Type: application/emacs-lisp, Size: 2456 bytes --]

[-- Attachment #3: Type: text/plain, Size: 717 bytes --]


Erik Iverson <eriki@ccbr.umn.edu> writes:

>> 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
>
> Er, not emacs-lisp, just lisp... like the following
>
> #+begin_src lisp :session
>
> (defvar test1 "test1 value")
> (defvar test2 "test2 value")
> test2
>
> #+end_src
>
> #+results:
> : test2 value
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Orgmode] [babel] some lisp/slime progress
  2011-03-31  6:14   ` [Orgmode] " Eric Schulte
@ 2011-03-31  6:37     ` Eric Schulte
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2011-03-31  6:37 UTC (permalink / raw)
  To: Erik Iverson; +Cc: Emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

This newly attached version includes some slight improvements over the
previous, namely,

- support for declaring the CL package in which evaluation takes place
- support for the ":results output" header argument
- and better handling of non-elisp-parsable results.

Best -- Eric


[-- Attachment #2: ob-lisp.el --]
[-- Type: application/emacs-lisp, Size: 2621 bytes --]

[-- Attachment #3: Type: text/plain, Size: 1279 bytes --]


"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi Erik,
>
> I've had an opportunity to return to Babel support for common lisp
> recently.  I just copied over the existing ob-clojure.el file to
> ob-lisp.el and changed the clojure/swank specific parts.  The resulting
> file seems to work after some initial tests and is exceedingly simple.
>
> If this works for you as well, then I'd propose replacing the existing
> ob-lisp.el with this new implementation.
>
> Please let me know what you think.
>
> Thanks -- Eric
>
>
>
> Erik Iverson <eriki@ccbr.umn.edu> writes:
>
>>> 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
>>
>> Er, not emacs-lisp, just lisp... like the following
>>
>> #+begin_src lisp :session
>>
>> (defvar test1 "test1 value")
>> (defvar test2 "test2 value")
>> test2
>>
>> #+end_src
>>
>> #+results:
>> : test2 value
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-31  6:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-21  2:22 [babel] some lisp/slime progress Erik Iverson
2011-02-21  2:28 ` Erik Iverson
2011-03-31  6:14   ` [Orgmode] " Eric Schulte
2011-03-31  6:37     ` Eric Schulte
2011-02-21 17:02 ` Eric Schulte

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).