emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-lisp.el patch to choose to use SLIME or SLY
@ 2016-03-27  1:57 numbchild
  2016-04-06  9:33 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: numbchild @ 2016-03-27  1:57 UTC (permalink / raw)
  To: Org-mode


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

I original created an package ob-lisp on here:
https://github.com/stardiviner/ob-lisp
and add it to MELPA recipe.
https://github.com/melpa/melpa/pull/3682

The author suggest me to merge this change to Org-mode.

I attached patch in attachment file.
Hope someone can merge this patch.

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

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

[-- Attachment #2: ob-lisp.patch --]
[-- Type: text/x-patch, Size: 5572 bytes --]

diff --git a/ob-lisp.el b/ob-lisp.el
index d2cac3d..04df7fb 100644
--- a/ob-lisp.el
+++ b/ob-lisp.el
@@ -1,14 +1,12 @@
-;;; ob-lisp.el --- org-babel functions for common lisp evaluation with SLY or SLIME.
+;;; ob-lisp.el --- org-babel functions for common lisp evaluation
 
-;; Copyright (C) 2016-2020 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
-;; Authors: stardiviner <numbchild@gmail.com>
-;; Maintainer: stardiviner <numbchild@gmail.com>
-;; Keywords: org babel lisp sly slime
-;; URL: https://github.com/stardiviner/ob-lisp
-;; Created: 1th March 2016
-;; Version: 0.0.1
-;; Package-Requires: ((org "8"))
+;; Authors: Joel Boehland
+;;	 Eric Schulte
+;;	 David T. O'Toole <dto@gnu.org>
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
 
 ;; This file is part of GNU Emacs.
 
@@ -27,27 +25,17 @@
 
 ;;; Commentary:
 
-;;; Support for evaluating Common Lisp code, relies on SLY or SLIME for all eval.
+;;; support for evaluating common lisp code, relies on slime for all eval
 
 ;;; Requirements:
 
-;; Requires SLY (Sylvester the Cat's Common Lisp IDE) and SLIME
-;; See:
-;; - https://github.com/capitaomorte/sly
-;; - http://common-lisp.net/project/slime/
+;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.)
+;; See 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)
 (add-to-list 'org-babel-tangle-lang-exts '("lisp" . "lisp"))
@@ -67,54 +55,50 @@ current directory string."
 (defun org-babel-expand-body:lisp (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
-         (result-params (cdr (assoc :result-params params)))
-         (print-level nil) (print-length nil)
-         (body (org-babel-trim
-                (if (> (length vars) 0)
-                    (concat "(let ("
-                            (mapconcat
-                             (lambda (var)
-                               (format "(%S (quote %S))" (car var) (cdr var)))
-                             vars "\n      ")
-                            ")\n" body ")")
-                  body))))
+	 (result-params (cdr (assoc :result-params params)))
+	 (print-level nil) (print-length nil)
+	 (body (org-babel-trim
+		(if (> (length vars) 0)
+		    (concat "(let ("
+			    (mapconcat
+			     (lambda (var)
+			       (format "(%S (quote %S))" (car var) (cdr var)))
+			     vars "\n      ")
+			    ")\n" body ")")
+		  body))))
     (if (or (member "code" result-params)
-            (member "pp" result-params))
-        (format "(pprint %s)" body)
+	    (member "pp" result-params))
+	(format "(pprint %s)" body)
       body)))
 
-;;;###autoload
 (defun org-babel-execute:lisp (body params)
-  "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)))
+  "Execute a block of Common Lisp code with Babel."
+  (require 'slime)
   (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))
-                     (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)))))))
+	  (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)))))))
      (org-babel-result-cond (cdr (assoc :result-params params))
        result
        (condition-case nil
            (read (org-babel-lisp-vector-to-list result))
          (error result))))
    (org-babel-pick-name (cdr (assoc :colname-names params))
-                        (cdr (assoc :colnames params)))
+			(cdr (assoc :colnames params)))
    (org-babel-pick-name (cdr (assoc :rowname-names params))
-                        (cdr (assoc :rownames params)))))
+			(cdr (assoc :rownames params)))))
 
 (defun org-babel-lisp-vector-to-list (results)
   ;; TODO: better would be to replace #(...) with [...]

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

end of thread, other threads:[~2016-04-06  9:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-27  1:57 ob-lisp.el patch to choose to use SLIME or SLY numbchild
2016-04-06  9:33 ` Nicolas Goaziou

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