Skip to content
Merged
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@ 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")
(let ((new-repl-buffer
(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 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-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.

(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))
(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