branch: elpa/cider commit 253c22f420199ce1eb9abb104ac4222d0098bca9 Author: vemv <v...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
`cider--sesman-friendly-session-p`: avoid semi-recursive edge case (#3435) --- cider-client.el | 13 ++++++++----- cider-repl.el | 5 ++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cider-client.el b/cider-client.el index 20c368628d..13c311d870 100644 --- a/cider-client.el +++ b/cider-client.el @@ -120,16 +120,19 @@ Useful for special buffers (e.g. REPL, doc buffers) that have to keep track of a namespace. This should never be set in Clojure buffers, as there the namespace should be extracted from the buffer's ns form.") -(defun cider-current-ns (&optional no-default) +(defun cider-current-ns (&optional no-default no-repl-check) "Return the current ns. The ns is extracted from the ns form for Clojure buffers and from `cider-buffer-ns' for all other buffers. If it's missing, use the current -REPL's ns, otherwise fall back to \"user\". When NO-DEFAULT is non-nil, it -will return nil instead of \"user\"." +REPL's ns, otherwise fall back to \"user\". +When NO-DEFAULT is non-nil, it will return nil instead of \"user\". +When NO-REPL-CHECK is non-nil, `cider-current-repl' will not be queried, +improving performance (at the possible cost of accuracy)." (or cider-buffer-ns (cider-get-ns-name) - (when-let* ((repl (cider-current-repl))) - (buffer-local-value 'cider-buffer-ns repl)) + (unless no-repl-check + (when-let* ((repl (cider-current-repl))) + (buffer-local-value 'cider-buffer-ns repl))) (if no-default nil "user"))) (defun cider-path-to-ns (relpath) diff --git a/cider-repl.el b/cider-repl.el index e5c315445f..6728538645 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -1802,7 +1802,10 @@ The checking is done as follows: classpath-roots))) translated)) (when-let ((ns (condition-case nil - (substring-no-properties (cider-current-ns :no-default)) + (substring-no-properties (cider-current-ns :no-default + ;; important - don't query the repl, + ;; avoiding a recursive invocation of `cider--sesman-friendly-session-p`: + :no-repl-check)) (error nil)))) ;; if the ns form matches with a ns of all runtime namespaces, we can consider the buffer to match ;; (this is a bit lax, but also quite useful)