Skip to content

Commit c6f463d

Browse files
yuhan0bbatsov
authored andcommitted
Add config for position of inline evaluation and debugger overlays
1 parent c3c903a commit c6f463d

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## master (unreleased)
44

5+
### New features
6+
* New configuration variable `cider-result-overlay-position` determining where debugger and inline eval result overlays should be displayed. Current options are 'at-eol and 'at-point.
7+
58
### Changes
69

710
* [#2711](https://github.com/clojure-emacs/cider/pull/2711): `cider-selector` has more robust handling for edge cases.

cider-overlays.el

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,27 @@ font-locking it."
5959

6060
(defcustom cider-use-overlays 'both
6161
"Whether to display evaluation results with overlays.
62-
If t, use overlays. If nil, display on the echo area. If both, display on
63-
both places.
62+
If t, use overlays determined by `cider-result-overlay-position'.
63+
If nil, display on the echo area.
64+
If both, display on both places.
6465
6566
Only applies to evaluation commands. To configure the debugger overlays,
6667
see `cider-debug-use-overlays'."
67-
:type '(choice (const :tag "End of line" t)
68-
(const :tag "Bottom of screen" nil)
68+
:type '(choice (const :tag "Display using overlays" t)
69+
(const :tag "Display in echo area" nil)
6970
(const :tag "Both" both))
7071
:group 'cider
7172
:package-version '(cider . "0.10.0"))
7273

74+
(defcustom cider-result-overlay-position 'at-eol
75+
"Where to display result overlays for inline evaluation and the debugger.
76+
If 'at-eol, display at the end of the line.
77+
If 'at-point, display at the end of the respective sexp."
78+
:group 'cider
79+
:type ''(choice (const :tag "End of line" at-eol)
80+
(const :tag "End of sexp" at-point))
81+
:package-version '(cider . "0.22.1"))
82+
7383
(defcustom cider-eval-result-prefix "=> "
7484
"The prefix displayed in the minibuffer before a result value."
7585
:type 'string
@@ -156,21 +166,19 @@ END is the position where the sexp ends, and defaults to point."
156166
(format (concat " " cider-eval-result-prefix "%s "))
157167
(prepend-face 'cider-result-overlay-face)
158168
&allow-other-keys)
159-
"Place an overlay displaying VALUE at the end of line.
169+
"Place an overlay displaying VALUE at the position determined by WHERE.
160170
VALUE is used as the overlay's after-string property, meaning it is
161-
displayed at the end of the overlay. The overlay itself is placed from
162-
beginning to end of current line.
171+
displayed at the end of the overlay.
163172
Return nil if the overlay was not placed or if it might not be visible, and
164173
return the overlay otherwise.
165174
166175
Return the overlay if it was placed successfully, and nil if it failed.
167176
168177
This function takes some optional keyword arguments:
169178
170-
If WHERE is a number or a marker, apply the overlay over
171-
the entire line at that place (defaulting to `point'). If
172-
it is a cons cell, the car and cdr determine the start and
173-
end of the overlay.
179+
If WHERE is a number or a marker, apply the overlay as determined by
180+
`cider-result-overlay-position'. If it is a cons cell, the car and cdr
181+
determine the start and end of the overlay.
174182
DURATION takes the same possible values as the
175183
`cider-eval-result-duration' variable.
176184
TYPE is passed to `cider--make-overlay' (defaults to `result').
@@ -200,7 +208,9 @@ overlay."
200208
(point))))
201209
(end (if (consp where)
202210
(cdr where)
203-
(line-end-position)))
211+
(pcase cider-result-overlay-position
212+
('at-eol (line-end-position))
213+
('at-point (point)))))
204214
(display-string (format format value))
205215
(o nil))
206216
(remove-overlays beg end 'category type)

0 commit comments

Comments
 (0)