From 5cb98a74bad81a2cd15f8db86c469020ed030156 Mon Sep 17 00:00:00 2001 From: Vitalie Spinu Date: Sun, 17 Jun 2018 22:11:00 +0200 Subject: New connection API and jack-in rewrite (#2324) Second attempt on #2069. A brief description of the new functionality follows. 1) __Jack-in/connect__ - User level commands: Create new sessions: C-c M-j: cider-jack-in-clj C-c M-J: cider-jack-in-cljs C-c M-c: cider-connect-clj C-c M-C: cider-connect-cljs Add new REPLs to the current session: C-c M-s: cider-connect-sibling-clj C-c M-S: cider-connect-sibling-cljs - `cider-jack-in-clojurescript` no longer creates two repls, only the cljs repl - clj repl has no longer a special status of the "main" repl. All repls within a session share same server and are siblings of each other. You can create as many clj and cljs siblings as you want from any repl. - Creation of the client is no longer tightly bounded with the nrepl-server startup. The dynamic communication mechanism between jack-in and nrepl-server filter has been replace by a simple `on-port-callback`. 2) __New Connection and Session Management API__ - Connections (aka REPLs) are grouped in [sesman](https://github.com/vspinu/sesman) sessions. Sibling repls are added to the current session. - Cider connection commands (`cider-quit`, `cider-restart`, `cider-display-connection-info`) have been refactored to operate exclusively on the connection level. - Sesman commands operate on the whole session: ![sesman-map](https://user-images.githubusercontent.com/1363467/41355277-6864ffb8-6f21-11e8-9387-3de586477d68.png) - Associations (links) between current context (buffer, directory, project) are governed by sesman and could be formed only on the session level. In a nutshell, session can be linked to projects, directories and buffers. Buffer link have precedence over directory links, and directory have precedence over project links. When a sesman session is registered it's automatically linked with the lowest priority context (project, or directory if no project found). By default (configured with `sesman-1-to-1-links`) multiple sessions can be linked with a project or a directory, but only one session can be linked with a buffer. Cider functionality (eval, completion, repl-switching etc) operate on linked sessions. When there are multiple linked sessions ambiguity is automatically resolved by the recency of the REPL buffers (configured with `sesman-disambiguate-by-relevance`). - Show info on current links with `C-c C-s l`. Show info on current, linked or all sessions with `C-c C-s i`. - Micro-management of the server is not allowed (it's not useful and would complicate UI). All repls within a session share a server. Server can be either remote (`cider-connect`) or local (bootstraped within the emacs during `cider-jack-in-xyz`). In case of the local server, when the last connection is killed the server is automatically killed. `cider-restart` restarts the connection but not the server. `sesman-restart` restarts the server and all the connections. At least two issues I still plan to tackle here: - Restart of SSH tunneled connection has not been tested and probably doesn't work - REPL buffer naming system is no longer adequate. It should be possible to include session name as part of the buffer name and add more flexibility into the customization of buffer name templates. ----- A tot of no longer necessary or questionable functionality has been removed. The goal is to start from scratch and add only what is really necessary. I am listing all the removed functions for the ease of lookup through the github interface. Removed: cider--connection-host, cider--connection-port, cider--connection-project-dir, cider--connection-properties, cider--connection-type, cider--guess-cljs-connection, cider--has-warned-about-bad-repl-type, cider--in-connection-buffer-p, cider--quit-connection, cider--restart-connection, cider-assoc-buffer-with-connection, cider-assoc-project-with-connection, cider-change-buffers-designation, cider-clear-buffer-local-connection, cider-close-nrepl-session, cider-connections (variable), cider-current-connection (variable), cider-current-messages-buffer, cider-current-repl-buffer, cider-default-connection, cider-extract-designation-from-current-repl-buffer, cider-find-connection-buffer-for-project-directory, cider-find-reusable-repl-buffer, cider-make-connection-default, cider-map-connections, cider-other-connection, cider-project-connections, cider-project-connections-types, cider-prompt-for-project-on-connect, cider-read-connection, cider-repl-buffers, cider-replicate-connection, cider-request-dispatch, cider-rotate-default-connection, cider-toggle-buffer-connection, cider-toggle-request-dispatch, nrepl-connection-buffer-name-template, nrepl-create-client-buffer-function, nrepl-post-client-callback nrepl-prompt-to-kill-server-buffer-on-quit, nrepl-use-this-as-repl-buffer, Connection Browser Functionality: cider--connection-browser-buffer-name, cider--connection-ewoc, cider--connection-pp, cider--connections-close-connection, cider--connections-goto-connection, cider--connections-make-default, cider--connections-refresh, cider--connections-refresh-buffer, cider--ewoc-apply-at-point, cider--setup-connection-browser, cider--update-connections-display, cider-client-name-repl-type, cider-connection-browser, cider-connections-buffer-mode, cider-connections-buffer-mode-map cider-connections-close-connection, cider-connections-goto-connection, cider-connections-make-default, cider-display-connected-message, cider-project-name, Renamed: cider-current-session -> cider-nrepl-eval-session cider-current-tooling-session -> cider-nrepl-tooling-session cider-display-connection-info -> cider-describe-current-connection cider-create-sibling-cljs-repl -> cider-connect-sibling-cljs nrepl-connection-buffer-name -> nrepl-repl-buffer-name cider--close-connection-buffer -> cider--close-connection ## repl <> connection overlap cleanup cider-connections -> cider-repls cider-current-connection -> cider-current-repl cider-map-connections -> cider-map-repls cider-connection-type-for-buffer -> cider-repl-type-for-buffer cider-repl-set-type -> cider-set-repl-type --- cider-selector.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index dc6b4ea2..cd09cc93 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -64,7 +64,6 @@ Only considers buffers that are not already visible." The user is prompted for a single character indicating the method by which to choose a new buffer. The `?' character describes then available methods. OTHER-WINDOW provides an optional target. - See `def-cider-selector-method' for defining new methods." (interactive) (message "Select [%s]: " @@ -85,7 +84,6 @@ See `def-cider-selector-method' for defining new methods." (defmacro def-cider-selector-method (key description &rest body) "Define a new `cider-select' buffer selection method. - KEY is the key the user will enter to choose this method. DESCRIPTION is a one-line sentence describing how the method @@ -138,16 +136,11 @@ is chosen. The returned buffer is selected with (def-cider-selector-method ?r "Current REPL buffer." - (cider-current-repl-buffer)) - -(def-cider-selector-method ?n - "Connections browser buffer." - (cider-connection-browser) - cider--connection-browser-buffer-name) + (cider-current-repl)) (def-cider-selector-method ?m "Current connection's *nrepl-messages* buffer." - (cider-current-messages-buffer)) + (nrepl-messages-buffer (cider-current-repl))) (def-cider-selector-method ?x "*cider-error* buffer." -- cgit v1.2.3 From ac9cb611f422f1133a9520efa469687c0cd3af18 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 25 Jun 2018 09:44:51 +0300 Subject: [Fix #2203] Rename cider-interaction.el to cider-eval.el All of the non-eval functionality was removed, which marks the end of the process of breaking up the old file. Down the road we may opt to break down cider-eval into some core functionality and extra functionality, as many of the eval commands there are kind of "exotic", but that's not that important at this point. --- cider-selector.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index cd09cc93..92c90965 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -32,7 +32,7 @@ ;;; Code: (require 'cider-client) -(require 'cider-interaction) +(require 'cider-eval) (require 'cider-scratch) (defconst cider-selector-help-buffer "*CIDER Selector Help*" -- cgit v1.2.3 From e78389572f637fb0a9705046ef16507e97e52234 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 8 Jul 2018 08:17:25 +0200 Subject: Rename cider-find-or-create-scratch-buffer to cider-scratch-find-or-create-buffer --- cider-selector.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index 92c90965..e0ba71d3 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -150,10 +150,10 @@ is chosen. The returned buffer is selected with "*cider-doc* buffer." cider-doc-buffer) -(declare-function cider-find-or-create-scratch-buffer "cider-scratch") +(declare-function cider-scratch-find-or-create-buffer "cider-scratch") (def-cider-selector-method ?s "*cider-scratch* buffer." - (cider-find-or-create-scratch-buffer)) + (cider-scratch-find-or-create-buffer)) (provide 'cider-selector) -- cgit v1.2.3 From 4b5f28bfadd2428c3a8386dcb982993a29ea4e84 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 8 Jul 2018 08:36:45 +0200 Subject: Add the ability to jump to the profiler buffer using `cider-selector` --- cider-selector.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index e0ba71d3..62fbff12 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -146,6 +146,10 @@ is chosen. The returned buffer is selected with "*cider-error* buffer." cider-error-buffer) +(def-cider-selector-method ?p + "CIDER profiler buffer." + cider-profile-buffer) + (def-cider-selector-method ?d "*cider-doc* buffer." cider-doc-buffer) -- cgit v1.2.3 From c3f4d157079eff77f8c0291213a5af655622967a Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 8 Jul 2018 08:41:29 +0200 Subject: Rename cider--recently-visited-buffer to cider-selector--recently-visited-buffer --- cider-selector.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index 62fbff12..8c02d532 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -46,7 +46,7 @@ DESCRIPTION is a one-line description of what the key selects.") (defvar cider-selector-other-window nil "If non-nil use `switch-to-buffer-other-window'.") -(defun cider--recently-visited-buffer (mode) +(defun cider-selector--recently-visited-buffer (mode) "Return the most recently visited buffer, deriving its `major-mode' from MODE. Only considers buffers that are not already visible." (cl-loop for buffer in (buffer-list) @@ -125,11 +125,11 @@ is chosen. The returned buffer is selected with (def-cider-selector-method ?c "Most recently visited clojure-mode buffer." - (cider--recently-visited-buffer 'clojure-mode)) + (cider-selector--recently-visited-buffer 'clojure-mode)) (def-cider-selector-method ?e "Most recently visited emacs-lisp-mode buffer." - (cider--recently-visited-buffer 'emacs-lisp-mode)) + (cider-selector--recently-visited-buffer 'emacs-lisp-mode)) (def-cider-selector-method ?q "Abort." (top-level)) -- cgit v1.2.3 From ebec8911ca501b6311614756d299af103159c74d Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 8 Jul 2018 14:09:20 +0200 Subject: Improve a docstring --- cider-selector.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index 8c02d532..d2d925fb 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -44,7 +44,9 @@ Each element is a list (KEY DESCRIPTION FUNCTION). DESCRIPTION is a one-line description of what the key selects.") (defvar cider-selector-other-window nil - "If non-nil use `switch-to-buffer-other-window'.") + "If non-nil use `switch-to-buffer-other-window'. +Not meant to be set by users. It's used internally +by `cider-selector'.") (defun cider-selector--recently-visited-buffer (mode) "Return the most recently visited buffer, deriving its `major-mode' from MODE. -- cgit v1.2.3 From 73278d76fae8ade321631f2ce71ef26e5fc42fe7 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 8 Jul 2018 14:09:47 +0200 Subject: Kill a redundant declare-function --- cider-selector.el | 1 - 1 file changed, 1 deletion(-) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index d2d925fb..3163e6fa 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -156,7 +156,6 @@ is chosen. The returned buffer is selected with "*cider-doc* buffer." cider-doc-buffer) -(declare-function cider-scratch-find-or-create-buffer "cider-scratch") (def-cider-selector-method ?s "*cider-scratch* buffer." (cider-scratch-find-or-create-buffer)) -- cgit v1.2.3 From 1c9f9e33a2c3995774953e43906148200b11507e Mon Sep 17 00:00:00 2001 From: Vitalie Spinu Date: Sun, 5 Aug 2018 11:32:16 +0200 Subject: Rename `cider-describe-current-connection` -> `cider-describe-connection` .. because it accepts an explicit REPL argument now. --- cider-selector.el | 1 + 1 file changed, 1 insertion(+) (limited to 'cider-selector.el') diff --git a/cider-selector.el b/cider-selector.el index 3163e6fa..a21032db 100644 --- a/cider-selector.el +++ b/cider-selector.el @@ -34,6 +34,7 @@ (require 'cider-client) (require 'cider-eval) (require 'cider-scratch) +(require 'cider-profile) (defconst cider-selector-help-buffer "*CIDER Selector Help*" "The name of the selector's help buffer.") -- cgit v1.2.3