Composable condition DSL for projectile-kill-buffers-filter#2015
Merged
Conversation
projectile-kill-buffers-filter could only be kill-all, kill-only-files, or a bare predicate. That's coarse compared to project.el, where project-kill-buffer-conditions lets you compose rules out of buffer-name regexps, mode checks, and boolean combinators. Teach the filter to also accept a list of such conditions: regexps, predicate functions, and (major-mode . M) / (derived-mode . M) / (not ...) / (and ...) / (or ...) forms, killing a buffer when it matches any of them. The matcher mirrors project.el's project--buffer-check. The existing symbol and predicate values keep working unchanged, so this is purely additive. The decision logic moves into a new projectile-buffer-killed-p predicate, which keeps projectile-kill-buffers tidy and is easy to test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
projectile-kill-buffers-filterwas limited tokill-all,kill-only-files, or a bare predicate - coarse next to project.el'sproject-kill-buffer-conditions. This teaches the filter to also accept a list of composable conditions: buffer-name regexps, predicate functions, and(major-mode . M)/(derived-mode . M)/(not ...)/(and ...)/(or ...)forms. A buffer is killed when it matches any condition. The matcher mirrors project.el'sproject--buffer-check.Fully backward compatible - the existing symbol and predicate values are untouched. The per-buffer decision now lives in a small
projectile-buffer-killed-ppredicate.