Skip to content

Commit 6a6bdf2

Browse files
committed
Put startup command in repl banner, cljs outside
1 parent 1013ed9 commit 6a6bdf2

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

cider-repl.el

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ fully initialized."
319319
((pred identity) (pop-to-buffer buffer)))
320320
(with-current-buffer buffer
321321
(cider-repl--insert-banner)
322-
(cider-repl--insert-startup-commands)
322+
(cider-repl--insert-param-values `((:cljs-repl-type "cljs repl type:" ,#'symbol-name)
323+
(:repl-init-form "cljs repl startup command:")))
323324
(when-let* ((window (get-buffer-window buffer t)))
324325
(with-selected-window window
325326
(recenter (- -1 scroll-margin))))
@@ -334,27 +335,25 @@ fully initialized."
334335
(insert-before-markers
335336
(propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face))))
336337

337-
(defun cider-repl--insert-startup-commands ()
338-
"Insert the commands used to create the repl."
339-
(let ((params cider-saved-params))
340-
(cl-labels
341-
((emit-comment
342-
(string)
343-
(insert-before-markers
344-
(propertize string 'font-lock-face 'font-lock-comment-face)))
345-
(emit-command
346-
(desc prop &optional transform)
347-
(let ((transform (or transform #'identity)))
348-
(when-let ((command (plist-get params prop)))
349-
(emit-comment
350-
(concat ";; " desc "\n;; " (funcall transform command) "\n"))))))
351-
(emit-comment ";;\n")
352-
(emit-command "repl startup command:" :jack-in-cmd)
353-
(when (plist-get params :repl-init-form)
354-
(emit-comment ";;\n")
355-
(emit-command "repl type:" :cljs-repl-type #'symbol-name)
356-
(emit-command "cljs startup command:" :repl-init-form))
357-
(emit-comment "\n"))))
338+
(defun cider-repl--insert-param-values (param-tuples)
339+
"Insert the values from params specified in PARAM-TUPLES.
340+
PARAM-TUPLES are tuples of (param-key description) or (param-key
341+
description transform) where transform is called with the param-value if
342+
present."
343+
(cl-labels
344+
((emit-comment
345+
(string)
346+
(insert-before-markers
347+
(propertize
348+
(if (string-blank-p string) ";;\n" (concat ";; " string "\n"))
349+
'font-lock-face 'font-lock-comment-face))))
350+
(mapc (lambda (param-tuple)
351+
(cl-destructuring-bind (param-key desc &optional transform) param-tuple
352+
(when-let ((value (plist-get cider-saved-params param-key)))
353+
(emit-comment "")
354+
(emit-comment (concat desc ": " (funcall (or transform #'identity) value))))))
355+
param-tuples)
356+
(emit-comment "")))
358357

359358
(defun cider-repl--banner ()
360359
"Generate the welcome REPL buffer banner."
@@ -367,13 +366,15 @@ fully initialized."
367366
;; Javadoc: (javadoc java-object-or-class)
368367
;; Exit: <C-c C-q>
369368
;; Results: Stored in vars *1, *2, *3, an exception in *e;
369+
;; Startup: %s
370370
"
371371
(plist-get nrepl-endpoint :host)
372372
(plist-get nrepl-endpoint :port)
373373
(cider--version)
374374
(cider--nrepl-version)
375375
(cider--clojure-version)
376-
(cider--java-version)))
376+
(cider--java-version)
377+
(plist-get cider-saved-params :jack-in-cmd)))
377378

378379
(defun cider-repl--help-banner ()
379380
"Generate the help banner."

test/cider-repl-tests.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
(spy-on 'cider--nrepl-version :and-return-value "0.5.3")
3939
(setq nrepl-endpoint (list :host "localhost" :port "54018"))
4040
(setq cider-version "0.12.0")
41-
(setq cider-codename "Seattle"))
41+
(setq cider-codename "Seattle")
42+
(setq cider-saved-params (list :jack-in-cmd "startup command")))
4243

4344
(describe "when the cider package version information is available"
4445
(it "returns the repl banner string"
@@ -53,6 +54,7 @@
5354
;; Javadoc: (javadoc java-object-or-class)
5455
;; Exit: <C-c C-q>
5556
;; Results: Stored in vars *1, *2, *3, an exception in *e;
57+
;; Startup: startup command
5658
")))
5759

5860
(describe "when the cider package version information is not available"
@@ -68,6 +70,7 @@
6870
;; Javadoc: (javadoc java-object-or-class)
6971
;; Exit: <C-c C-q>
7072
;; Results: Stored in vars *1, *2, *3, an exception in *e;
73+
;; Startup: startup command
7174
"))))
7275

7376
(defvar cider-testing-ansi-colors-vector

0 commit comments

Comments
 (0)