From 4798d58df779414416596c2a15c18083c68a7a1f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 30 Oct 2015 20:11:02 +0000 Subject: When using a temp debug buffer, explain what the user did wrong --- cider-debug.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'cider-debug.el') diff --git a/cider-debug.el b/cider-debug.el index c995426c..c4e52aee 100644 --- a/cider-debug.el +++ b/cider-debug.el @@ -387,9 +387,10 @@ specific message." (defun cider--debug-trim-code (code) (replace-regexp-in-string "\\`#\\(dbg\\|break\\) ?" "" code)) -(defun cider--initialize-debug-buffer (code ns id) +(defun cider--initialize-debug-buffer (code ns id &optional reason) "Create a new debugging buffer with CODE and namespace NS. -ID is the id of the message that instrumented CODE." +ID is the id of the message that instrumented CODE. +REASON is a keyword describing why this buffer was necessary." (let ((buffer-name (format cider--debug-buffer-format id))) (if-let ((buffer (get-buffer buffer-name))) (cider-popup-buffer-display buffer 'select) @@ -400,8 +401,12 @@ ID is the id of the message that instrumented CODE." (let ((inhibit-read-only t) (buffer-undo-list t)) (erase-buffer) - (insert - (format "%s" (cider--debug-trim-code code))) + (insert (format "%s" (cider--debug-trim-code code))) + (when code + (insert "\n\n\n;; We had to create this temporary buffer because we couldn't find the original definition. That probably happened because " + reason + ".") + (fill-paragraph)) (cider--font-lock-ensure) (set-buffer-modified-p nil)))) (switch-to-buffer buffer-name) @@ -514,7 +519,11 @@ needed. It is expected to contain at least \"key\", \"input-type\", and ;; But we can create a temp buffer if that fails. (unless (or (looking-at-p (regexp-quote code)) (looking-at-p (regexp-quote (cider--debug-trim-code code)))) - (cider--initialize-debug-buffer code ns original-id)) + (cider--initialize-debug-buffer + code ns original-id + (if (and line column) + "you edited the code" + "your tools.nrepl version is older than 0.2.11"))) (cider--debug-move-point coor)) ;; The overlay code relies on window boundaries, but point could have been ;; moved outside the window by some other code. Redisplay here to ensure the -- cgit v1.2.3