[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 9961fc9434 2/2: Introduce `cider-inspector-preferred
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 9961fc9434 2/2: Introduce `cider-inspector-preferred-var-names` (#3483) |
Date: |
Sat, 30 Sep 2023 03:59:58 -0400 (EDT) |
branch: elpa/cider
commit 9961fc9434eebdfb6557e50b9616919bd74e644f
Author: vemv <vemv@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Introduce `cider-inspector-preferred-var-names` (#3483)
---
CHANGELOG.md | 1 +
cider-inspector.el | 22 +++++++++++++++++++++-
doc/modules/ROOT/pages/debugging/inspector.adoc | 10 +++++++++-
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29d0ad47b8..ee8bcccb8e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,6 +53,7 @@
- [#3419](https://github.com/clojure-emacs/cider/issues/3419): Also match
friendly sessions based on the buffer's ns form.
- Always match friendly sessions for `cider-ancillary-buffers` (like
`*cider-error*`, `*cider-result*`, etc).
- `cider-test`: only show diffs for collections.
+- `cider-inspector-def-current-val` now can suggest a var name (default none),
which can be customized via `cider-inspector-preferred-var-names`.
- [#3375](https://github.com/clojure-emacs/cider/pull/3375): `cider-test`:
don't render a newline between expected and actual, most times.
- Ensure there's a leading `:` when using `cider-clojure-cli-aliases`.
- Improve `nrepl-dict` error reporting.
diff --git a/cider-inspector.el b/cider-inspector.el
index 085e4026fa..744e0d9547 100644
--- a/cider-inspector.el
+++ b/cider-inspector.el
@@ -274,13 +274,33 @@ MAX-SIZE is the new value."
(when-let ((value (cider-sync-request:inspect-set-max-coll-size max-size)))
(cider-inspector--render-value value)))
+(defcustom cider-inspector-preferred-var-names nil
+ "The preferred var names to be suggested by
`cider-inspector-def-current-val'.
+
+If you choose a different one while completing interactively,
+it will be included (in the first position) the next time
+you use `cider-inspector-def-current-val'."
+ :type '(repeat string)
+ :group 'cider
+ :package-version '(cider . "1.8.0"))
+
+(defun cider-inspector--read-var-name-from-user (ns)
+ "Reads a var name from the user, to be defined within NS.
+Grows `cider-inspector-preferred-var-names' if the user chose a new name,
+making that new name take precedence for subsequent usages."
+ (let ((v (completing-read (format "Name of the var to be defined in ns %s: "
ns)
+ cider-inspector-preferred-var-names)))
+ (unless (member v cider-inspector-preferred-var-names)
+ (setq cider-inspector-preferred-var-names (cons v
cider-inspector-preferred-var-names)))
+ v))
+
(defun cider-inspector-def-current-val (var-name ns)
"Defines a var with VAR-NAME in current namespace.
Doesn't modify current page. When called interactively NS defaults to
current-namespace."
(interactive (let ((ns (cider-current-ns)))
- (list (read-from-minibuffer (concat "Var name: " ns "/"))
+ (list (cider-inspector--read-var-name-from-user ns)
ns)))
(setq cider-inspector--current-repl (cider-current-repl))
(when-let* ((value (cider-sync-request:inspect-def-current-val ns var-name)))
diff --git a/doc/modules/ROOT/pages/debugging/inspector.adoc
b/doc/modules/ROOT/pages/debugging/inspector.adoc
index c326f73e46..43bf0a1980 100644
--- a/doc/modules/ROOT/pages/debugging/inspector.adoc
+++ b/doc/modules/ROOT/pages/debugging/inspector.adoc
@@ -59,7 +59,9 @@ You'll have access to additional keybindings in the inspector
buffer
| Set a new maximum length above which nested atoms (non-collections) are
truncated
| kbd:[d]
-| Defines a var in the REPL namespace with current inspector value
+| Defines a var in the REPL namespace with current inspector value.
+| If you tend to always choose the same name,
+| you way want to set the `cider-inspector-preferred-var-names` customization
option.
|===
== Configuration
@@ -80,6 +82,12 @@ inspector buffer using the `s`, `c`, and `a` keybindings.
If you enable `cider-inspector-fill-frame`, the inspector window fills its
frame.
+Starting from CIDER 1.8.0, when you define a var using kbd:[d],
+a var name can be suggested (default none). You can customize this value
+via the `cider-inspector-preferred-var-names` configuration option.
+Even after setting it, you are free to choose new names on the fly,
+as you type. Most recent names will take priority in subsequent usages.
+
== Additional Resources
*
https://practicalli.github.io/spacemacs/evaluating-clojure/inspect.html[Using
CIDER's Inspector in Spacemacs]