Skip to content

Display message after setting repl #208

New issue

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

By clicking “No 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? No Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2023

Conversation

jjttjj
Copy link
Contributor

@jjttjj jjttjj commented Feb 24, 2023

Displays a message after setting the repl.

When manually setting a repl with inf-clojure-set-repl, there is no visual indication that the repl has successfully been changed. This has confused me a few times in the past so I added a message.

This was briefly discussed on slack


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

Thanks!

inf-clojure.el Outdated
(when-let ((repl-buffer (completing-read "Select default REPL: " repl-buffers nil t)))
(setq inf-clojure-buffer (get-buffer repl-buffer)))
(user-error "No buffers have an inf-clojure process"))))
(message "inf-clojure repl set to %s" inf-clojure-buffer))
Copy link
Member

Choose a reason for hiding this comment

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

Probably it'd be better to use something like "Current/active inf-clojure REPL set to ...".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the input, I made the change!

@dpsutton
Copy link
Contributor

thanks for the addition. Great usability addition. Once you update to @bbatsov 's suggestion for the message we'll merge.

CHANGELOG.md Outdated
@@ -3,6 +3,7 @@
## master (unreleased)
* [#202](https://github.com/clojure-emacs/inf-clojure/issues/202): Add ClojureCLR support.
* [#204](https://github.com/clojure-emacs/inf-clojure/issues/204): Scroll repl buffer on insert commands
* Display message after setting repl.
Copy link
Contributor

Choose a reason for hiding this comment

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

you should add a link here

  • #208 Display message after setting repl with inf-clojure-set-repl

inf-clojure.el Outdated
(when-let ((repl-buffer (completing-read "Select default REPL: " repl-buffers nil t)))
(setq inf-clojure-buffer (get-buffer repl-buffer)))
(user-error "No buffers have an inf-clojure process"))))
(message "Current inf-clojure REPL set to %s" inf-clojure-buffer))
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should this message move this to be inside of the when-let which sets inf-clojure-buffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I missed that possible outcome.
I changed it to only display the message after a successful change. Not confident in my style choices here, I could also just repeat the call to message in both success branches separately, let me know if you have a preference.
https://github.com/jjttjj/inf-clojure/blob/04b967f1e60adb79cd84d580268f7af00021eb71/inf-clojure.el#L284-L294

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have any strong opinions. I lean towards having the message and the setq in the same body so they work in tandem. But it doesn't really matter.

inf-clojure.el Outdated
(user-error "No buffers have an inf-clojure process"))))))
(when new-repl-buffer
(message "Current inf-clojure REPL set to %s" new-repl-buffer))))
(if (and (not always-ask)
Copy link
Member

Choose a reason for hiding this comment

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

The nest ifs make it a bit hard to follow the code, so some comments at the beginning of each branch might be useful.

inf-clojure.el Outdated
(inf-clojure-repl-p))
(progn
(setq inf-clojure-buffer (current-buffer))
(message "Current inf-clojure REPL set to %s" inf-clojure-buffer))
Copy link
Member

Choose a reason for hiding this comment

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

To reduce this message duplication you can just return the new-repl buffer at the end and set it outside the ifs with a single message there. You can even the the code looking for the new repl to be a separate private function, so this would read a bit better. I'd prefer such less imperative code structure.

@jjttjj
Copy link
Contributor Author

jjttjj commented Feb 25, 2023

After trying a few arrangements, I went with extracting a function to just handle the "select repl" prompt. I believe this could also be reused to refactor this if you would like.
(Sorry if this little change has required a disproportionate amount of attention)

@bbatsov
Copy link
Member

bbatsov commented Feb 26, 2023

After trying a few arrangements, I went with extracting a function to just handle the "select repl" prompt. I believe this could also be reused to refactor this if you would like.

Yeah, it'd be nice to remove the code duplication, so a follow-up PR will be appreciated.

(Sorry if this little change has required a disproportionate amount of attention)

No worries! The code is better in the end and that is all that matters.

@bbatsov bbatsov merged commit fb9b5ea into clojure-emacs:master Feb 26, 2023
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants