summaryrefslogtreecommitdiff
path: root/cider-debug.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-07-01 07:15:36 +0100
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-07-03 14:56:33 +0100
commitc66f5e2d9bdd82a7dae0dab364fc16a667d85e46 (patch)
tree604652caf982cd1b782eedc065e3c2e16d4a4ede /cider-debug.el
parentce1ce8ca1f2d46b1d4f705ae32dce45d1e4cd96f (diff)
Highlight instrumented definitions in each clojure buffer
Diffstat (limited to 'cider-debug.el')
-rw-r--r--cider-debug.el27
1 files changed, 25 insertions, 2 deletions
diff --git a/cider-debug.el b/cider-debug.el
index 11237cc7..26ec31ba 100644
--- a/cider-debug.el
+++ b/cider-debug.el
@@ -76,6 +76,27 @@ Possible values are inline, end-of-line, or nil."
;;; Implementation
+(defun cider--update-instrumented-defs (defs)
+ "Update which defs in current buffer are instrumented."
+ (remove-overlays nil nil 'cider-type 'instrumented-defs)
+ (save-excursion
+ (dolist (name defs)
+ (goto-char (point-min))
+ (when (search-forward-regexp
+ (format "(def.*\\s-\\(%s\\)" (regexp-quote name))
+ nil 'noerror)
+ (cider--make-overlay
+ (match-beginning 1) (match-end 1) 'instrumented-defs
+ 'face 'cider-instrumented-face)))))
+
+(defun cider--debug-handle-instrumented-defs (defs ns)
+ "Update display of NS according to instrumented DEFS."
+ (-when-let (buf (-first (lambda (b) (with-current-buffer b
+ (string= ns (cider-current-ns))))
+ (buffer-list)))
+ (with-current-buffer buf
+ (cider--update-instrumented-defs defs))))
+
(defun cider-browse-instrumented-defs ()
"List all instrumented definitions."
(interactive)
@@ -99,9 +120,11 @@ Possible values are inline, end-of-line, or nil."
(nrepl-send-request
'("op" "init-debugger")
(lambda (response)
- (nrepl-dbind-response response (status id)
+ (nrepl-dbind-response response (status id instrumented-defs ns)
(if (not (member "done" status))
- (cider--handle-debug response)
+ (if (member "instrumented-defs" response)
+ (cider--debug-handle-instrumented-defs instrumented-defs ns)
+ (cider--handle-debug response))
(puthash id (gethash id nrepl-pending-requests)
nrepl-completed-requests)
(remhash id nrepl-pending-requests))))))