Skip to content

Commit

Permalink
[#1337] Rebind clearing the REPL buffer to C-u C-c C-o in cider-rep…
Browse files Browse the repository at this point in the history
…l-mode
  • Loading branch information
bbatsov committed Nov 5, 2015
1 parent 56d20b2 commit 68bb5c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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.

### Bugs fixed

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,7 @@ Keyboard shortcut | Description
<kbd>RET</kbd> | Evaluate the current input in Clojure if it is complete. If incomplete, open a new line and indent. If invoked with a prefix argument is given then the input is evaluated without checking for completeness.
<kbd>C-RET</kbd> | Close any unmatched parenthesis and then evaluate the current input in Clojure.
<kbd>C-j</kbd> | Open a new line and indent.
<kbd>C-c M-o</kbd> | Clear the entire REPL buffer, leaving only a prompt.
<kbd>C-c C-o</kbd> | Remove the output of the previous evaluation from the REPL buffer.
<kbd>C-c C-o</kbd> | Remove the output of the previous evaluation from the REPL buffer. With a prefix argument it will clear the entire REPL buffer, leaving only a prompt.
<kbd>C-c C-u</kbd> | Kill all text from the prompt to the current point.
<kbd>C-c C-b</kbd> <kbd>C-c C-c</kbd>| Interrupt any pending evaluations.
<kbd>C-up</kbd> <kbd>C-down</kbd> | Goto to previous/next input in history.
Expand Down
36 changes: 19 additions & 17 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -731,22 +731,25 @@ text property `cider-old-input'."
(1- (previous-single-property-change cider-repl-input-start-mark 'field nil
(1+ (point-min)))))

(defun cider-repl-clear-output ()
"Delete the output inserted since the last input."
(interactive)
(let ((start (save-excursion
(cider-repl-previous-prompt)
(ignore-errors (forward-sexp))
(forward-line)
(point)))
(end (cider-repl--end-of-line-before-input-start)))
(when (< start end)
(let ((inhibit-read-only t))
(delete-region start end)
(save-excursion
(goto-char start)
(insert
(propertize ";;; output cleared" 'font-lock-face 'font-lock-comment-face)))))))
(defun cider-repl-clear-output (&optional clear-repl)
"Delete the output inserted since the last input.
With a prefix argument CLEAR-REPL it will clear the entire REPL buffer instead."
(interactive "P")
(if clear-repl
(cider-repl-clear-buffer)
(let ((start (save-excursion
(cider-repl-previous-prompt)
(ignore-errors (forward-sexp))
(forward-line)
(point)))
(end (cider-repl--end-of-line-before-input-start)))
(when (< start end)
(let ((inhibit-read-only t))
(delete-region start end)
(save-excursion
(goto-char start)
(insert
(propertize ";;; output cleared" 'font-lock-face 'font-lock-comment-face))))))))

(defun cider-repl-switch-ns-handler (buffer)
"Make a nREPL evaluation handler for the REPL BUFFER's ns switching."
Expand Down Expand Up @@ -1091,7 +1094,6 @@ constructs."
(define-key map (kbd "C-<return>") #'cider-repl-closing-return)
(define-key map (kbd "C-j") #'cider-repl-newline-and-indent)
(define-key map (kbd "C-c C-o") #'cider-repl-clear-output)
(define-key map (kbd "C-c M-o") #'cider-repl-clear-buffer)
(define-key map (kbd "C-c M-n") #'cider-repl-set-ns)
(define-key map (kbd "C-c C-u") #'cider-repl-kill-input)
(define-key map (kbd "C-S-a") #'cider-repl-bol-mark)
Expand Down

0 comments on commit 68bb5c9

Please sign in to comment.