87
87
RESPONSE is a message received form the nrepl describing the input
88
88
needed. It is expected to contain at least \" key\" , \" input-type\" , and
89
89
\" 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 )
91
91
(let ((input))
92
92
(unwind-protect
93
93
(setq input
@@ -97,7 +97,7 @@ needed. It is expected to contain at least \"key\", \"input-type\", and
97
97
((pred sequencep)
98
98
(when (and filename point)
99
99
(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 ))))
101
101
; ; No matter what, we want to send this request or the session will stay
102
102
; ; hanged.
103
103
(nrepl-send-request
@@ -107,16 +107,39 @@ needed. It is expected to contain at least \"key\", \"input-type\", and
107
107
" input" (or input " :quit" ))
108
108
#'ignore )))))
109
109
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 )
111
127
" Receive input from the user representing a command to do.
112
128
VALUE 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 => " )))
114
133
(cider--display-interactive-eval-result (or value " #unknown#" )))
115
134
(let ((alist `((?\C -\[ . " :quit" ) (?\C -g . " :quit" )
116
135
,@(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))))))
120
143
121
144
122
145
; ;; User commands
0 commit comments