Skip to content

Commit c694b1e

Browse files
committed
Add a couple of commands for removal or REPL banners
1 parent 6933632 commit c694b1e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ and try to associate the created connection with this project automatically.
2020
* [#1543](https://github.com/clojure-emacs/cider/issues/1543): Add some getting started instructions to the welcome banner.
2121
* New command `cider-drink-a-sip`. Use in case you're thirsty for knowledge.
2222
* Make the connection message configurable via `cider-connection-message-fn`. This means now you can have any function (e.g. `cider-random-tip`) provide the second part of the message.
23+
* New command `cider-repl-clear-banners`.
24+
* New command `cider-repl-clear-help-banner`.
2325

2426
### Changes
2527

cider-repl.el

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
340340
;; Above all else - don’t panic! In case of an emergency - procure
341341
;; some (hard) cider and enjoy it responsibly!
342342
;;
343-
;; You can disable this message from appearing on start by setting
343+
;; You can remove this message with the `cider-repl-clear-help-banner' command.
344+
;; You can disable it from appearing on start by setting
344345
;; `cider-repl-display-help-banner' to nil.
345346
;; ======================================================================
346347
"))
@@ -832,6 +833,43 @@ With a prefix argument CLEAR-REPL it will clear the entire REPL buffer instead."
832833
(insert
833834
(propertize ";;; output cleared" 'font-lock-face 'font-lock-comment-face))))))))
834835

836+
(defun cider-repl-clear-banners ()
837+
"Delete the REPL banners."
838+
(interactive)
839+
;; TODO: Improve the boundaries detecting logic
840+
;; probably it should be based on text properties
841+
;; the current implemetation will clear warnings as well
842+
(let ((start (point-min))
843+
(end (save-excursion
844+
(goto-char (point-min))
845+
(cider-repl-next-prompt)
846+
(forward-line -1)
847+
(end-of-line)
848+
(point))))
849+
(when (< start end)
850+
(let ((inhibit-read-only t))
851+
(cider-repl--clear-region start (1+ end))))))
852+
853+
(defun cider-repl-clear-help-banner ()
854+
"Delete the help REPL banner."
855+
(interactive)
856+
;; TODO: Improve the boundaries detecting logic
857+
;; probably it should be based on text properties
858+
(let ((start (save-excursion
859+
(goto-char (point-min))
860+
(search-forward ";; =")
861+
(beginning-of-line)
862+
(point)))
863+
(end (save-excursion
864+
(goto-char (point-min))
865+
(cider-repl-next-prompt)
866+
(search-backward ";; =")
867+
(end-of-line)
868+
(point))))
869+
(when (< start end)
870+
(let ((inhibit-read-only t))
871+
(cider-repl--clear-region start (1+ end))))))
872+
835873
(defun cider-repl-switch-ns-handler (buffer)
836874
"Make a nREPL evaluation handler for the REPL BUFFER's ns switching."
837875
(nrepl-make-response-handler buffer
@@ -1107,6 +1145,8 @@ constructs."
11071145
(declare-function cider-refresh "cider-interaction")
11081146
(cider-repl-add-shortcut "clear-output" #'cider-repl-clear-output)
11091147
(cider-repl-add-shortcut "clear" #'cider-repl-clear-buffer)
1148+
(cider-repl-add-shortcut "clear-banners" #'cider-repl-clear-banners)
1149+
(cider-repl-add-shortcut "clear-help-banner" #'cider-repl-clear-help-banner)
11101150
(cider-repl-add-shortcut "ns" #'cider-repl-set-ns)
11111151
(cider-repl-add-shortcut "toggle-pretty" #'cider-repl-toggle-pretty-printing)
11121152
(cider-repl-add-shortcut "browse-ns" (lambda () (cider-browse-ns (cider-current-ns))))

0 commit comments

Comments
 (0)