Skip to content

Commit 5dbeb5b

Browse files
vspinubbatsov
authored andcommitted
Add nREPL support for user level notifications
1 parent 91a0b38 commit 5dbeb5b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [#2015](https://github.com/clojure-emacs/cider/pull/2015): Show symbols as special forms *and* macros in `cider-doc`
1313
* [#2012](https://github.com/clojure-emacs/cider/pull/2012): Support special forms in `cider-apropos` and `cider-grimoire-lookup`.
1414
* [#2007](https://github.com/clojure-emacs/cider/pull/2007): Fontify code blocks from `cider-grimoire` if possible.
15+
* Add support for notifications from the NREPL server.
1516
* [#1990](https://github.com/clojure-emacs/cider/issues/1990): Add new customation variable `cider-save-files-on-cider-refresh` to allow auto-saving buffers when `cider-refresh` is called.
1617
* Add new function `cider-load-all-files`, along with menu bar update.
1718
* Add new customization variable `cider-special-mode-truncate-lines`.

nrepl-client.el

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,25 @@ It is safe to call this function multiple times on the same ID."
736736
(puthash id handler nrepl-completed-requests)
737737
(remhash id nrepl-pending-requests)))
738738

739+
(declare-function cider-repl--emit-interactive-output "cider-repl")
740+
(defun nrepl-notify (msg type)
741+
"Handle \"notification\" server request.
742+
MSG is a string to be displayed. TYPE is the type of the message. All
743+
notifications are currently displayed with `message' function and emitted
744+
to the REPL."
745+
(let* ((face (pcase type
746+
((or "message" 'nil) 'font-lock-builtin-face)
747+
("warning" 'warning)
748+
("error" 'error)))
749+
(msg (if face
750+
(propertize msg 'face face)
751+
(format "%s: %s" (upcase type) msg))))
752+
(cider-repl--emit-interactive-output msg (or face 'font-lock-builtin-face))
753+
(message msg)
754+
;; Interactive eval handler covers this message, but it won't be eval
755+
;; middleware using this functionality.
756+
(sit-for 2)))
757+
739758
(defvar cider-buffer-ns)
740759
(defvar cider-special-mode-truncate-lines)
741760
(declare-function cider-need-input "cider-interaction")
@@ -779,6 +798,9 @@ corresponding type of response."
779798
(when stderr-handler
780799
(funcall stderr-handler buffer err)))
781800
(status
801+
(when (member "notification" status)
802+
(nrepl-dbind-response response (msg type)
803+
(nrepl-notify msg type)))
782804
(when (member "interrupted" status)
783805
(message "Evaluation interrupted."))
784806
(when (member "eval-error" status)

0 commit comments

Comments
 (0)