File tree 3 files changed +38
-0
lines changed
Filter options
3 files changed +38
-0
lines changed
Original file line number Diff line number Diff line change 2
2
3
3
## master (unreleased)
4
4
5
+ ### New features
6
+
7
+ * [ #190 ] ( https://github.com/clojure-emacs/inf-clojure/pull/190 ) : Helper function ` inf-clojure-set-repl ` to select inf-clojure process buffer.
8
+
5
9
### Bugs fixed
6
10
7
11
* [ #152 ] ( https://github.com/clojure-emacs/inf-clojure/issues/152 ) : Sanitize should only remove whitespace at the end of a command.
Original file line number Diff line number Diff line change @@ -316,6 +316,17 @@ one process, this does the right thing. If you run multiple
316
316
processes, you might need to change ` inf-clojure-buffer ` to
317
317
whichever process buffer you want to use.
318
318
319
+ You can use the helpful function ` inf-clojure-set-repl ` . If called in
320
+ an inf-clojure repl buffer, it will assign that buffer as the current
321
+ connection (` (setq inf-clojure-buffer (current-buffer) ` ). If you are
322
+ not in an inf-clojure repl buffer, it will offer a choice of
323
+ acceptable buffers to set as the repl buffer. If called with a prefix,
324
+ it will always give the list even if you are currently in an
325
+ acceptable repl buffer. Renaming buffers will greatly improve the
326
+ functionality of this list; the list "project-1: clojure repl",
327
+ "project-2: cljs repl" is far more understandable than "inf-clojure",
328
+ "inf-clojure<2>".
329
+
319
330
#### REPL Type
320
331
321
332
An ` inf-clojure ` REPL has an associated type. The available types can be
Original file line number Diff line number Diff line change @@ -199,6 +199,29 @@ has been found. See also variable `inf-clojure-buffer'."
199
199
(unless no-error
200
200
(error " No Clojure subprocess; see variable `inf-clojure-buffer' " ))))
201
201
202
+ (defun inf-clojure-set-repl (always-ask )
203
+ " Set an inf clojure buffer as the active repl.
204
+ If in a repl already, use that unless a prefix is used (or
205
+ ALWAYS-ASK). Otherwise get a list of all active inf-clojure
206
+ repls and offer a choice. Recommended to rename buffers as they
207
+ are created with `rename-buffer`."
208
+ (interactive " P" )
209
+ (cl-flet ((inf-clojure-repl-p () (and (derived-mode-p 'inf-clojure-mode )
210
+ (get-buffer-process (current-buffer ))
211
+ (process-live-p (get-buffer-process (current-buffer ))))))
212
+ (if (and (not always-ask)
213
+ (inf-clojure-repl-p))
214
+ (setq inf-clojure-buffer (current-buffer ))
215
+ (let (repl-buffers)
216
+ (dolist (b (buffer-list ))
217
+ (with-current-buffer b
218
+ (when (inf-clojure-repl-p)
219
+ (push (buffer-name b) repl-buffers))))
220
+ (if (> (length repl-buffers) 0 )
221
+ (when-let ((repl-buffer (completing-read " Use for repl: " repl-buffers nil t )))
222
+ (setq inf-clojure-buffer (get-buffer repl-buffer)))
223
+ (user-error " No buffers have an inf-clojure process" ))))))
224
+
202
225
(defvar-local inf-clojure-repl-type nil
203
226
" Symbol to define your REPL type.
204
227
Its root binding is nil and it can be further customized using
You can’t perform that action at this time.
0 commit comments