diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-03-06 14:40:59 -0300 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-03-06 14:48:11 -0300 |
commit | 2d4a0d84479e6009b1d40a15b2515017aaea1668 (patch) | |
tree | 2fc56540cdb02d4029d6467f78a9562d61e4a51a /cider-overlays.el | |
parent | 3d211d62df954dd9c6d8344d2df7d10819bbff00 (diff) |
C-u C-M-x now inserts a literal #dbg into the buffer
This #dbg is covered in a fragile overlay. This means hitting RET or
deleting any char in it deletes the whole thing.
Related to #1591
Diffstat (limited to 'cider-overlays.el')
-rw-r--r-- | cider-overlays.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cider-overlays.el b/cider-overlays.el index f7599eb6..06370840 100644 --- a/cider-overlays.el +++ b/cider-overlays.el @@ -227,5 +227,37 @@ focused." 'invisible (and used-overlay (not (eq cider-use-overlays 'both))))))) + +;;; Fragile buttons +(defface cider-fragile-button-face + '((((type graphic)) + :box (:line-width 2 :style released-button) + :inherit cider-result-overlay-face) + (t :inverse-video t)) + "Face for buttons that vanish when clicked." + :package-version '(cider . "0.12.0") + :group 'cider) + +(define-button-type 'cider-fragile + 'action 'cider--overlay-destroy + 'follow-link t + 'face 'cider-fragile-button-face + 'modification-hooks '(cider--overlay-destroy) + 'help-echo "RET: delete this.") + +(defun cider--overlay-destroy (x &rest r) + "Delete overlay X and its underlying text. +If any other arguments are given, only actually do anything if the first +one is non-nil. This is so it works in `modification-hooks'." + (unless (and r (not (car r))) + (let ((inhibit-modification-hooks t) + (beg (copy-marker (overlay-start x))) + (end (copy-marker (overlay-end x)))) + (delete-overlay x) + (delete-region beg end) + (goto-char beg) + (when (= (char-after) (char-before) ?\n) + (delete-char 1))))) + (provide 'cider-overlays) ;;; cider-overlays.el ends here |