emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] a patch to ob-lisp.el


From: address@hidden
Subject: Re: [O] a patch to ob-lisp.el
Date: Wed, 6 Apr 2016 22:51:10 +0800

Oh, right. I should attach it.

```diff
From 30eec5a63e4f720fa3880b9aef06aedd84072078 Mon Sep 17 00:00:00 2001
From: stardiviner <address@hidden>
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.)
+;; Requires SLY (Sylvester the Cat's Common Lisp IDE) or SLIME.
+;; See:
 
 ;;; 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 <address@hidden> wrote:
Hello,

"address@hidden" <address@hidden> 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: 0001-add-SLY-support-in-ob-lisp.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]