@@ -129,6 +129,12 @@ The error types are represented as strings."
129
129
:group 'cider-stacktrace
130
130
:package-version '(cider . " 0.6.0" ))
131
131
132
+ (defface cider-stacktrace-filter-positive-face
133
+ '((t (:inherit button :underline t :weight normal)))
134
+ " Face for filter buttons representing frames currently filtered out"
135
+ :group 'cider-stacktrace
136
+ :package-version '(cider . " 0.15.0" ))
137
+
132
138
(defface cider-stacktrace-face
133
139
'((t (:inherit default )))
134
140
" Face for stack frame text"
@@ -194,6 +200,7 @@ The error types are represented as strings."
194
200
(define-key map " r" #'cider-stacktrace-toggle-repl )
195
201
(define-key map " t" #'cider-stacktrace-toggle-tooling )
196
202
(define-key map " d" #'cider-stacktrace-toggle-duplicates )
203
+ (define-key map " p" #'cider-stacktrace-show-only-project )
197
204
(define-key map " a" #'cider-stacktrace-toggle-all )
198
205
(define-key map " 1" #'cider-stacktrace-cycle-cause-1 )
199
206
(define-key map " 2" #'cider-stacktrace-cycle-cause-2 )
@@ -224,6 +231,7 @@ The error types are represented as strings."
224
231
[" Show/hide REPL frames" cider-stacktrace-toggle-repl]
225
232
[" Show/hide tooling frames" cider-stacktrace-toggle-tooling]
226
233
[" Show/hide duplicate frames" cider-stacktrace-toggle-duplicates]
234
+ [" Show only project frames" cider-stacktrace-show-only-project]
227
235
[" Show/hide all frames" cider-stacktrace-toggle-all]))
228
236
map))
229
237
@@ -242,29 +250,34 @@ The error types are represented as strings."
242
250
243
251
; ; Stacktrace filtering
244
252
245
- (defun cider-stacktrace-indicate-filters (filters )
253
+ (defun cider-stacktrace--face-for-filter (filter neg-filters pos-filters )
254
+ " Return whether we should mark the filter is active or not."
255
+ (cond ((member filter neg-filters) 'cider-stacktrace-filter-hidden-face )
256
+ ((member filter pos-filters) 'cider-stacktrace-filter-positive-face )
257
+ ((member filter '(project)) 'cider-stacktrace-filter-hidden-face )
258
+ ((null filter) 'cider-stacktrace-filter-hidden-face )
259
+ (t 'cider-stacktrace-filter-shown-face )))
260
+
261
+ (defun cider-stacktrace-indicate-filters (filters pos-filters )
246
262
" Update enabled state of filter buttons.
247
263
248
264
Find buttons with a 'filter property; if filter is a member of FILTERS, or
249
265
if filter is nil ('show all') and the argument list is non-nil, fontify the
250
266
button as disabled. Upon finding text with a 'hidden-count property, stop
251
- searching and update the hidden count text."
267
+ searching and update the hidden count text. POS-FILTERS is the list of
268
+ positive filters to always include."
252
269
(with-current-buffer cider-error-buffer
253
270
(save-excursion
254
271
(goto-char (point-min ))
255
- (let ((inhibit-read-only t )
256
- (get-face (lambda (hide )
257
- (if hide
258
- 'cider-stacktrace-filter-hidden-face
259
- 'cider-stacktrace-filter-shown-face ))))
272
+ (let ((inhibit-read-only t ))
260
273
; ; Toggle buttons
261
274
(while (not (or (get-text-property (point ) 'hidden-count ) (eobp )))
262
275
(let ((button (button-at (point ))))
263
276
(when button
264
277
(let* ((filter (button-get button 'filter ))
265
- (face (funcall get- face ( if filter
266
- ( member filter filters)
267
- filters) )))
278
+ (face (cider-stacktrace-- face-for-filter filter
279
+ filters
280
+ pos- filters)))
268
281
(button-put button 'face face)))
269
282
(goto-char (or (next-property-change (point ))
270
283
(point-max )))))
@@ -465,6 +478,21 @@ When it reaches 3, it wraps to 0."
465
478
(cons flag cider-stacktrace-filters)))
466
479
cider-stacktrace-positive-filters))
467
480
481
+ (defun cider-stacktrace-show-only-project (&optional button )
482
+ " Display only the stackframes from the project.
483
+ BUTTON is the button at the top of the error buffer as the button calls
484
+ with the button."
485
+ (interactive )
486
+ (if (null cider-stacktrace-positive-filters)
487
+ (progn
488
+ (setq-local cider-stacktrace-prior-filters cider-stacktrace-filters)
489
+ (setq-local cider-stacktrace-filters '(java clj repl tooling dup))
490
+ (setq-local cider-stacktrace-positive-filters '(project)))
491
+ (progn
492
+ (setq-local cider-stacktrace-filters cider-stacktrace-prior-filters)
493
+ (setq-local cider-stacktrace-positive-filters nil )))
494
+ (cider-stacktrace-apply-filters cider-stacktrace-filters
495
+ cider-stacktrace-positive-filters))
468
496
469
497
(defun cider-stacktrace-toggle-java ()
470
498
" Toggle display of Java stack frames."
@@ -570,6 +598,13 @@ prompt and whether to use a new window. Similar to `cider-find-var'."
570
598
" Emit into BUFFER toggle buttons for each of the FILTERS."
571
599
(with-current-buffer buffer
572
600
(insert " Show: " )
601
+ (insert-text-button " Project-Only"
602
+ 'filter 'project
603
+ 'follow-link t
604
+ 'action 'cider-stacktrace-show-only-project
605
+ 'help-echo " Project frames only" )
606
+ (insert " " ) ; ; if you put the space after project-only the button
607
+ ; ; highlighting spills into the next button
573
608
(dolist (filter filters)
574
609
(insert-text-button (car filter)
575
610
'filter (cadr filter)
@@ -578,6 +613,7 @@ prompt and whether to use a new window. Similar to `cider-find-var'."
578
613
'help-echo (format " Toggle %s stack frames "
579
614
(car filter)))
580
615
(insert " " ))
616
+
581
617
(let ((hidden " (0 frames hidden)" ))
582
618
(put-text-property 0 (length hidden) 'hidden-count t hidden)
583
619
(insert " " hidden " \n " ))))
@@ -748,7 +784,6 @@ through the `cider-stacktrace-suppressed-errors' variable."
748
784
(cider-stacktrace-initialize causes)
749
785
(font-lock-refresh-defaults )))
750
786
751
-
752
787
(provide 'cider-stacktrace )
753
788
754
789
; ;; cider-stacktrace.el ends here
0 commit comments