Skip to content

Commit f37db43

Browse files
committed
[Fix #1280] Add readme links to all warnings
1 parent 94386d5 commit f37db43

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

cider-repl.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,17 @@ If BOL is non-nil insert at the beginning of line."
494494
"Emit STRING as interactive err output."
495495
(cider-repl--emit-interactive-output string 'cider-repl-stderr-face))
496496

497+
(defun cider-repl-readme-warning (section-id format &rest args)
498+
"Emit a warning to the REPL and link to the online readme.
499+
SECTION-ID is the section to link to. The link is added on the last line.
500+
FORMAT is a format string to compile with ARGS and display on the REPL."
501+
(let ((message (split-string (apply #'format format args) "\n")))
502+
(cider-repl-emit-interactive-stderr
503+
(concat "WARNING: "
504+
(mapconcat #'identity (butlast message) "\n ")
505+
(when (cdr message) "\n ")
506+
(cider--readme-button (car (last message)) section-id)))))
507+
497508
(defun cider-repl--emit-output (buffer string face &optional bol)
498509
"Using BUFFER, emit STRING font-locked with FACE.
499510
If BOL is non-nil, emit at the beginning of the line."

cider.el

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -471,24 +471,21 @@ In case `default-directory' is non-local we assume the command is available."
471471
(missing-ops (seq-remove (lambda (op) (nrepl-op-supported-p op current-connection))
472472
cider-required-nrepl-ops)))
473473
(when missing-ops
474-
(cider-repl-emit-interactive-stderr
475-
(format "WARNING: The following required nREPL ops are not supported: \n%s\nPlease, install (or update) cider-nrepl %s and restart CIDER"
476-
(cider-string-join missing-ops " ")
477-
(upcase cider-version))))))
474+
(cider-repl-readme-warning "cider-nrepl-middleware"
475+
"The following required nREPL ops are not supported: \n%s\nPlease, install (or update) cider-nrepl %s and restart CIDER"
476+
(cider-string-join missing-ops " ")
477+
(upcase cider-version)))))
478478

479479
(defun cider--check-required-nrepl-version ()
480480
"Check whether we're using a compatible nREPL version."
481-
(let ((nrepl-version (cider--nrepl-version)))
482-
(if nrepl-version
483-
(when (version< nrepl-version cider-required-nrepl-version)
484-
(cider-repl-emit-interactive-stderr
485-
(cider--readme-button
486-
(format "WARNING: CIDER requires nREPL %s (or newer) to work properly"
487-
cider-required-nrepl-version)
488-
"warning-saying-you-have-to-use-nrepl-027")))
489-
(cider-repl-emit-interactive-stderr
490-
(format "WARNING: Can't determine nREPL's version. Please, update nREPL to %s."
491-
cider-required-nrepl-version)))))
481+
(if-let ((nrepl-version (cider--nrepl-version)))
482+
(when (version< nrepl-version cider-required-nrepl-version)
483+
(cider-repl-readme-warning "warning-saying-you-have-to-use-nrepl-0212"
484+
"CIDER requires nREPL %s (or newer) to work properly"
485+
cider-required-nrepl-version))
486+
(cider-repl-readme-warning "warning-saying-you-have-to-use-nrepl-0212"
487+
"Can't determine nREPL's version.\nPlease, update nREPL to %s."
488+
cider-required-nrepl-version)))
492489

493490
(defun cider--check-middleware-compatibility-callback (buffer)
494491
"A callback to check if the middleware used is compatible with CIDER."
@@ -497,9 +494,10 @@ In case `default-directory' is non-local we assume the command is available."
497494
(lambda (_buffer result)
498495
(let ((middleware-version (read result)))
499496
(unless (and middleware-version (equal cider-version middleware-version))
500-
(cider-repl-emit-interactive-stderr
501-
(format "ERROR: CIDER's version (%s) does not match cider-nrepl's version (%s). Things will break!"
502-
cider-version middleware-version)))))
497+
;; FIXME: Add a proper readme section about this.
498+
(cider-repl-readme-warning "cider-nrepl-middleware"
499+
"CIDER's version (%s) does not match cider-nrepl's version (%s). Things will break!"
500+
cider-version middleware-version))))
503501
'()
504502
'()
505503
'()))

0 commit comments

Comments
 (0)