diff options
-rw-r--r-- | cider-interaction.el | 21 | ||||
-rw-r--r-- | cider-overlays.el | 32 |
2 files changed, 43 insertions, 10 deletions
diff --git a/cider-interaction.el b/cider-interaction.el index ece0b6f5..d4db5da0 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -1117,16 +1117,17 @@ Print its value into the current buffer." With DEBUG-IT prefix argument, also debug the entire form as with the command `cider-debug-defun-at-point'." (interactive "P") - (when (and debug-it (derived-mode-p 'clojurescript-mode)) - (when (y-or-n-p (concat "The debugger doesn't support ClojureScript yet, and we need help with that." - " \nWould you like to read the Feature Request?")) - (browse-url "https://github.com/clojure-emacs/cider/issues/1416")) - (user-error "The debugger does not support ClojureScript")) - (cider-interactive-eval - (concat (if debug-it "#dbg\n") - (cider-defun-at-point)) - nil - (cider-defun-at-point 'bounds))) + (when debug-it + (when (derived-mode-p 'clojurescript-mode) + (when (y-or-n-p (concat "The debugger doesn't support ClojureScript yet, and we need help with that." + " \nWould you like to read the Feature Request?")) + (browse-url "https://github.com/clojure-emacs/cider/issues/1416")) + (user-error "The debugger does not support ClojureScript")) + (save-excursion + (goto-char (car (cider-defun-at-point 'bounds))) + (insert-button "#dbg" :type 'cider-fragile) + (insert "\n"))) + (cider-interactive-eval nil nil (cider-defun-at-point 'bounds))) (defun cider-pprint-eval-defun-at-point () "Evaluate the \"top-level\" form at point and pprint its value in a popup buffer." 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 |