Subject: Re: bug#76417: [PATCH] Add tramp-cleanup-bufferless-connections

From: Ship Mints <[email-masked]>
Date: Fri, 21 Feb 2025 07:34:08 -0500

On Thu, Feb 20, 2025 at 9:03 AM Michael Albinus <[email-masked]>
wrote:

> Ship Mints <[email-masked]> writes:
>
> Hi,
>
> tramp-cleanup-some-buffers is intended as frame to be customized for
> different use cases.
>
> > I did look. What concerned me was that tramp-cleanup-some-buffers-hook
> > could be altered by users, where tramp-cleanup-bufferless-connections
> > does one and only one thing without interference from potentially
> > modified hooks.
>
> You can write a wrapper function for your package, which binds
> tramp-cleanup-some-buffers-hook with proper functions, and which calls
> tramp-cleanup-some-buffers then.
>
> > It looks to me, though, that tramp-cleanup-some-buffers does things
> > differently.
>
> It is a new command of Emacs 30, so it is not very known to
> users. There's much room to customize it for different use cases.
>
> > It does (tramp-cleanup-all-connections) which is not
> > what I want.  I want only to kill unused tramp connections, not all
> > tramp connections.
>
> I've seen this also today. Hmm, perhaps we can move this call to a hook
> function, added by default, which you can suppress in your own binding
> of tramp-cleanup-some-buffers-hook.
>
> > It also kills user buffers which is not what my
> > function does--it kills only tramp-related objects not user buffers.
>
> This should also be configurable.
>
> > I could take a second look today, but it doesn't seem like they solve
> > the same problem?
>
> Yes, please do. I'm interested in pimp up this command with alternative
> scenarios.
>

I spent some more time on this and I think there's an "impedance mismatch"
between cleanup-some-buffers and cleaning up unused connections.  I'm
finding it cumbersome to mix the two as I have to move back and forth
between "buffer space" and "connection space" to achieve connection
cleanup.  My original patch seems like the cleanest approach, and can be
made shorter with a few tramp utility function changes.  Would you like to
see a patch based on those?