Skip to content

Commit ff60b8f

Browse files
committed
Add cider-load-buffer-and-switch-to-repl-buffer
The function will load (eval) the current buffer, change the namespace of the REPL buffer to match the currently visited source file, and then switch to the relevant REPL buffer.
1 parent cb35041 commit ff60b8f

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### New features
66

7+
* [#1232](https://github.com/clojure-emacs/cider/pull/1232): Add cider-load-buffer-and-switch-to-repl-buffer
78
* [#1212](https://github.com/clojure-emacs/cider/pull/1212): Add pagination of long collections to inspector.
89
* [#1201](https://github.com/clojure-emacs/cider/pull/1201): Integrate overlays with interactive evaluation. `cider-use-overlays` can be used to turn this on or off.
910
* [#1195](https://github.com/clojure-emacs/cider/pull/1195): CIDER can [create cljs REPLs](https://github.com/clojure-emacs/cider#clojurescript-usage).

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ Keyboard shortcut | Description
813813
<kbd>C-c C-n</kbd> | Eval the ns form.
814814
<kbd>C-c M-n</kbd> | Switch the namespace of the REPL buffer to the namespace of the current buffer.
815815
<kbd>C-c C-z</kbd> | Switch to the relevant REPL buffer. Use a prefix argument to change the namespace of the REPL buffer to match the currently visited source file.
816+
<kbd>C-c M-z</kbd> | Load (eval) the current buffer, change the namespace of the REPL buffer to match the currently visited source file, and then switch to the relevant REPL buffer.
816817
<kbd>C-u C-u C-c C-z</kbd> | Switch to the REPL buffer based on a user prompt for a directory.
817818
<kbd>C-c M-d</kbd> | Display default REPL connection details, including project directory name, buffer namespace, host and port.
818819
<kbd>C-c M-r</kbd> | Rotate and display the default nREPL connection.

cider-interaction.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,13 @@ directory."
507507
(message (cider--connection-info (car nrepl-connection-list))))
508508
connection-buffer))
509509

510+
(defun cider-load-buffer-and-switch-to-repl-buffer ()
511+
"Load the current buffer into the REPL buffer, swtich the REPL buffer to
512+
that namespace, and switch to the REPL buffer."
513+
(interactive "p")
514+
(cider-load-buffer)
515+
(cider-switch-to-relevant-repl-buffer 4))
516+
510517
(defun cider-switch-to-relevant-repl-buffer (&optional arg)
511518
"Select the REPL buffer, when possible in an existing window.
512519
The buffer chosen is based on the file open in the current buffer.

cider-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ entirely."
104104
(define-key map (kbd "C-c M-t v") #'cider-toggle-trace-var)
105105
(define-key map (kbd "C-c M-t n") #'cider-toggle-trace-ns)
106106
(define-key map (kbd "C-c C-z") #'cider-switch-to-repl-buffer)
107+
(define-key map (kbd "C-c M-z") #'cider-load-buffer-and-switch-to-repl-buffer)
107108
(define-key map (kbd "C-c M-o") #'cider-find-and-clear-repl-buffer)
108109
(define-key map (kbd "C-c C-k") #'cider-load-buffer)
109110
(define-key map (kbd "C-c C-l") #'cider-load-file)

0 commit comments

Comments
 (0)