diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-03-20 18:43:28 -0300 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-03-20 20:16:06 -0300 |
commit | b6d961420d7a2c68fc6c0a6b98f8e075243caf29 (patch) | |
tree | 7ac5b508a7d5abd93527afb511dac0e073154515 | |
parent | 862332a381ffba7c943f17b1b6817ce872bad0b7 (diff) |
Only use buttons for debugging when inlined
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cider-interaction.el | 47 | ||||
-rw-r--r-- | cider-overlays.el | 6 |
3 files changed, 40 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 75b33670..0e1ded4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Apropos commands now accept lists of space-separated words as arguments, in addition to regular expressions (similar to Emacs's own apropos commands). * [#1541](https://github.com/clojure-emacs/cider/issues/1541): New commands `cider-apropos-select` and `cider-apropos-documentation-select`. * New function `cider-expected-ns` is like `clojure-expected-ns`, but uses classpath for better results. See [clojure-mode#372](https://github.com/clojure-emacs/clojure-mode/issues/372). +* A double prefix argument (`C-u C-u`) for `cider-eval-defun-at-point` debugs the sexp at point instead of the entire defun, and offers to create a conditional breakpoint. ## 0.11.0 / 2016-03-03 diff --git a/cider-interaction.el b/cider-interaction.el index d4db5da0..73237d05 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -1112,22 +1112,47 @@ Print its value into the current buffer." (interactive) (cider--pprint-eval-form (cider-last-sexp 'bounds))) +(defun cider--prompt-and-insert-inline-dbg () + "Insert a #dbg button at the current sexp." + (save-excursion + (let ((beg)) + (skip-chars-forward "\r\n[:blank:]") + (unless (looking-at-p "(") + (ignore-errors (backward-up-list))) + (setq beg (point)) + (let* ((cond (cider-read-from-minibuffer "Condition for debugging (leave empty for \"always\"): ")) + (button (propertize (concat "#dbg" + (unless (equal cond "") + (format " ^{:break/when %s}" cond))) + 'font-lock-face 'cider-fragile-button-face))) + (when (> (current-column) 30) + (insert "\n") + (indent-according-to-mode)) + (insert button) + (when (> (current-column) 40) + (insert "\n") + (indent-according-to-mode))) + (make-button beg (point) + 'help-echo "Breakpoint. Reevaluate this form to remove it." + :type 'cider-fragile)))) + (defun cider-eval-defun-at-point (&optional debug-it) "Evaluate the current toplevel form, and print result in the minibuffer. With DEBUG-IT prefix argument, also debug the entire form as with the command `cider-debug-defun-at-point'." (interactive "P") - (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))) + (let ((inline-debug (eq 16 (car-safe debug-it)))) + (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")) + (when inline-debug + (cider--prompt-and-insert-inline-dbg))) + (cider-interactive-eval (when (and debug-it (not inline-debug)) + (concat "#dbg\n" (cider-defun-at-point))) + 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 1aba85d4..03606e18 100644 --- a/cider-overlays.el +++ b/cider-overlays.el @@ -231,8 +231,8 @@ focused." ;;; Fragile buttons (defface cider-fragile-button-face '((((type graphic)) - :box (:line-width 2 :style released-button) - :inherit cider-result-overlay-face) + :box (:line-width 3 :style released-button) + :inherit font-lock-warning-face) (t :inverse-video t)) "Face for buttons that vanish when clicked." :package-version '(cider . "0.12.0") @@ -241,7 +241,7 @@ focused." (define-button-type 'cider-fragile 'action 'cider--overlay-destroy 'follow-link t - 'face 'cider-fragile-button-face + 'face nil 'modification-hooks '(cider--overlay-destroy) 'help-echo "RET: delete this.") |