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 all 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
25 changes: 17 additions & 8 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,30 @@ Checks the mode and that there is a live process."
(push (buffer-name b) repl-buffers)))
repl-buffers))

(defun inf-clojure--prompt-repl-buffer (prompt)
"Prompt the user to select an inf-clojure repl buffer.
PROMPT is a string to prompt the user.
Returns nil when no buffer is selected."
(let ((repl-buffers (inf-clojure-repls)))
(if (> (length repl-buffers) 0)
(when-let ((repl-buffer (completing-read prompt repl-buffers nil t)))
(get-buffer repl-buffer))
(user-error "No buffers have an inf-clojure process"))))

(defun inf-clojure-set-repl (always-ask)
"Set an inf-clojure buffer as the active (default) REPL.
If in a REPL buffer already, use that unless a prefix is used (or
ALWAYS-ASK). Otherwise get a list of all active inf-clojure
REPLS and offer a choice. It's recommended to rename REPL
buffers after they are created with `rename-buffer'."
(interactive "P")
(if (and (not always-ask)
(inf-clojure-repl-p))
(setq inf-clojure-buffer (current-buffer))
(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")))))
(when-let ((new-repl-buffer
(if (or always-ask
(not (inf-clojure-repl-p)))
(inf-clojure--prompt-repl-buffer "Select default REPL: ")
(current-buffer))))
(setq inf-clojure-buffer new-repl-buffer)
(message "Current inf-clojure REPL set to %s" new-repl-buffer)))

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