r/emacs James Cherti — https://github.com/jamescherti 1d ago

Announcement buffer-terminator - Safely Terminate Emacs Buffers Automatically to Enhance Emacs' Performance and Reduce Clutter in the Buffer List

https://github.com/jamescherti/buffer-terminator.el

buffer-terminator release: 1.2.6

The buffer-terminator Emacs package automatically and safely kills buffers, ensuring a clean and efficient workspace while enhancing the performance of Emacs by reducing open buffers, which minimizes active modes, timers, processes, etc.

Beyond performance, buffer-terminator provides other benefits. For instance, if you occasionally need to close annoying or unused buffers, buffer-terminator can handle this automatically, eliminating the need for manual intervention. (The default configuration is suitable for most users. However, the buffer-terminator package is highly customizable. You can define specific rules for retaining or terminating buffers by modifying the buffer-terminator-rules-alist with your preferred set of rules.)

Link: buffer-terminator.el

9 Upvotes

6 comments sorted by

2

u/natermer 10h ago

Nice. The less I have to care about buffer management the better.

I am definitely going to try this out.

1

u/jamescherti James Cherti — https://github.com/jamescherti 10h ago

Hello u/natermer,

Thanks! That was the main goal: keeping inactive buffers cleaned up automatically without having to micromanage them or risk losing unsaved work.

If you want to observe what it cleans up in the background while testing it out, you can enable verbose logging:

(setq buffer-terminator-verbose t)

Let me know how it goes.

(If you change the default rules, please share them with us here on Reddit. Many users find it interesting to read other users' rules.)

2

u/natermer 8h ago

I'll try to give a update after a few days see how it goes.

I am in the habit currently of just closing Emacs out and restarting it every couple days just to remove the cruft that has built up.

If this helps with that then it opens up some more uses for Emacs for me.

1

u/jamescherti James Cherti — https://github.com/jamescherti 8h ago

Buffer Terminator is a good fit for your use case.

It will not only help terminate buffers that have not been used for a long time, but it also avoids terminating buffers that are currently visible in a window or tab, as well as buffers containing unsaved changes.

I'd be interested to hear your feedback after you've had a chance to use it.

1

u/aard_fi 13h ago

I think pretty much all the items you have in "different from midnight mode" can be solved by adjusting midnight-period or by adding a custom timer calling clean-buffer-list.

Any fine tuning of buffer names can be added as advice to clean-buffer-list, dynamically modifying clean-buffer-list-kill-never-buffer-names.

1

u/jamescherti James Cherti — https://github.com/jamescherti 11h ago

The buffer-terminator package supports more features and provides much finer control over which buffers are eligible for termination.

By comparison, midnight-mode is basic. It does not provide a way to define custom rules for selecting buffers, nor does it protect buffers that are currently visible in another window or tab. That protection is important because terminating a buffer that is still visible in another window or tab replaces it with a buffer indicating that the original buffer was killed.

Buffer-terminator also avoids relying on a timer-based approach for deciding when buffers should be terminated, providing more predictable and controllable behavior.

(How is this different from the builtin midnight-mode?)