Skip to content

Commit 5854f3a

Browse files
Dan Suttonbbatsov
authored andcommitted
Make "project-only" button handler same as others
invoking function from button was not working the way I expected. It was not seeing new values for defvar's. Now it's called by the button handler and it is working correctly.
1 parent beb0035 commit 5854f3a

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

cider-stacktrace.el

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,21 @@ The error types are represented as strings."
244244

245245
;; Stacktrace filtering
246246

247+
(defvar cider-stacktrace--all-negative-filters
248+
'(clj tooling dup java repl)
249+
"Filters that remove stackframes")
250+
251+
(defvar cider-stacktrace--all-positive-filters
252+
'(project)
253+
"Filters that ensure stackframes are shown")
254+
247255
(defun cider-stacktrace--face-for-filter (filter neg-filters pos-filters)
248256
"Return whether we should mark the filter is active or not."
249-
(cond ((member filter '(clj java repl tooling dup)) ; negative filter
257+
(cond ((member filter cider-stacktrace--all-negative-filters)
250258
(if (member filter neg-filters)
251259
'cider-stacktrace-filter-active-face
252260
'cider-stacktrace-filter-inactive-face))
253-
((member filter '(project)) ; positive filter
261+
((member filter cider-stacktrace--all-positive-filters)
254262
(if (member filter pos-filters)
255263
'cider-stacktrace-filter-active-face
256264
'cider-stacktrace-filter-inactive-face))
@@ -479,15 +487,15 @@ When it reaches 3, it wraps to 0."
479487
(cons flag cider-stacktrace-filters)))
480488
cider-stacktrace-positive-filters))
481489

482-
(defun cider-stacktrace-show-only-project (&optional button)
490+
(defun cider-stacktrace-show-only-project ()
483491
"Display only the stackframes from the project.
484492
BUTTON is the button at the top of the error buffer as the button calls
485493
with the button."
486494
(interactive)
487495
(if (null cider-stacktrace-positive-filters)
488496
(progn
489497
(setq-local cider-stacktrace-prior-filters cider-stacktrace-filters)
490-
(setq-local cider-stacktrace-filters '(java clj repl tooling dup))
498+
(setq-local cider-stacktrace-filters cider-stacktrace-filters)
491499
(setq-local cider-stacktrace-positive-filters '(project)))
492500
(progn
493501
(setq-local cider-stacktrace-filters cider-stacktrace-prior-filters)
@@ -526,9 +534,11 @@ with the button."
526534
"Apply filter(s) indicated by the BUTTON."
527535
(with-temp-message "Filters may also be toggled with the keyboard."
528536
(let ((flag (button-get button 'filter)))
529-
(if flag
530-
(cider-stacktrace-toggle flag)
531-
(cider-stacktrace-toggle-all)))
537+
(cond ((member flag cider-stacktrace--all-negative-filters)
538+
(cider-stacktrace-toggle flag))
539+
((member flag cider-stacktrace--all-positive-filters)
540+
(cider-stacktrace-show-only-project))
541+
(t cider-stacktrace-toggle-all)))
532542
(sit-for 5)))
533543

534544
(defun cider-stacktrace-toggle-suppression (button)
@@ -603,7 +613,7 @@ prompt and whether to use a new window. Similar to `cider-find-var'."
603613
(insert-text-button (car filter)
604614
'filter (cadr filter)
605615
'follow-link t
606-
'action (or (nth 3 filter) 'cider-stacktrace-filter)
616+
'action 'cider-stacktrace-filter
607617
'help-echo (format "Toggle %s stack frames"
608618
(car filter)))
609619
(insert " "))
@@ -772,7 +782,7 @@ through the `cider-stacktrace-suppressed-errors' variable."
772782
;; Stacktrace filters
773783
(cider-stacktrace-render-filters
774784
buffer
775-
`(("Project-Only" project cider-stacktrace-show-only-project) ("All" ,nil))
785+
`(("Project-Only" project) ("All" ,nil))
776786
`(("Clojure" clj) ("Java" java) ("REPL" repl)
777787
("Tooling" tooling) ("Duplicates" dup)))
778788
(insert "\n")

0 commit comments

Comments
 (0)