Function: cider--make-result-overlay
cider--make-result-overlay is a byte-compiled function defined in
cider-overlays.el.
Signature
(cider--make-result-overlay VALUE &rest PROPS &key WHERE DURATION (TYPE 'result) (FORMAT (concat " " cider-eval-result-prefix "%s ")) (PREPEND-FACE 'cider-result-overlay-face) &allow-other-keys)
Documentation
Place an overlay displaying VALUE at the position determined by WHERE.
VALUE is used as the overlay's after-string property, meaning it is displayed at the end of the overlay. Return nil if the overlay was not placed or if it might not be visible, and return the overlay otherwise.
Return the overlay if it was placed successfully, and nil if it failed.
This function takes some optional keyword arguments:
If WHERE is a number or a marker, apply the overlay as determined by
cider-result-overlay-position. If it is a cons cell, the car and cdr
determine the start and end of the overlay.
DURATION takes the same possible values as the
cider-eval-result-duration variable.
TYPE is passed to cider--make-overlay (defaults to result).
FORMAT is a string passed to format. It should have
exactly one %s construct (for VALUE).
All arguments beyond these (PROPS) are properties to be used on the overlay.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-overlays.el
(cl-defun cider--make-result-overlay (value &rest props &key where duration (type 'result)
(format (concat " " cider-eval-result-prefix "%s "))
(prepend-face 'cider-result-overlay-face)
&allow-other-keys)
"Place an overlay displaying VALUE at the position determined by WHERE.
VALUE is used as the overlay's after-string property, meaning it is
displayed at the end of the overlay.
Return nil if the overlay was not placed or if it might not be visible, and
return the overlay otherwise.
Return the overlay if it was placed successfully, and nil if it failed.
This function takes some optional keyword arguments:
If WHERE is a number or a marker, apply the overlay as determined by
`cider-result-overlay-position'. If it is a cons cell, the car and cdr
determine the start and end of the overlay.
DURATION takes the same possible values as the
`cider-eval-result-duration' variable.
TYPE is passed to `cider--make-overlay' (defaults to `result').
FORMAT is a string passed to `format'. It should have
exactly one %s construct (for VALUE).
All arguments beyond these (PROPS) are properties to be used on the
overlay."
(declare (indent 1))
(while (keywordp (car props))
(setq props (cdr (cdr props))))
;; If the marker points to a dead buffer, don't do anything.
(let ((buffer (cond
((markerp where) (marker-buffer where))
((markerp (car-safe where)) (marker-buffer (car where)))
(t (current-buffer)))))
(with-current-buffer buffer
(save-excursion
(when (number-or-marker-p where)
(goto-char where))
;; Make sure the overlay is actually at the end of the sexp.
(skip-chars-backward "\r\n[:blank:]")
(let* ((beg (if (consp where)
(car where)
(save-excursion
(clojure-backward-logical-sexp 1)
(point))))
(end (if (consp where)
(cdr where)
(pcase cider-result-overlay-position
('at-eol (line-end-position))
('at-point (point)))))
;; Specify `default' face, otherwise unformatted text will
;; inherit the face of the following text.
(display-string (format (propertize format 'face 'default) value))
;; Maximum value width at which we truncate it.
(truncation-threshold (* 3 (window-width)))
(o nil))
;; Remove any overlay at the position we're creating a new one, if it
;; exists.
(remove-overlays beg end 'category type)
(funcall (if cider-overlays-use-font-lock
#'font-lock-prepend-text-property
#'put-text-property)
0 (length display-string)
'face prepend-face
display-string)
;; If the display spans multiple lines or is very long, display it at
;; the beginning of the next line.
(when (or (string-match "\n." display-string)
;; string-width can be very slow on large results, so check
;; with a cheaper predicate first. Conservatively limit to
;; truncation threshold.
(> (length display-string) truncation-threshold)
(> (string-width display-string)
(- (window-width) (current-column))))
(setq display-string (concat " \n" display-string)))
(when (or (> (length display-string) truncation-threshold)
(> (string-width display-string) truncation-threshold))
(setq display-string
(concat (substring display-string 0 truncation-threshold)
(substitute-command-keys
"...\nResult truncated. Type `\\[cider-inspect-last-result]' to inspect it."))))
;; Put the cursor property only once we're done manipulating the
;; string, since we want it to be at the first char.
(put-text-property 0 1 'cursor 0 display-string)
;; Create the result overlay.
(setq o (apply #'cider--make-overlay
beg end type
'after-string display-string
props))
(pcase duration
((pred numberp) (run-at-time duration nil #'cider--delete-overlay o))
(`command
;; Since the previous overlay was already removed above, we should
;; remove the hook to remove all overlays after this function
;; ends. Otherwise, we would inadvertently remove the newly created
;; overlay too.
(remove-hook 'post-command-hook 'cider--remove-result-overlay 'local)
;; If inside a command-loop, tell `cider--remove-result-overlay'
;; to only remove after the *next* command.
(if this-command
(add-hook 'post-command-hook
#'cider--remove-result-overlay-after-command
nil 'local)
(cider--remove-result-overlay-after-command)))
(`change
(add-hook 'after-change-functions
#'cider--remove-result-overlay
nil 'local)))
(when-let* ((win (get-buffer-window buffer)))
;; Left edge is visible.
(when (and (<= (window-start win) (point) (window-end win))
;; Right edge is visible. This is a little conservative
;; if the overlay contains line breaks.
(or (< (+ (current-column) (string-width display-string))
(window-width win))
(not truncate-lines)))
o)))))))