Skip to content

Display message after setting repl #208

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

Merged
merged 3 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* [#208](https://github.com/clojure-emacs/inf-clojure/pull/208) Display message after setting repl.


## 3.2.1 (2022-07-22)
Expand Down
13 changes: 8 additions & 5 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,15 @@ buffers after they are created with `rename-buffer'."
(interactive "P")
(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-repl-p))
(setq inf-clojure-buffer (current-buffer))
(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.

(let ((repl-buffers (inf-clojure-repls)))
(if (> (length repl-buffers) 0)
(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")))))
(if (> (length repl-buffers) 0)
(when-let ((repl-buffer (completing-read "Select default REPL: " repl-buffers nil t)))
(setq inf-clojure-buffer (get-buffer repl-buffer))
(message "Current inf-clojure REPL set to %s" inf-clojure-buffer))
(user-error "No buffers have an inf-clojure process")))))

(defvar inf-clojure--repl-type-lock nil
"Global lock for protecting against proc filter race conditions.
Expand Down