Allow excluding buffers from perspectives based on patterns or anonymous status
Currently, perspectives automatically collect any buffer visited while in that perspective. This can lead to cluttered buffer lists and a degraded user experience, particularly when using packages like magit that create many transient buffers that are typically accessed via their own specialised UI rather than through perspective's buffer switching.
For example, magit creates buffers like `*magit: repo-name*`, `*magit-process*`, etc. These rarely need to be accessed via perspective buffer switching since magit manages them internally. However, they currently pollute perspective buffer lists, making it harder to find the buffers you actually want to switch between.
Proposed Solution:
Add configuration options to exclude certain buffers from being automatically added to perspectives:
1. Buffer pattern exclusion:
``` elisp
(setq persp-excluded-buffer-patterns
'("\\=\\*magit" "\\=\\/Messages\\*" "\\=\\*Org Agenda\\*"))
```
2. Anonymous buffer marking:
- Add a function `persp-mark-buffer-anonymous` that removes a buffer from the current perspective and marks it to prevent future automatic inclusion
- When a buffer is marked anonymous, visiting it won't add it to any perspective
- Buffers can still be explicitly added to perspectives if needed
This would improve the user experience by:
- Keeping perspective buffer lists focused on buffers you actually want to switch between
- Reducing clutter from transient/utility buffers that have their own navigation mechanisms
- Maintaining the ability to explicitly add excluded buffers when desired
Implementation considerations:
- Buffer exclusion patterns could be handled during `persp-add-buffer`
- Anonymous status could be stored as a buffer-local variable
- Existing perspectives would need cleanup when patterns change
- Should provide commands to toggle buffer anonymity
The magit use case demonstrates why this would be valuable - magit users rarely need to switch to magit buffers via perspective because magit already provides optimal buffer navigation. This pattern applies to other packages like org-agenda that create utility buffers that are better accessed through their native interfaces.
[2025-01-29 Wed 07:44]
关闭于 2025-02-25 5 条评论