[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider f556d30f68: Add option to remove result overlays aft
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider f556d30f68: Add option to remove result overlays after buffer change (#3149) |
Date: |
Fri, 11 Feb 2022 09:58:03 -0500 (EST) |
branch: elpa/cider
commit f556d30f687cbf20703ccda6f510254bdfa0cb9e
Author: yuhan0 <qythium@gmail.com>
Commit: GitHub <noreply@github.com>
Add option to remove result overlays after buffer change (#3149)
---
CHANGELOG.md | 1 +
cider-eval.el | 6 +++++-
cider-overlays.el | 24 +++++++++++++++++------
doc/modules/ROOT/pages/usage/code_evaluation.adoc | 18 +++++++++++++++++
4 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c39f6f0d49..a911fca758 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
* [#3127](https://github.com/clojure-emacs/cider/pull/3040): Strip all
exec-opts flags (`-A` `-M` `-T` `-X`) if they exist in
`cider-clojure-cli-aliases`. Also addresses a duplicate `:` in the generated
`clj` command.
* Enable `cider-enrich-classpath` by default.
* [#3148](https://github.com/clojure-emacs/cider/pull/3148): Display error
messages in multiline comment eval results, and in result overlays when
`cider-show-error-buffer` is set to nil.
+* [#3149](https://github.com/clojure-emacs/cider/pull/3149): Add option
`'change` to `cider-eval-result-duration`, allowing multiple eval result
overlays to persist until the next change to the buffer.
### Bugs fixed
diff --git a/cider-eval.el b/cider-eval.el
index 75c307de1c..e0f2e9a791 100644
--- a/cider-eval.el
+++ b/cider-eval.el
@@ -902,7 +902,11 @@ arguments and only proceed with evaluation if it returns
nil."
(start (car-safe bounds))
(end (car-safe (cdr-safe bounds))))
(when (and start end)
- (remove-overlays start end 'cider-temporary t))
+ ;; NOTE: don't use `remove-overlays' as it splits and leaves behind
+ ;; partial overlays, leading to duplicate eval results in some
situations.
+ (dolist (ov (overlays-in start end))
+ (when (eq (overlay-get ov 'cider-temporary) t)
+ (delete-overlay ov))))
(unless (and cider-interactive-eval-override
(functionp cider-interactive-eval-override)
(funcall cider-interactive-eval-override form callback
bounds))
diff --git a/cider-overlays.el b/cider-overlays.el
index 060a77b6c3..95788ad029 100644
--- a/cider-overlays.el
+++ b/cider-overlays.el
@@ -44,9 +44,11 @@ applied with lower priority than the syntax highlighting."
(defface cider-error-overlay-face
'((((class color) (background light))
- :background "orange red")
+ :background "orange red"
+ :extend t)
(((class color) (background dark))
- :background "firebrick"))
+ :background "firebrick"
+ :extend t))
"Like `cider-result-overlay-face', but for evaluation errors."
:group 'cider
:package-version '(cider "0.25.0"))
@@ -98,9 +100,11 @@ If 'at-point, display at the end of the respective sexp."
"Duration, in seconds, of CIDER's eval-result overlays.
If nil, overlays last indefinitely.
If the symbol `command', they're erased after the next command.
+If the symbol `change', they last until the next change to the buffer.
Also see `cider-use-overlays'."
:type '(choice (integer :tag "Duration in seconds")
(const :tag "Until next command" command)
+ (const :tag "Until next buffer change" change)
(const :tag "Last indefinitely" nil))
:group 'cider
:package-version '(cider . "0.10.0"))
@@ -125,10 +129,14 @@ PROPS is a plist of properties and values to add to the
overlay."
(push #'cider--delete-overlay (overlay-get o 'modification-hooks))
o))
-(defun cider--remove-result-overlay ()
+(defun cider--remove-result-overlay (&rest _)
"Remove result overlay from current buffer.
-This function also removes itself from `post-command-hook'."
- (remove-hook 'post-command-hook #'cider--remove-result-overlay 'local)
+This function also removes itself from `post-command-hook' and
+`after-change-functions'."
+ (let ((hook (pcase cider-eval-result-duration
+ (`command 'post-command-hook)
+ (`change 'after-change-functions))))
+ (remove-hook hook #'cider--remove-result-overlay 'local))
(remove-overlays nil nil 'category 'result))
(defun cider--remove-result-overlay-after-command ()
@@ -258,7 +266,11 @@ overlay."
(add-hook 'post-command-hook
#'cider--remove-result-overlay-after-command
nil 'local)
- (cider--remove-result-overlay-after-command))))
+ (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))
diff --git a/doc/modules/ROOT/pages/usage/code_evaluation.adoc
b/doc/modules/ROOT/pages/usage/code_evaluation.adoc
index b290772f30..8bb5532964 100644
--- a/doc/modules/ROOT/pages/usage/code_evaluation.adoc
+++ b/doc/modules/ROOT/pages/usage/code_evaluation.adoc
@@ -207,6 +207,24 @@ Note that this also affects the position of debugger
overlays.
(setq cider-result-overlay-position 'at-point)
----
+
+You can also customize how overlays are persisted using the variable
+`cider-eval-result-duration`.
+
+By default, its value is `'command`, meaning that result overlays disappear
+after the next user-executed command, such as moving the point or scrolling.
+
+Setting the variable to a number represents the duration in seconds until
+overlays are removed, while setting it to `'change' persists overlays until the
+next change to the buffer contents.
+
+
+[source,lisp]
+----
+(setq cider-eval-result-duration 5.0)
+(setq cider-eval-result-duration 'change)
+----
+
=== Auto-Save Clojure Buffers on Load
Normally, CIDER prompts you to save a modified Clojure buffer when you
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/cider f556d30f68: Add option to remove result overlays after buffer change (#3149),
ELPA Syncer <=