branch: elpa/inf-clojure
commit d7e391da741aaacaf97a60328b28640de4f42f34
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Unify arglists forms across JVM Clojure-family REPLs
    
    The arglists forms for clojure, babashka, and node-babashka were
    functionally identical (resolve + meta + :arglists) but written
    differently. Move the common form into the base features and use
    copy-alist for types that need no overrides.
    
    The clojure type's reader conditional #?(:clj Throwable :cljr
    Exception) is unnecessary since lein-clr already exists for CLR.
    Only lein-clr overrides arglists now (catching Exception).
---
 inf-clojure.el            | 32 ++++++--------------------------
 test/inf-clojure-tests.el | 10 ++++++----
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/inf-clojure.el b/inf-clojure.el
index c0d20a5d15..3f833970a1 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -94,13 +94,14 @@ Keys in OVERRIDES take precedence over those in BASE."
   '((load . "(clojure.core/load-file \"%s\")")
     (doc . "(clojure.repl/doc %s)")
     (source . "(clojure.repl/source %s)")
+    (arglists . "(try (-> '%s clojure.core/resolve clojure.core/meta 
:arglists) (catch Throwable e nil))")
     (apropos . "(doseq [var (sort (clojure.repl/apropos \"%s\"))] (println 
(str var)))")
     (ns-vars . "(clojure.repl/dir %s)")
     (set-ns . "(clojure.core/in-ns '%s)")
     (macroexpand . "(clojure.core/macroexpand '%s)")
     (macroexpand-1 . "(clojure.core/macroexpand-1 '%s)"))
   "Base feature forms shared by Clojure-family REPLs.
-Individual REPL types override specific entries (typically `arglists')
+Individual REPL types override specific entries (e.g. `arglists')
 via `inf-clojure--merge-repl-features'.")
 
 (defvar inf-clojure-repl-features
@@ -134,34 +135,13 @@ via `inf-clojure--merge-repl-features'.")
               (set-ns . "(in-ns '%s)")
               (macroexpand . "(macroexpand '%s)")
               (macroexpand-1 . "(macroexpand-1 '%s)")))
-    (babashka . ,(inf-clojure--merge-repl-features
-                  inf-clojure--clojure-repl-base-features
-                  '((arglists .
-                              "(try (-> '%s clojure.core/resolve 
clojure.core/meta :arglists)
-                              (catch Throwable e nil))"))))
-    (node-babashka . ,(inf-clojure--merge-repl-features
-                       inf-clojure--clojure-repl-base-features
-                       '((arglists .
-                                   "(try (-> '%s clojure.core/resolve 
clojure.core/meta :arglists)
-                              (catch Throwable e nil))"))))
-    (clojure . ,(inf-clojure--merge-repl-features
-                 inf-clojure--clojure-repl-base-features
-                 '((arglists .
-                             "(try
-                             (:arglists
-                              (clojure.core/meta
-                               (clojure.core/resolve
-                                (clojure.core/read-string \"%s\"))))
-                            (catch #?(:clj Throwable :cljr Exception) e 
nil))"))))
+    (babashka . ,(copy-alist inf-clojure--clojure-repl-base-features))
+    (node-babashka . ,(copy-alist inf-clojure--clojure-repl-base-features))
+    (clojure . ,(copy-alist inf-clojure--clojure-repl-base-features))
     (lein-clr . ,(inf-clojure--merge-repl-features
                   inf-clojure--clojure-repl-base-features
                   '((arglists .
-                              "(try
-                             (:arglists
-                              (clojure.core/meta
-                               (clojure.core/resolve
-                                (clojure.core/read-string \"%s\"))))
-                             (catch Exception e nil))"))))))
+                              "(try (-> '%s clojure.core/resolve 
clojure.core/meta :arglists) (catch Exception e nil))"))))))
 
 (defvar-local inf-clojure-repl-type nil
   "Symbol to define your REPL type.
diff --git a/test/inf-clojure-tests.el b/test/inf-clojure-tests.el
index c1327a0b03..bc1951e42d 100644
--- a/test/inf-clojure-tests.el
+++ b/test/inf-clojure-tests.el
@@ -181,12 +181,14 @@ is a string\")
     (let ((bb-features (alist-get 'babashka inf-clojure-repl-features))
           (nbb-features (alist-get 'node-babashka inf-clojure-repl-features)))
       (expect bb-features :to-equal nbb-features)))
-  (it "differentiates arglists across clojure-family REPL types"
+  (it "shares arglists across JVM REPL types"
+    (let ((clj-arglists (inf-clojure--get-feature 'clojure 'arglists nil))
+          (bb-arglists (inf-clojure--get-feature 'babashka 'arglists nil)))
+      (expect clj-arglists :to-equal bb-arglists)))
+  (it "uses a different arglists catch clause for lein-clr"
     (let ((clj-arglists (inf-clojure--get-feature 'clojure 'arglists nil))
-          (bb-arglists (inf-clojure--get-feature 'babashka 'arglists nil))
           (clr-arglists (inf-clojure--get-feature 'lein-clr 'arglists nil)))
-      (expect clj-arglists :not :to-equal bb-arglists)
       (expect clj-arglists :not :to-equal clr-arglists)
-      (expect bb-arglists :not :to-equal clr-arglists))))
+      (expect clr-arglists :to-match "Exception"))))
 
 ;;; inf-clojure-tests.el ends here

Reply via email to