Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show startup commands in repl buffer #2744

Merged
merged 1 commit into from
Nov 29, 2019

Conversation

dpsutton
Copy link
Contributor

@dpsutton dpsutton commented Nov 8, 2019

Simple change to show the commands CIDER uses to get everything running to the user in the repl buffer.

image

There are a few good reasons to do this:

  • we show the jack in command but its as a message and can quickly go away

  • we never show the cljs command so people might forget how they are actually starting the cljs repl when CIDER doesn't display it

  • it removes the "magic" of what CIDER does for beginners and trouble shooters.

  • it gives someone access to the commands if they prefer to cider-connect instead of having clojure running as a subprocess to emacs.

  • The commits are consistent with our contribution guidelines

  • You've added tests (if possible) to cover your change(s)

  • All tests are passing (make test)

  • All code passes the linter (make lint) which is based on elisp-lint and includes

  • You've updated the changelog (if adding/changing user-visible functionality)

  • You've updated the user manual (if adding/changing user-visible functionality)

Thanks!

If you're just starting out to hack on CIDER you might find this section of its
manual
extremely useful.

@bbatsov
Copy link
Member

bbatsov commented Nov 8, 2019

Nicely done! I think, however, it's a bit misleading that the shell command that boots nREPL and the Clojure form that changes a REPL type are shown in the same way, because they clearly aren't. It also seems to me that this will work only for REPLs which came from cider-jack-in, so some command to describe a REPL might be useful as well. And perhaps we should show the ClojureScript version in use somewhere. Somehow I never thought about this.

@dpsutton
Copy link
Contributor Author

dpsutton commented Nov 8, 2019

It also seems to me that this will work only for REPLs which came from cider-jack-in

I was envisioning making sure it was clear how a repl is started. If someone is not using jack-in commands then it is already clear to them how it was started.

And perhaps we should show the ClojureScript version in use somewhere

I don't follow this. I'm showing the clojurescript startup command. Or do you mean the cljs repl type? Like shadow or figwheel etc?

@bbatsov
Copy link
Member

bbatsov commented Nov 8, 2019

I was thinking of:

ClojureScript: 1.10.x-fdfd (this can be different from the Clojure version)
ClojureScript REPL flavour: ...
ClojureScript REPL init form: ...

Or something along those lines. Similar to the info you get on top of the REPL. I guess it's easy to infer what's the flavour based on the form, but it might look nicer for the users.

I was envisioning making sure it was clear how a repl is started. If someone is not using jack-in commands then it is already clear to them how it was started.

Fair point. I guess the ClojureScript info, however, can always be displayed as we always upgrade a Clojure REPL and you can't really connect to a ClojureScript session.

@dpsutton
Copy link
Contributor Author

dpsutton commented Nov 8, 2019

image

I've added the cljs repl type and done a bit of formatting so that its grouped. The only thing that is missing would be perhaps the clojurescript version and i guess the node version if running on node. I think these present a pretty annoying problem.

  1. The other information appears at the top of the repl. The clojurescript version can't easily be gotten right now. nrepl provides some info in the describe op for clojure and nrepl, and cider-nrepl adds the cider-nrepl version. I see there's cljs.util/*clojurescript-version* that can be looked at but without nrepl support it will come back as edn rather than an nrepl dict.

@bbatsov
Copy link
Member

bbatsov commented Nov 12, 2019

I guess we can have either the cider-nrepl version middleware return them on use the aux attribute of nREPL's own describe. There we can stuff whatever data we want to quite easily.

@bbatsov
Copy link
Member

bbatsov commented Nov 16, 2019

@dpsutton One more thing - I notice that something's weird with the REPL prompt in your example. First there's the shadow.user prompt that's not on its own line, then the prompt changes to cljs.user. I guess you might have changed this explicitly, but I wanted to make sure the init is not messed up somehow.

@@ -333,6 +334,28 @@ fully initialized."
(insert-before-markers
(propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face))))

(defun cider-repl--insert-startup-commands ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit more about this and I'd prefer to split this in two - the jack-in command that gets displayed in the REPL banner if present and the ClojureScript details which can be placed/displayed as you've suggested. I just feel that the jack-in command is more fundamental than the ClojureScript form, that's why it should be listed more prominently. Potentially we can add there some info about the build system down the road - e.g. Leiningen 2.9, etc.

@bbatsov
Copy link
Member

bbatsov commented Nov 26, 2019

@dpsutton ping :-)

@dpsutton
Copy link
Contributor Author

image

If I understand correctly you mean something like this? The startup command is in the banner and the cljs stuff is lower and more in-line?

@dpsutton dpsutton force-pushed the show-startup-commands branch 3 times, most recently from 6a6bdf2 to 8aa19ff Compare November 28, 2019 00:18
@bbatsov
Copy link
Member

bbatsov commented Nov 28, 2019

Yeah, something like this. We just need some fallback for the jack-in command in case it's not present. Probably we can just move it to the very top and prepend it to the rest of the banner if needed.

cider-repl.el Outdated
@@ -333,6 +335,26 @@ fully initialized."
(insert-before-markers
(propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face))))

(defun cider-repl--insert-param-values (param-tuples)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't call this often, so I'd go with explicit params here. I think it's going to read much nicer.

@dpsutton
Copy link
Contributor Author

@bbatsov this should be what you are looking for if i understand you correctly. The startup command is now in the banner along with the other info and the cljs stuff is outside and grouped together

@dpsutton
Copy link
Contributor Author

image

CHANGELOG.md Outdated
* [#2499](https://github.com/clojure-emacs/cider/issues/2499): Add `cider-jump-to-pop-to-buffer-actions`.
* Show clj and cljs startup commands in repl buffer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've duplicated this in the changelog.

@@ -38,7 +70,8 @@
(spy-on 'cider--nrepl-version :and-return-value "0.5.3")
(setq nrepl-endpoint (list :host "localhost" :port "54018"))
(setq cider-version "0.12.0")
(setq cider-codename "Seattle"))
(setq cider-codename "Seattle")
(setq cider-saved-params (list :jack-in-cmd "startup command")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're not using this.

@@ -699,6 +699,7 @@ PARAMS is a plist as received by `cider-repl-create'."
(declare-function cider-repl-reset-markers "cider-repl")
(defvar-local cider-session-name nil)
(defvar-local cider-repl-init-function nil)
(defvar-local cider-saved-params nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd name this cider-launch-params or something like this.

cider-repl.el Outdated
(when (or cljs-repl-type cljs-init-form)
(emit-comment "")
(when cljs-repl-type
(emit-comment (concat "cljs repl type: " (symbol-name cljs-repl-type))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use ClojureScript REPL type: here.

cider-repl.el Outdated
(when cljs-repl-type
(emit-comment (concat "cljs repl type: " (symbol-name cljs-repl-type))))
(when cljs-init-form
(emit-comment (concat "cljs repl startup command: " cljs-init-form)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClojureScript REPL init form:

@bbatsov
Copy link
Member

bbatsov commented Nov 28, 2019

@dpsutton Looks good. I've added a couple of tiny cosmetic remarks and we're good to go.

@bbatsov bbatsov merged commit 71e737a into clojure-emacs:master Nov 29, 2019
@bbatsov
Copy link
Member

bbatsov commented Nov 29, 2019

Thanks for working on this! 🙇

@dpsutton
Copy link
Contributor Author

Thanks for the thorough checking of the code! much appreciated

@dpsutton dpsutton deleted the show-startup-commands branch January 27, 2021 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants