diff mbox series

[bug#57737,v5,4/6] gnu: Add emacs-eval-in-repl packages.

Message ID 20220923183437.18059-4-ngraves@ngraves.fr
State Accepted
Headers show
Series [bug#57737,v5,1/6] gnu: Add emacs-eval-in-repl. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Nicolas Graves Sept. 23, 2022, 6:34 p.m. UTC
* gnu/packages/emacs-xyz.scm
  (emacs-eval-in-repl-ielm): New variable.
  (emacs-eval-in-repl-cider): New variable.
  (emacs-eval-in-repl-slime): New variable.
  (emacs-eval-in-repl-sly): New variable.
  (emacs-eval-in-repl-geiser): New variable.
  (emacs-eval-in-repl-racket): New variable.
  (emacs-eval-in-repl-scheme): New variable.
  (emacs-eval-in-repl-hy): New variable.
  (emacs-eval-in-repl-python): New variable.
  (emacs-eval-in-repl-ruby): New variable.
  (emacs-eval-in-repl-sml): New variable.
  (emacs-eval-in-repl-ocaml): New variable.
  (emacs-eval-in-repl-prolog): New variable.
  (emacs-eval-in-repl-javascript): New variable.
  (emacs-eval-in-repl-shell): New variable.
  (emacs-eval-in-repl-iex): New variable.
  (emacs-eval-in-repl-erlang): New variable.
  (emacs-eval-in-repl-elm): New variable.
  (emacs-eval-in-repl-lua): New variable.
---
 gnu/packages/emacs-xyz.scm | 86 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index ac35e57773..9db49cd8a7 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -140,6 +140,7 @@  (define-module (gnu packages emacs-xyz)
   #:use-module (guix download)
   #:use-module (guix bzr-download)
   #:use-module (guix gexp)
+  #:use-module (guix i18n)
   #:use-module (guix git-download)
   #:use-module (guix hg-download)
   #:use-module (guix build-system gnu)
@@ -240,6 +241,8 @@  (define-module (gnu packages emacs-xyz)
   #:use-module (gnu packages photo)
   #:use-module (gnu packages uml)
   #:use-module (gnu packages finance)
+  #:use-module (gnu packages ocaml)
+  #:use-module (gnu packages erlang)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match))
@@ -27152,6 +27155,89 @@  (define-public emacs-eval-in-repl
 @end itemize")
     (license license:expat)))
 
+(define (repl->lang s)
+    (cond
+     ((string= s "ielm")   "Emacs Lisp")
+     ((string= s "cider")  "Clojure")
+     ((string= s "slime")  "Common Lisp")
+     ((string= s "sly")    "Common Lisp")
+     ((string= s "geiser") "Racket/Scheme")
+     ((string= s "sml")    "Standard ML")
+     ((string= s "iex")    "Elixir")
+     ((string= s "ocaml")  "OCaml")
+     (else (string-capitalize s))))
+
+(define (repl->inputs s)
+    (cond
+     ((string= s "cider")      '("emacs-cider"))
+     ((string= s "slime")      '("emacs-slime"))
+     ((string= s "sly")        '("emacs-sly"))
+     ((string= s "geiser")     '("emacs-geiser"))
+     ((string= s "racket")     '("emacs-racket-mode"))
+     ((string= s "hy")         '("emacs-hy-mode"))
+     ((string= s "ruby")       '("emacs-inf-ruby"))
+     ((string= s "sml")        '("emacs-sml-mode"))
+     ((string= s "ocaml")      '("emacs-tuareg"))
+     ((string= s "javascript") '("emacs-js2-mode" "emacs-js-comint"))
+     ((string= s "iex")        '("emacs-elixir-mode" "emacs-alchemist"))
+     ((string= s "erlang")     '("emacs-erlang"))
+     ((string= s "elm")        '("emacs-elm-mode"))
+     ((string= s "lua")        '("emacs-lua-mode"))
+     (else '())))
+
+(define (make-emacs-eval-in-repl repl)
+  (let* ((lang (repl->lang repl))
+         (inputs (repl->inputs repl)))
+    (package
+      (name (string-append "emacs-eval-in-repl-" repl))
+      (version "0.9.7")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/kaz-yos/eval-in-repl")
+               (commit (string-append "v" version))))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1mrssbl0wyc6iij8zk1y3h9bd3rv53nnrxsij7fn67l1m4z0clyn"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:include (list ,(string-append "eval-in-repl-" repl "\\.el"))))
+      (propagated-inputs (append (list emacs-eval-in-repl)
+                                 (map specification->package+output inputs)))
+      (home-page "https://github.com/kaz-yos/eval-in-repl")
+      (synopsis "Consistent evaluation interface for Emacs Lisp REPLs for emacs")
+      (description (G_ (string-append "\
+This package provides a consistent ESS-like evaluation interface for
+" lang " REPLs.  Emacs Speaks Statistics (ESS) package has a nice function
+called @code{ess-eval-region-or-line-and-step}, which is assigned to
+C-RET.  This function sends a line or a selected region to the corresponding
+shell (R, Julia, Stata, etc) visibly.  It also start up a shell if there is
+none.")))
+      (license license:expat))))
+
+(define-public emacs-eval-in-repl-ielm   (make-emacs-eval-in-repl "ielm"))
+(define-public emacs-eval-in-repl-cider  (make-emacs-eval-in-repl "cider"))
+(define-public emacs-eval-in-repl-slime  (make-emacs-eval-in-repl "slime"))
+(define-public emacs-eval-in-repl-sly    (make-emacs-eval-in-repl "sly"))
+(define-public emacs-eval-in-repl-geiser (make-emacs-eval-in-repl "geiser"))
+(define-public emacs-eval-in-repl-racket (make-emacs-eval-in-repl "racket"))
+(define-public emacs-eval-in-repl-scheme (make-emacs-eval-in-repl "scheme"))
+(define-public emacs-eval-in-repl-hy     (make-emacs-eval-in-repl "hy"))
+(define-public emacs-eval-in-repl-python (make-emacs-eval-in-repl "python"))
+(define-public emacs-eval-in-repl-ruby   (make-emacs-eval-in-repl "ruby"))
+(define-public emacs-eval-in-repl-sml    (make-emacs-eval-in-repl "sml"))
+(define-public emacs-eval-in-repl-ocaml  (make-emacs-eval-in-repl "ocaml"))
+(define-public emacs-eval-in-repl-prolog (make-emacs-eval-in-repl "prolog"))
+(define-public emacs-eval-in-repl-shell  (make-emacs-eval-in-repl "shell"))
+(define-public emacs-eval-in-repl-iex    (make-emacs-eval-in-repl "iex"))
+(define-public emacs-eval-in-repl-erlang (make-emacs-eval-in-repl "erlang"))
+(define-public emacs-eval-in-repl-elm    (make-emacs-eval-in-repl "elm"))
+(define-public emacs-eval-in-repl-lua    (make-emacs-eval-in-repl "lua"))
+(define-public emacs-eval-in-repl-javascript
+  (make-emacs-eval-in-repl "javascript"))
+
+
 (define-public emacs-eval-sexp-fu-el
   (package
     (name "emacs-eval-sexp-fu-el")