From 33480e97bc2a91d170d03893e097d40fdb03c1d4 Mon Sep 17 00:00:00 2001 From: vemv Date: Sat, 12 Aug 2023 19:56:28 +0200 Subject: [PATCH 1/2] Bump the injected Piggieback to 0.5.3 --- CHANGELOG.md | 1 + cider.el | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13241e784..52f4482b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - `cider-test`: only show diffs for collections. - [#3375](https://github.com/clojure-emacs/cider/pull/3375): `cider-test`: don't render a newline between expected and actual, most times. - Improve `nrepl-dict` error reporting. +- Bump the injected `piggieback` to [0.5.3](https://github.com/nrepl/piggieback/blob/0.5.3/CHANGES.md#053-2021-10-26). - Bump the injected `cider-nrepl` to [0.35](https://github.com/clojure-emacs/cider-nrepl/blob/v0.35.0/CHANGELOG.md#0350-2023-08-09). - Improves indentation, font-locking and other metadata support for ClojureScript. - Updates [Orchard](https://github.com/clojure-emacs/orchard/blob/v0.14.2/CHANGELOG.md) diff --git a/cider.el b/cider.el index c18079036..bf2602442 100644 --- a/cider.el +++ b/cider.el @@ -472,7 +472,7 @@ your version of Boot or Leiningen is bundling an older one." "List of dependencies where elements are lists of artifact name and version. Added to `cider-jack-in-dependencies' when doing `cider-jack-in-cljs'.") (put 'cider-jack-in-cljs-dependencies 'risky-local-variable t) -(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.5.2") +(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.5.3") (defvar cider-jack-in-dependencies-exclusions nil "List of exclusions for jack in dependencies. From f26304d53180ca56873aabc663eacd99dbef0036 Mon Sep 17 00:00:00 2001 From: vemv Date: Sat, 12 Aug 2023 20:00:49 +0200 Subject: [PATCH 2/2] Recompute namespace info on each fighweel-main recompilation Similar to https://github.com/clojure-emacs/cider/pull/3396, except that it's only necessary on recompilation - not on evaluations. --- CHANGELOG.md | 2 ++ cider-repl.el | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52f4482b2..2bcd9f628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ - [#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. +- [#3393](https://github.com/clojure-emacs/cider/issues/3393): Recompute namespace info on each shadow-cljs recompilation or evaluation. +- Recompute namespace info on each fighweel-main recompilation. - 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-repl.el b/cider-repl.el index d70b708c3..b083a08de 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -986,6 +986,12 @@ t, as the content-type response is (currently) an alternative to the value response. However for handlers which themselves issue subsequent nREPL ops, it may be convenient to prevent inserting a prompt.") +(defun cider--maybe-get-state-cljs () + "Invokes `cider/get-state' when it's possible to do so." + (when-let ((conn (cider-current-repl 'cljs))) + (when (nrepl-op-supported-p "cider/get-state" conn) + (nrepl-send-request '("op" "cider/get-state") nil conn)))) + (defun cider--maybe-get-state-for-shadow-cljs (buffer &optional err) "Refresh the changed namespaces metadata given BUFFER and ERR (stderr string). @@ -1003,9 +1009,16 @@ This is particularly necessary for shadow-cljs because: (if err (string-match-p "Build completed\\." err) t)) - (when-let ((conn (cider-current-repl 'cljs))) - (when (nrepl-op-supported-p "cider/get-state" conn) - (nrepl-send-request '("op" "cider/get-state") nil conn)))))) + (cider--maybe-get-state-cljs)))) + +(defun cider--maybe-get-state-for-figwheel-main (buffer out) + "Refresh the changed namespaces metadata given BUFFER and OUT (stdout string)." + (with-current-buffer buffer + (when (and (eq cider-repl-type 'cljs) + (eq cider-cljs-repl-type 'figwheel-main) + (not cider-repl-cljs-upgrade-pending) + (string-match-p "Successfully compiled build" out)) + (cider--maybe-get-state-cljs)))) (defun cider--shadow-cljs-handle-stderr (buffer err) "Refresh the changed namespaces metadata given BUFFER and ERR." @@ -1015,6 +1028,12 @@ This is particularly necessary for shadow-cljs because: "Refresh the changed namespaces metadata given BUFFER." (cider--maybe-get-state-for-shadow-cljs buffer)) +(defvar cider--repl-stdout-functions (list #'cider--maybe-get-state-for-figwheel-main) + "Functions to be invoked each time new stdout is received on a repl buffer. + +Good for, for instance, monitoring specific strings that may be logged, +and responding to them.") + (defvar cider--repl-stderr-functions (list #'cider--shadow-cljs-handle-stderr) "Functions to be invoked each time new stderr is received on a repl buffer. @@ -1032,6 +1051,8 @@ and responding to them.") (lambda (buffer value) (cider-repl-emit-result buffer value t)) (lambda (buffer out) + (dolist (f cider--repl-stdout-functions) + (funcall f buffer out)) (cider-repl-emit-stdout buffer out)) (lambda (buffer err) (dolist (f cider--repl-stderr-functions)