[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-clojure 91145b0 293/313: Function to select repls as t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-clojure 91145b0 293/313: Function to select repls as the current active connection |
Date: |
Wed, 11 Aug 2021 10:00:36 -0400 (EDT) |
branch: elpa/inf-clojure
commit 91145b034ba083afe76471ea5598a912862ae7a1
Author: dan sutton <dan@dpsutton.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Function to select repls as the current active connection
very simple: if in a repl, use that. if not in a repl, display a list
of inf-clojure process buffers. If given a prefix, always show a list.
Makes running simultaneous repls far easier
---
CHANGELOG.md | 4 ++++
README.md | 11 +++++++++++
inf-clojure.el | 23 +++++++++++++++++++++++
3 files changed, 38 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6aaafd4..56dc45a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## master (unreleased)
+### New features
+
+* [#190](https://github.com/clojure-emacs/inf-clojure/pull/190): Helper
function `inf-clojure-set-repl` to select inf-clojure process buffer.
+
### Bugs fixed
* [#152](https://github.com/clojure-emacs/inf-clojure/issues/152): Sanitize
should only remove whitespace at the end of a command.
diff --git a/README.md b/README.md
index d9c38aa..6bf9fca 100644
--- a/README.md
+++ b/README.md
@@ -316,6 +316,17 @@ one process, this does the right thing. If you run
multiple
processes, you might need to change `inf-clojure-buffer` to
whichever process buffer you want to use.
+You can use the helpful function `inf-clojure-set-repl`. If called in
+an inf-clojure repl buffer, it will assign that buffer as the current
+connection (`(setq inf-clojure-buffer (current-buffer)`). If you are
+not in an inf-clojure repl buffer, it will offer a choice of
+acceptable buffers to set as the repl buffer. If called with a prefix,
+it will always give the list even if you are currently in an
+acceptable repl buffer. Renaming buffers will greatly improve the
+functionality of this list; the list "project-1: clojure repl",
+"project-2: cljs repl" is far more understandable than "inf-clojure",
+"inf-clojure<2>".
+
#### REPL Type
An `inf-clojure` REPL has an associated type. The available types can be
diff --git a/inf-clojure.el b/inf-clojure.el
index 3832799..25457b5 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -199,6 +199,29 @@ has been found. See also variable `inf-clojure-buffer'."
(unless no-error
(error "No Clojure subprocess; see variable `inf-clojure-buffer'"))))
+(defun inf-clojure-set-repl (always-ask)
+ "Set an inf clojure buffer as the active repl.
+If in a repl 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. Recommended to rename buffers as they
+are created with `rename-buffer`."
+ (interactive "P")
+ (cl-flet ((inf-clojure-repl-p () (and (derived-mode-p 'inf-clojure-mode)
+ (get-buffer-process (current-buffer))
+ (process-live-p (get-buffer-process
(current-buffer))))))
+ (if (and (not always-ask)
+ (inf-clojure-repl-p))
+ (setq inf-clojure-buffer (current-buffer))
+ (let (repl-buffers)
+ (dolist (b (buffer-list))
+ (with-current-buffer b
+ (when (inf-clojure-repl-p)
+ (push (buffer-name b) repl-buffers))))
+ (if (> (length repl-buffers) 0)
+ (when-let ((repl-buffer (completing-read "Use for repl: "
repl-buffers nil t)))
+ (setq inf-clojure-buffer (get-buffer repl-buffer)))
+ (user-error "No buffers have an inf-clojure process"))))))
+
(defvar-local inf-clojure-repl-type nil
"Symbol to define your REPL type.
Its root binding is nil and it can be further customized using
- [nongnu] elpa/inf-clojure 7a5b32f 238/313: Extend a bit the README, (continued)
- [nongnu] elpa/inf-clojure 7a5b32f 238/313: Extend a bit the README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 30638a0 242/313: Remove old defcustomed, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 1bac8fe 249/313: Tweak some messages, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure f1c8323 261/313: Fix some wording, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 23492b5 263/313: Trim some whitespace, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 8be9cec 269/313: Use kbd-style keybindings everywhere, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 68ab0f7 282/313: Bump the required Emacs version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 81e0912 287/313: Tweak some features, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 675e9be 290/313: Handle newlines between forms for `inf-clojure-eval-buffer`, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b601d48 266/313: Tweak the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 91145b0 293/313: Function to select repls as the current active connection,
ELPA Syncer <=
- [nongnu] elpa/inf-clojure d79e4eb 299/313: Remove a redundant call to with-current-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 397272d 300/313: Auto-enable inf-clojure-minor-mode on starting inf-clojure, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 07b2738 301/313: Include the project name automatically in the REPL buffer name, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c3ff2f4 308/313: Add a note about comint, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 37cfe85 307/313: Update some wording, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 696e5ef 309/313: Add a link to Discord, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 49b2257 310/313: Remove the TOC, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure fcf30b5 210/313: README: Add instructions for including socket config in .dir-locals.el or .emacs., ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b53074a 216/313: Tweak README and discourage terminal REPLs, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure e14dbba 145/313: Update the commentary section of the package, ELPA Syncer, 2021/08/11