8787RESPONSE is a message received form the nrepl describing the input
8888needed. It is expected to contain at least \" key\" , \" input-type\" , and
8989\" prompt\" , and possibly other entries depending on the input-type."
90- (nrepl-dbind-response response (debug-value key coor filename point input-type prompt)
90+ (nrepl-dbind-response response (debug-value key coor filename point input-type prompt locals )
9191 (let ((input))
9292 (unwind-protect
9393 (setq input
@@ -97,7 +97,7 @@ needed. It is expected to contain at least \"key\", \"input-type\", and
9797 ((pred sequencep)
9898 (when (and filename point)
9999 (cider--debug-move-point filename point coor))
100- (cider--debug-read-command input-type debug-value prompt))))
100+ (cider--debug-read-command input-type debug-value prompt locals ))))
101101 ; ; No matter what, we want to send this request or the session will stay
102102 ; ; hanged.
103103 (nrepl-send-request
@@ -107,16 +107,39 @@ needed. It is expected to contain at least \"key\", \"input-type\", and
107107 " input" (or input " :quit" ))
108108 #'ignore )))))
109109
110- (defun cider--debug-read-command (command-list value prompt )
110+ (defvar cider--debug-display-locals nil
111+ " If non-nil, local variables are displayed while debugging.
112+ Can be toggled while debugging with `l' ." )
113+
114+ (defun cider--debug-format-locals-list (locals )
115+ " Return a string description of list LOCALS.
116+ Each element of LOCALS should be a list of at least two elements."
117+ (let ((left-col-width
118+ ; ; To right-indent the variable names.
119+ (apply #'max (mapcar (lambda (l ) (string-width (car l))) locals))))
120+ ; ; A format string to build a format string. :-P
121+ (mapconcat (lambda (l ) (format (format " %%%d s: %% s\n " left-col-width)
122+ (propertize (car l) 'face 'font-lock-variable-name-face )
123+ (cider-font-lock-as-clojure (cadr l))))
124+ locals " " )))
125+
126+ (defun cider--debug-read-command (command-list value prompt locals )
111127 " Receive input from the user representing a command to do.
112128VALUE is displayed to the user as the output of last evaluated sexp."
113- (let ((cider-interactive-eval-result-prefix (concat prompt " \n => " )))
129+ (let* ((prompt (concat (when cider--debug-display-locals
130+ (cider--debug-format-locals-list locals))
131+ prompt))
132+ (cider-interactive-eval-result-prefix (concat prompt " (l)ocals\n => " )))
114133 (cider--display-interactive-eval-result (or value " #unknown#" )))
115134 (let ((alist `((?\C -\[ . " :quit" ) (?\C -g . " :quit" )
116135 ,@(mapcar (lambda (k ) (cons (string-to-char k) (concat " :" k)))
117- command-list))))
118- (or (cdr (assq (read-char ) alist))
119- (cider--debug-read-command command-list value))))
136+ command-list)))
137+ (input (read-char )))
138+ (pcase input
139+ (?l (setq cider--debug-display-locals (not cider--debug-display-locals))
140+ (cider--debug-read-command command-list value prompt locals))
141+ (_ (or (cdr (assq input alist))
142+ (cider--debug-read-command command-list value prompt locals))))))
120143
121144
122145; ;; User commands
0 commit comments