Skip to content

Commit

Permalink
[#1337] Unify the REPL clearing behavior in cider-mode and cider-repl…
Browse files Browse the repository at this point in the history
…-mode
  • Loading branch information
bbatsov committed Nov 5, 2015
1 parent 20d4b80 commit 2770532
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* [#732](https://github.com/clojure-emacs/cider/issues/732): `cider-quit` and `cider-restart` now operate on the current connection only. With a prefix argument they operate on all connections.
* `nrepl-log-messages` is now set to `t` by default.
* Renamed `cider-repl-output-face` to `cider-repl-stdout-face` and `cider-repl-err-output-face` to `cider-repl-stderr-face`.
* Clearing the REPL buffer is now bound to `C-u C-C C-o` when you're in the REPL.
* Clearing the REPL buffer is now bound to `C-u C-C C-o`.

### Bugs fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ Keyboard shortcut | Description
<kbd>C-c M-z</kbd> | Load (eval) the current buffer and 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.
<kbd>C-c M-d</kbd> | Display default REPL connection details, including project directory name, buffer namespace, host and port.
<kbd>C-c M-r</kbd> | Rotate and display the default nREPL connection.
<kbd>C-c M-o</kbd> | Clear the entire REPL buffer, leaving only a prompt. Useful if you're running the REPL buffer in a side by side buffer.
<kbd>C-c C-o</kbd> | Clear the last output in the REPL buffer. With a prefix argument it will clear the entire REPL buffer, leaving only a prompt. Useful if you're running the REPL buffer in a side by side buffer.
<kbd>C-c C-k</kbd> | Load (eval) the current buffer.
<kbd>C-c C-l</kbd> | Load (eval) a Clojure file.
<kbd>C-c C-x</kbd> | Reload all modified files on the classpath. If invoked with a prefix argument, reload all files on the classpath. If invoked with a double prefix argument, clear the state of the namespace tracker before reloading.
Expand Down
13 changes: 8 additions & 5 deletions cider-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,16 @@ Clojure buffer and the REPL buffer."
(pop-to-buffer cider-last-clojure-buffer))
(message "Don't know the original Clojure buffer")))

(defun cider-find-and-clear-repl-buffer ()
(defun cider-find-and-clear-repl-output (&optional clear-repl)
"Find the current REPL buffer and clear it.
With a prefix argument CLEAR-REPL the command clears the entire REPL buffer.
Returns to the buffer in which the command was invoked."
(interactive)
(interactive "P")
(let ((origin-buffer (current-buffer)))
(switch-to-buffer (cider-current-repl-buffer))
(cider-repl-clear-buffer)
(if clear-repl
(cider-repl-clear-buffer)
(cider-repl-clear-output))
(switch-to-buffer origin-buffer)))


Expand Down Expand Up @@ -226,7 +229,7 @@ Returns to the buffer in which the command was invoked."
(define-key map (kbd "C-c M-t n") #'cider-toggle-trace-ns)
(define-key map (kbd "C-c C-z") #'cider-switch-to-repl-buffer)
(define-key map (kbd "C-c M-z") #'cider-load-buffer-and-switch-to-repl-buffer)
(define-key map (kbd "C-c M-o") #'cider-find-and-clear-repl-buffer)
(define-key map (kbd "C-c C-o") #'cider-find-and-clear-repl-output)
(define-key map (kbd "C-c C-k") #'cider-load-buffer)
(define-key map (kbd "C-c C-l") #'cider-load-file)
(define-key map (kbd "C-c C-b") #'cider-interrupt)
Expand Down Expand Up @@ -285,7 +288,7 @@ Returns to the buffer in which the command was invoked."
["Switch to REPL" cider-switch-to-repl-buffer]
["Switch to Relevant REPL" cider-switch-to-relevant-repl-buffer]
["Toggle REPL Pretty Print" cider-repl-toggle-pretty-printing]
["Clear REPL" cider-find-and-clear-repl-buffer]
["Clear REPL output" cider-find-and-clear-repl-output]
"--"
("nREPL"
["Describe session" cider-describe-nrepl-session]
Expand Down

0 comments on commit 2770532

Please sign in to comment.