branch: elpa/cider commit 9d1c3cd203eb298e3785779c924407e31bc7f5c7 Author: vemv <v...@users.noreply.github.com> Commit: Bozhidar Batsov <bozhi...@batsov.dev>
fix `cider-format-connection-params` edge case for Emacs 29 Fixes https://github.com/clojure-emacs/cider/issues/3402 --- CHANGELOG.md | 1 + cider-connection.el | 16 +++++++++++++++- test/cider-connection-tests.el | 26 ++++++++++++++++++++------ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c8cfcd4b..13241e7846 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - [#3331](https://github.com/clojure-emacs/cider/issues/3331): `cider-eval`: never jump to spurious locations, as sometimes conveyed by nREPL. - [#3112](https://github.com/clojure-emacs/cider/issues/3112): Fix the CIDER `xref-find-references` backend to return correct filenames. - [#3393](https://github.com/clojure-emacs/cider/issues/3393): recompute namespace info on each shadow-cljs recompilation or evaluation. +- [#3402](https://github.com/clojure-emacs/cider/issues/3402): fix `cider-format-connection-params` edge case for Emacs 29. - Fix the `xref-find-definitions` CIDER backend to return correct filenames. - Fix the `cider-xref-fn-deps` buttons to direct to the right file. diff --git a/cider-connection.el b/cider-connection.el index 9ada652292..765d915ced 100644 --- a/cider-connection.el +++ b/cider-connection.el @@ -720,6 +720,19 @@ Fallback on `cider' command." (plist-put :session-name ses-name) (plist-put :repl-buffer r))))))) +(defun cider--ensure-spec-is-not-invokable (spec) + "Ensures SPEC cannot be invoked as a function. + +Invokeable specs are an Emacs 29 feature +that we don't intend to use in this context." + (let ((spec-char (car spec)) + (spec-value (cdr spec))) + `(,spec-char + . + ,(if (symbolp spec-value) + (prin1-to-string spec-value) + spec-value)))) + (defun cider-format-connection-params (template params) "Format PARAMS with TEMPLATE string. The following formats can be used in TEMPLATE string: @@ -771,7 +784,8 @@ removed." (?S . ,cljs-repl-type))) (ses-name (or (plist-get params :session-name) (format-spec cider-session-name-template specs))) - (specs (append `((?s . ,ses-name)) specs))) + (specs (append `((?s . ,ses-name)) specs)) + (specs (mapcar #'cider--ensure-spec-is-not-invokable specs))) (thread-last (format-spec template specs) ;; remove extraneous separators diff --git a/test/cider-connection-tests.el b/test/cider-connection-tests.el index f30ce7e9bc..def21d5ebc 100644 --- a/test/cider-connection-tests.el +++ b/test/cider-connection-tests.el @@ -488,15 +488,20 @@ (expect (cider--compatible-middleware-version-p "1.25.3" "1.25.2-alpha2") :to-be t))) +(defun cider-connection-tests-dummy-function (a b c d) + "A B C D." + ;; See https://github.com/clojure-emacs/cider/issues/3402 + (error "I should never be invoked!")) + (describe "cider-format-connection-params" (it "Generates a pretty string. `:repl-type' can be symbol." ;; https://github.com/clojure-emacs/cider/issues/3402 (expect (cider-format-connection-params nrepl-repl-buffer-name-template nil) :to-equal "*cider-repl ~/project:localhost:(unknown)*") - (expect (cider-format-connection-params nrepl-repl-buffer-name-template '(:host "localhost" - :port 12345 - :project-dir "/Users/me/myproject" - :repl-type clj - :cljs-repl-type shadow)) + (expect (cider-format-connection-params nrepl-repl-buffer-name-template '(:host "localhost" + :port 12345 + :project-dir "/Users/me/myproject" + :repl-type clj + :cljs-repl-type shadow)) :to-equal "*cider-repl me/myproject:localhost:12345(clj)*") (expect (cider-format-connection-params nrepl-repl-buffer-name-template '(:host "localhost" @@ -504,4 +509,13 @@ :project-dir "/Users/me/myproject" :repl-type cljs :cljs-repl-type shadow)) - :to-equal "*cider-repl me/myproject:localhost:12345(cljs:shadow)*"))) + :to-equal "*cider-repl me/myproject:localhost:12345(cljs:shadow)*")) + + (it "Never invokes symbols as functions (Emacs 29 feature)" + (expect (functionp 'cider-connection-tests-dummy-function) + :to-equal t) + (expect (cider-format-connection-params nrepl-repl-buffer-name-template '(:host "localhost" + :port 12345 + :project-dir "/Users/me/myproject" + :repl-type cider-connection-tests-dummy-function)) + :to-equal "*cider-repl me/myproject:localhost:12345(cider-connection-tests-dummy-function)*")))