emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "numbchild@gmail.com" <numbchild@gmail.com>
To: "numbchild@gmail.com" <numbchild@gmail.com>,
	"Thomas S. Dye" <tsd@tsdye.com>, Nick Dokos <ndokos@gmail.com>,
	Org-mode <emacs-orgmode@gnu.org>
Subject: Re: a patch to ob-lisp.el
Date: Wed, 6 Apr 2016 22:51:10 +0800	[thread overview]
Message-ID: <CAL1eYuJoE-5sF=OA-zZVH14VDqze3wdVCO7d=q3m+-hE77ptiQ@mail.gmail.com> (raw)
In-Reply-To: <874mbedhro.fsf@nicolasgoaziou.fr>


[-- Attachment #1.1: Type: text/plain, Size: 5041 bytes --]

Oh, right. I should attach it.

```diff
From 30eec5a63e4f720fa3880b9aef06aedd84072078 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sat, 2 Apr 2016 00:46:36 +0800
Subject: [PATCH] add SLY support in ob-lisp

* ob-lisp.el (org-babel-execute:lisp): Support using SLY to evaluate
  lisp src block.

SLY has some advantages over SLIME, let user can evaluate Lisp src block
with SLY.

modified from a patch proposal by stardiviner.

TINYCHANGE
---
 etc/ORG-NEWS    |  2 ++
 lisp/ob-lisp.el | 51 ++++++++++++++++++++++++++++++++-------------------
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 3ddc3f9..bb8a00d 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -819,6 +819,8 @@ See the docstring of ~org-latex-classes~ and

 *** `org-insert-heading' can be forced to insert top-level headline

+*** let ob-lisp supporting use SLY to evaluate
+
 ** Removed functions

 *** Removed function ~org-translate-time~
diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
index 64b032d..68ea5e2 100644
--- a/lisp/ob-lisp.el
+++ b/lisp/ob-lisp.el
@@ -25,16 +25,26 @@

 ;;; Commentary:

-;;; support for evaluating common lisp code, relies on slime for all eval
+;;; Support for evaluating Common Lisp code, relies on SLY or SLIME for
all eval.

 ;;; Requirements:

-;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.)
-;; See http://common-lisp.net/project/slime/
+;; Requires SLY (Sylvester the Cat's Common Lisp IDE) or SLIME.
+;; See:
+;; - https://github.com/capitaomorte/sly
+;; - http://common-lisp.net/project/slime/

 ;;; Code:
 (require 'ob)

+(defcustom org-babel-lisp-eval-fn "sly-eval"
+  "The function to be called to evaluate code on the Lisp side."
+  :group 'org-babel
+  :version "24.1"
+  :options '("sly-eval" "slime-eval")
+  :type 'stringp)
+
+(declare-function sly-eval "ext:sly" (sexp &optional package))
 (declare-function slime-eval "ext:slime" (sexp &optional package))

 (defvar org-babel-tangle-lang-exts)
@@ -72,24 +82,27 @@ current directory string."
       body)))

 (defun org-babel-execute:lisp (body params)
-  "Execute a block of Common Lisp code with Babel."
-  (require 'slime)
+  "Execute a block `BODY' with `PARAMS' of Common Lisp code with Babel."
+  (pcase org-babel-lisp-eval-fn
+    ("slime-eval" (require 'slime))
+    ("sly-eval" (require 'sly)))
   (org-babel-reassemble-table
    (let ((result
-  (funcall (if (member "output" (cdr (assoc :result-params params)))
-       #'car #'cadr)
-   (with-temp-buffer
-     (insert (org-babel-expand-body:lisp body params))
-     (slime-eval `(swank:eval-and-grab-output
-   ,(let ((dir (if (assoc :dir params)
-   (cdr (assoc :dir params))
- default-directory)))
-      (format
-       (if dir (format org-babel-lisp-dir-fmt dir)
- "(progn %s\n)")
-       (buffer-substring-no-properties
- (point-min) (point-max)))))
- (cdr (assoc :package params)))))))
+          (funcall (if (member "output" (cdr (assoc :result-params
params)))
+                       #'car #'cadr)
+                   (with-temp-buffer
+                     (insert (org-babel-expand-body:lisp body params))
+                     (funcall org-babel-lisp-eval-fn
+                              `(swank:eval-and-grab-output
+                                ,(let ((dir (if (assoc :dir params)
+                                                (cdr (assoc :dir params))
+                                              default-directory)))
+                                   (format
+                                    (if dir (format org-babel-lisp-dir-fmt
dir)
+                                      "(progn %s\n)")
+                                    (buffer-substring-no-properties
+                                     (point-min) (point-max)))))
+                              (cdr (assoc :package params)))))))
      (org-babel-result-cond (cdr (assoc :result-params params))
        result
        (condition-case nil
-- 
2.8.0
```

[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/

On Wed, Apr 6, 2016 at 8:49 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> "numbchild@gmail.com" <numbchild@gmail.com> writes:
>
> > Hi, Nicolas, the another email which you commented many places is
> outdated.
> > That patch is modified from the version of MELPA package
> `org-plus-conrtib`.
> >
> > I cloned org-mode git repo, and created public repo branch at here:
> > https://github.com/stardiviner/org-mode/tree/sly-support-for-ob-lisp
> >
> > I checked this branch's diff with your mentioned places. All checked.
> > I followed org-mode contrib guide to create this commit.
> > Please let me know if there is any place need to modify.
>
> From your local branch, use
>
>   git format-patch master
>
> This will generate a patch file, which you can send to this ML.
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #1.2: Type: text/html, Size: 16430 bytes --]

[-- Attachment #2: 0001-add-SLY-support-in-ob-lisp.patch --]
[-- Type: text/x-patch, Size: 3982 bytes --]

From 30eec5a63e4f720fa3880b9aef06aedd84072078 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sat, 2 Apr 2016 00:46:36 +0800
Subject: [PATCH] add SLY support in ob-lisp

* ob-lisp.el (org-babel-execute:lisp): Support using SLY to evaluate
  lisp src block.

SLY has some advantages over SLIME, let user can evaluate Lisp src block
with SLY.

modified from a patch proposal by stardiviner.

TINYCHANGE
---
 etc/ORG-NEWS    |  2 ++
 lisp/ob-lisp.el | 51 ++++++++++++++++++++++++++++++++-------------------
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 3ddc3f9..bb8a00d 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -819,6 +819,8 @@ See the docstring of ~org-latex-classes~ and
 
 *** `org-insert-heading' can be forced to insert top-level headline
 
+*** let ob-lisp supporting use SLY to evaluate
+
 ** Removed functions
 
 *** Removed function ~org-translate-time~
diff --git a/lisp/ob-lisp.el b/lisp/ob-lisp.el
index 64b032d..68ea5e2 100644
--- a/lisp/ob-lisp.el
+++ b/lisp/ob-lisp.el
@@ -25,16 +25,26 @@
 
 ;;; Commentary:
 
-;;; support for evaluating common lisp code, relies on slime for all eval
+;;; Support for evaluating Common Lisp code, relies on SLY or SLIME for all eval.
 
 ;;; Requirements:
 
-;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.)
-;; See http://common-lisp.net/project/slime/
+;; Requires SLY (Sylvester the Cat's Common Lisp IDE) or SLIME.
+;; See:
+;; - https://github.com/capitaomorte/sly
+;; - http://common-lisp.net/project/slime/
 
 ;;; Code:
 (require 'ob)
 
+(defcustom org-babel-lisp-eval-fn "sly-eval"
+  "The function to be called to evaluate code on the Lisp side."
+  :group 'org-babel
+  :version "24.1"
+  :options '("sly-eval" "slime-eval")
+  :type 'stringp)
+
+(declare-function sly-eval "ext:sly" (sexp &optional package))
 (declare-function slime-eval "ext:slime" (sexp &optional package))
 
 (defvar org-babel-tangle-lang-exts)
@@ -72,24 +82,27 @@ current directory string."
       body)))
 
 (defun org-babel-execute:lisp (body params)
-  "Execute a block of Common Lisp code with Babel."
-  (require 'slime)
+  "Execute a block `BODY' with `PARAMS' of Common Lisp code with Babel."
+  (pcase org-babel-lisp-eval-fn
+    ("slime-eval" (require 'slime))
+    ("sly-eval" (require 'sly)))
   (org-babel-reassemble-table
    (let ((result
-	  (funcall (if (member "output" (cdr (assoc :result-params params)))
-		       #'car #'cadr)
-		   (with-temp-buffer
-		     (insert (org-babel-expand-body:lisp body params))
-		     (slime-eval `(swank:eval-and-grab-output
-				   ,(let ((dir (if (assoc :dir params)
-						   (cdr (assoc :dir params))
-						 default-directory)))
-				      (format
-				       (if dir (format org-babel-lisp-dir-fmt dir)
-					 "(progn %s\n)")
-				       (buffer-substring-no-properties
-					(point-min) (point-max)))))
-				 (cdr (assoc :package params)))))))
+          (funcall (if (member "output" (cdr (assoc :result-params params)))
+                       #'car #'cadr)
+                   (with-temp-buffer
+                     (insert (org-babel-expand-body:lisp body params))
+                     (funcall org-babel-lisp-eval-fn
+                              `(swank:eval-and-grab-output
+                                ,(let ((dir (if (assoc :dir params)
+                                                (cdr (assoc :dir params))
+                                              default-directory)))
+                                   (format
+                                    (if dir (format org-babel-lisp-dir-fmt dir)
+                                      "(progn %s\n)")
+                                    (buffer-substring-no-properties
+                                     (point-min) (point-max)))))
+                              (cdr (assoc :package params)))))))
      (org-babel-result-cond (cdr (assoc :result-params params))
        result
        (condition-case nil
-- 
2.8.0


  reply	other threads:[~2016-04-06 14:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-26 16:02 a patch to ob-lisp.el stardiviner
2016-03-28  4:01 ` Nick Dokos
2016-03-30 15:30   ` numbchild
2016-03-30 16:52     ` Thomas S. Dye
2016-04-06  5:54       ` numbchild
2016-04-06  5:55         ` numbchild
2016-04-06  9:26           ` Nicolas Goaziou
2016-04-06 10:51             ` numbchild
2016-04-06 12:49               ` Nicolas Goaziou
2016-04-06 14:51                 ` numbchild [this message]
2016-04-10  8:12                   ` Nicolas Goaziou
2016-04-06  9:24         ` Nicolas Goaziou

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='CAL1eYuJoE-5sF=OA-zZVH14VDqze3wdVCO7d=q3m+-hE77ptiQ@mail.gmail.com' \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@gmail.com \
    --cc=tsd@tsdye.com \
    /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).