From dcebfde3bc49e6e6b0c71d785c9604c0e7567042 Mon Sep 17 00:00:00 2001 From: vemv Date: Sat, 22 Jul 2023 12:28:42 +0200 Subject: [PATCH 1/4] Preserve :cljs-repl-type when specified --- CHANGELOG.md | 1 + cider-connection.el | 4 +++- cider.el | 15 +++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d75aee4bd..09bc6b291 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Bump the injected `cider-nrepl` to [0.32](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md). - Improve `nrepl-dict` error reporting. +- Preserve the `:cljs-repl-type` more reliably. ## 1.7.0 (2023-03-23) diff --git a/cider-connection.el b/cider-connection.el index 35fc79271..f74e1d31e 100644 --- a/cider-connection.el +++ b/cider-connection.el @@ -788,7 +788,7 @@ Session name can be customized with `cider-session-name-template'." ;;; REPL Buffer Init (defvar-local cider-cljs-repl-type nil - "The type of the ClojureScript runtime (Browser, Node, Figwheel, etc.).") + "The type of the ClojureScript runtime ('browser, 'node, 'figwheel, etc.).") (defvar-local cider-repl-type nil "The type of this REPL buffer, usually either clj or cljs.") @@ -919,6 +919,8 @@ function with the repl buffer set as current." ;; ran at the end of cider--connected-handler cider-repl-init-function (plist-get params :repl-init-function) cider-launch-params params) + (when-let ((type (plist-get params :cljs-repl-type))) + (setq cider-cljs-repl-type type)) (cider-repl-reset-markers) (add-hook 'nrepl-response-handler-functions #'cider-repl--state-handler nil 'local) (add-hook 'nrepl-connected-hook #'cider--connected-handler nil 'local) diff --git a/cider.el b/cider.el index adfa7545c..f99cf8caf 100644 --- a/cider.el +++ b/cider.el @@ -1293,7 +1293,7 @@ double prefix prompt for all these parameters." (defun cider-jack-in-cljs (params) "Start an nREPL server for the current project and connect to it. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument, +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). With the prefix argument, allow editing of the jack in command; with a double prefix prompt for all these parameters." (interactive "P") @@ -1318,7 +1318,7 @@ these parameters." (defun cider-jack-in-clj&cljs (&optional params soft-cljs-start) "Start an nREPL server and connect with clj and cljs REPLs. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument, +:cljs-repl-type (e.g. 'shadow, 'node, 'fighweel, etc). With the prefix argument, allow for editing of the jack in command; with a double prefix prompt for all these parameters. When SOFT-CLJS-START is non-nil, start cljs REPL only when the ClojureScript dependencies are met." @@ -1371,13 +1371,14 @@ server is created." ;;;###autoload (defun cider-connect-sibling-cljs (params &optional other-repl) "Create a ClojureScript REPL with the same server as OTHER-REPL. -PARAMS is a plist optionally containing :cljs-repl-type (e.g. Node, -Figwheel, etc). All other parameters are inferred from the OTHER-REPL. +PARAMS is a plist optionally containing :cljs-repl-type (e.g. 'node, +'figwheel, 'shadow, etc). All other parameters are inferred from the OTHER-REPL. OTHER-REPL defaults to `cider-current-repl' but in programs can also be a server buffer, in which case a new session for that server is created." (interactive "P") (let* ((other-repl (or other-repl (cider-current-repl 'any 'ensure))) (other-params (cider--gather-connect-params nil other-repl)) + (other-params (thread-first other-params (map-delete :repl-type) (map-delete :cljs-repl-type))) (ses-name (unless (nrepl-server-p other-repl) (sesman-session-name-for-object 'CIDER other-repl)))) (cider-nrepl-connect @@ -1410,7 +1411,9 @@ prefix argument, prompt for all the parameters." (defun cider-connect-cljs (&optional params) "Initialize a ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and -:cljs-repl-type (e.g. Node, Figwheel, etc). On prefix, prompt for all the +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). + +On prefix, prompt for all the parameters regardless of their supplied or default values." (interactive "P") (cider-nrepl-connect @@ -1428,7 +1431,7 @@ parameters regardless of their supplied or default values." (defun cider-connect-clj&cljs (params &optional soft-cljs-start) "Initialize a Clojure and ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and -:cljs-repl-type (e.g. Node, Figwheel, etc). When SOFT-CLJS-START is +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). When SOFT-CLJS-START is non-nil, don't start if ClojureScript requirements are not met." (interactive "P") (let* ((params (thread-first From 9411aa98aaccbf8d3e6ed48bb34b33d1f13df200 Mon Sep 17 00:00:00 2001 From: vemv Date: Sat, 22 Jul 2023 12:39:48 +0200 Subject: [PATCH 2/4] Linter --- cider.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cider.el b/cider.el index f99cf8caf..677084908 100644 --- a/cider.el +++ b/cider.el @@ -1293,7 +1293,9 @@ double prefix prompt for all these parameters." (defun cider-jack-in-cljs (params) "Start an nREPL server for the current project and connect to it. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). With the prefix argument, +:cljs-repl-type (e.g. 'shadow, 'node, 'figwheel, etc). + +With the prefix argument, allow editing of the jack in command; with a double prefix prompt for all these parameters." (interactive "P") @@ -1318,9 +1320,12 @@ these parameters." (defun cider-jack-in-clj&cljs (&optional params soft-cljs-start) "Start an nREPL server and connect with clj and cljs REPLs. PARAMS is a plist optionally containing :project-dir, :jack-in-cmd and -:cljs-repl-type (e.g. 'shadow, 'node, 'fighweel, etc). With the prefix argument, -allow for editing of the jack in command; with a double prefix prompt for -all these parameters. When SOFT-CLJS-START is non-nil, start cljs REPL +:cljs-repl-type (e.g. 'shadow, 'node, 'fighweel, etc). + +With the prefix argument, allow for editing of the jack in command; +with a double prefix prompt for all these parameters. + +When SOFT-CLJS-START is non-nil, start cljs REPL only when the ClojureScript dependencies are met." (interactive "P") (let ((cider-jack-in-dependencies (append cider-jack-in-dependencies cider-jack-in-cljs-dependencies)) @@ -1372,7 +1377,9 @@ server is created." (defun cider-connect-sibling-cljs (params &optional other-repl) "Create a ClojureScript REPL with the same server as OTHER-REPL. PARAMS is a plist optionally containing :cljs-repl-type (e.g. 'node, -'figwheel, 'shadow, etc). All other parameters are inferred from the OTHER-REPL. +'figwheel, 'shadow, etc). + +All other parameters are inferred from the OTHER-REPL. OTHER-REPL defaults to `cider-current-repl' but in programs can also be a server buffer, in which case a new session for that server is created." (interactive "P") From 04dbe2e4925420cf7ffc02f98b18ca5f395f778b Mon Sep 17 00:00:00 2001 From: vemv Date: Sat, 22 Jul 2023 20:26:05 +0200 Subject: [PATCH 3/4] Remove now-duplicated code --- cider.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/cider.el b/cider.el index 677084908..792a26179 100644 --- a/cider.el +++ b/cider.el @@ -1640,8 +1640,6 @@ over to cljs. (plist-put :repl-init-function (lambda () (cider--check-cljs cljs-type) - ;; FIXME: ideally this should be done in the state handler - (setq-local cider-cljs-repl-type cljs-type) (cider-nrepl-send-request (list "op" "eval" "ns" (cider-current-ns) From d9496718aacec4ebbc31c1794d5c2d0ea0a869fb Mon Sep 17 00:00:00 2001 From: vemv Date: Sat, 22 Jul 2023 20:29:47 +0200 Subject: [PATCH 4/4] Add comment --- cider.el | 1 + 1 file changed, 1 insertion(+) diff --git a/cider.el b/cider.el index 792a26179..40150b33f 100644 --- a/cider.el +++ b/cider.el @@ -1385,6 +1385,7 @@ server buffer, in which case a new session for that server is created." (interactive "P") (let* ((other-repl (or other-repl (cider-current-repl 'any 'ensure))) (other-params (cider--gather-connect-params nil other-repl)) + ;; type-related params from the JVM conn are undesired for a cljs conn: (other-params (thread-first other-params (map-delete :repl-type) (map-delete :cljs-repl-type))) (ses-name (unless (nrepl-server-p other-repl) (sesman-session-name-for-object 'CIDER other-repl))))