GNU bug report logs -
#76417
[PATCH] Add tramp-cleanup-bufferless-connections
Previous Next
Reported by: Ship Mints <shipmints <at> gmail.com>
Date: Wed, 19 Feb 2025 17:45:02 UTC
Severity: wishlist
Tags: patch
Fixed in version 31.1
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76417 in the body.
You can then email your comments to 76417 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Wed, 19 Feb 2025 17:45:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ship Mints <shipmints <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 19 Feb 2025 17:45:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
'tramp-cleanup-bufferless-connections' cleans up connection-related objects
for which no associated buffers exist. This is helpful to prune
connections after you close remote-file buffers without having to either
cherry pick via 'tramp-cleanup-connection' or clear them all via
'tramp-cleanup-all-connections'.
I looked for an equivalent but didn't see one so I've been using this
command, and I think it's ready for contribution.
-Stephane
[Message part 2 (text/html, inline)]
[0001-Add-tramp-cleanup-bufferless-connections.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Thu, 20 Feb 2025 12:08:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 76417 <at> debbugs.gnu.org (full text, mbox):
Ship Mints <shipmints <at> gmail.com> writes:
Hi,
> 'tramp-cleanup-bufferless-connections' cleans up connection-related
> objects for which no associated buffers exist. This is helpful to
> prune connections after you close remote-file buffers without having
> to either cherry pick via 'tramp-cleanup-connection' or clear them all
> via 'tramp-cleanup-all-connections'.
Thanks for this. However, I feel we have already too many
Tramp-cleanup-* commands; I fear another one would bring more
confusion. Nobody but the author would remember :-)
> I looked for an equivalent but didn't see one so I've been using this
> command, and I think it's ready for contribution.
For this, we have tramp-cleanup-some-buffers. Would it be possible to
implement your feature by adding a proper hook function in
tramp-cleanup-some-buffers-hook?
As a first change, I propose to extend tramp-list-remote-buffers like
--8<---------------cut here---------------start------------->8---
(defsubst tramp-get-buffer-file-name (buffer)
"Return `buffer-file-name' of BUFFER."
(buffer-local-value 'buffer-file-name buffer))
(defun tramp-list-remote-buffers ()
"Return a list of all buffers with remote `default-directory'."
(tramp-compat-seq-keep
(lambda (x)
(when (or (tramp-tramp-file-p (tramp-get-default-directory x))
(tramp-tramp-file-p (tramp-get-buffer-file-name x)))
x))
(buffer-list)))
--8<---------------cut here---------------end--------------->8---
Could you work on such a patch?
> -Stephane
Best regards, Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Thu, 20 Feb 2025 12:51:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 76417 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thu, Feb 20, 2025 at 7:07 AM Michael Albinus <michael.albinus <at> gmx.de>
wrote:
> Ship Mints <shipmints <at> gmail.com> writes:
>
> > 'tramp-cleanup-bufferless-connections' cleans up connection-related
> > objects for which no associated buffers exist. This is helpful to
> > prune connections after you close remote-file buffers without having
> > to either cherry pick via 'tramp-cleanup-connection' or clear them all
> > via 'tramp-cleanup-all-connections'.
>
> Thanks for this. However, I feel we have already too many
> Tramp-cleanup-* commands; I fear another one would bring more
> confusion. Nobody but the author would remember :-)
>
No worries. I'll advertise this on support forums when it comes up, no
problem. Someone had a problem just yesterday for which this could help.
I added this function to my buffer-list-update-hook to keep clean
automatically.
> I looked for an equivalent but didn't see one so I've been using this
> > command, and I think it's ready for contribution.
>
> For this, we have tramp-cleanup-some-buffers. Would it be possible to
> implement your feature by adding a proper hook function in
> tramp-cleanup-some-buffers-hook?
>
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.
As a first change, I propose to extend tramp-list-remote-buffers like
>
> --8<---------------cut here---------------start------------->8---
> (defsubst tramp-get-buffer-file-name (buffer)
> "Return `buffer-file-name' of BUFFER."
> (buffer-local-value 'buffer-file-name buffer))
>
> (defun tramp-list-remote-buffers ()
> "Return a list of all buffers with remote `default-directory'."
> (tramp-compat-seq-keep
> (lambda (x)
> (when (or (tramp-tramp-file-p (tramp-get-default-directory x))
> (tramp-tramp-file-p (tramp-get-buffer-file-name x)))
> x))
> (buffer-list)))
> --8<---------------cut here---------------end--------------->8---
>
> Could you work on such a patch?
>
It looks to me, though, that tramp-cleanup-some-buffers does things
differently. It does (tramp-cleanup-all-connections) which is not what I
want. I want only to kill unused tramp connections, not all tramp
connections. It also kills user buffers which is not what my function
does--it kills only tramp-related objects not user buffers.
I could take a second look today, but it doesn't seem like they solve the
same problem?
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Thu, 20 Feb 2025 14:04:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 76417 <at> debbugs.gnu.org (full text, mbox):
Ship Mints <shipmints <at> gmail.com> 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.
Best regards, Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Fri, 21 Feb 2025 12:35:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 76417 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thu, Feb 20, 2025 at 9:03 AM Michael Albinus <michael.albinus <at> gmx.de>
wrote:
> Ship Mints <shipmints <at> gmail.com> 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?
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Fri, 21 Feb 2025 13:25:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 76417 <at> debbugs.gnu.org (full text, mbox):
Ship Mints <shipmints <at> gmail.com> writes:
Hi,
> 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?
Well, likely it will be a ship-only command in Tramp. But so what, show
it. If time permits (I hope so!), I'll play with your patch and see,
whether I could improve it in order to approach my target, use of
tramp-cleanup-some-buffers.
If I fail, I will install your patch.
Best regards, Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Fri, 21 Feb 2025 14:38:05 GMT)
Full text and
rfc822 format available.
Message #23 received at 76417 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi, Michael, take a look at this version of the patch. -Stephane
On Fri, Feb 21, 2025 at 8:24 AM Michael Albinus <michael.albinus <at> gmx.de>
wrote:
> Ship Mints <shipmints <at> gmail.com> writes:
>
> Hi,
>
> > 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?
>
> Well, likely it will be a ship-only command in Tramp. But so what, show
> it. If time permits (I hope so!), I'll play with your patch and see,
> whether I could improve it in order to approach my target, use of
> tramp-cleanup-some-buffers.
>
> If I fail, I will install your patch.
>
> Best regards, Michael.
>
[Message part 2 (text/html, inline)]
[0001-Add-tramp-cleanup-bufferless-connections.patch (application/octet-stream, attachment)]
Severity set to 'wishlist' from 'normal'
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 23 Feb 2025 00:00:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Sun, 23 Feb 2025 12:20:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 76417 <at> debbugs.gnu.org (full text, mbox):
Ship Mints <shipmints <at> gmail.com> writes:
> Hi, Michael, take a look at this version of the patch. -Stephane
Done. Finally, you're right. It is worth an own command. What I do miss
is its documentation in tramp.texi, node "Cleanup remote connections".
Some further remarks:
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -888,6 +888,14 @@ we invite Flyspell users to enable this new option and report issues.
>
> ** Tramp
>
> ++++
> +*** New command tramp-cleanup-bufferless-connections.
'tramp-cleanup-bufferless-connections'
> +Connection-related objects for which no associated buffers exist are
... for which no associated buffers except Tramp internal ones exist ...
> --- a/lisp/net/tramp-cmds.el
> +++ b/lisp/net/tramp-cmds.el
> +(defsubst tramp-get-buffer-file-name (buffer)
> + "Return `buffer-file-name' for BUFFER."
> + (buffer-local-value 'buffer-file-name buffer))
I've proposed this. But thinking about, there is already the exact same
function 'buffer-file-name'. We shall use it instead.
> +(defsubst tramp-get-buffer-default-directory (buffer)
> + "Return `default-directory' for BUFFER."
> + (buffer-local-value 'default-directory buffer))
Not needed here. This is defined in tramp.el.
> +A buffer is considered remote if either its `default-directory' or its
> +buffer file name is considered remote by the function
> +`tramp-tramp-file-p'."
... "is a remote file name."
> (tramp-compat-seq-keep
> - (lambda (x)
> - (when (tramp-tramp-file-p (tramp-get-default-directory x)) x))
> + (lambda (buffer)
> + (when (or
> + (tramp-tramp-file-p (tramp-get-buffer-file-name buffer))
> + (tramp-tramp-file-p (tramp-get-buffer-default-directory buffer)))
> + buffer))
Simplify as
--8<---------------cut here---------------start------------->8---
(when (tramp-tramp-file-p
(or (buffer-file-name buffer)
(tramp-get-buffer-default-directory buffer)))
buffer)
--8<---------------cut here---------------end--------------->8---
> +(defun tramp-list-remote-buffer-connections ()
> + "Return a list of all remote buffer connections.
> +A buffer is considered remote if either its `default-directory' or the
> +function `buffer-file-name' is considered remote by
> +`tramp-tramp-file-p'."
... "is a remote file name."
Best regards, Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76417
; Package
emacs
.
(Mon, 24 Feb 2025 16:08:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 76417 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Latest patch attached including texi update.
-Stephane
On Sun, Feb 23, 2025 at 7:18 AM Michael Albinus <michael.albinus <at> gmx.de>
wrote:
> Ship Mints <shipmints <at> gmail.com> writes:
>
> > Hi, Michael, take a look at this version of the patch. -Stephane
>
> Done. Finally, you're right. It is worth an own command. What I do miss
> is its documentation in tramp.texi, node "Cleanup remote connections".
>
> Some further remarks:
>
> > --- a/etc/NEWS
> > +++ b/etc/NEWS
> > @@ -888,6 +888,14 @@ we invite Flyspell users to enable this new option
> and report issues.
> >
> > ** Tramp
> >
> > ++++
> > +*** New command tramp-cleanup-bufferless-connections.
>
> 'tramp-cleanup-bufferless-connections'
>
> > +Connection-related objects for which no associated buffers exist are
>
> ... for which no associated buffers except Tramp internal ones exist ...
>
> > --- a/lisp/net/tramp-cmds.el
> > +++ b/lisp/net/tramp-cmds.el
> > +(defsubst tramp-get-buffer-file-name (buffer)
> > + "Return `buffer-file-name' for BUFFER."
> > + (buffer-local-value 'buffer-file-name buffer))
>
> I've proposed this. But thinking about, there is already the exact same
> function 'buffer-file-name'. We shall use it instead.
>
> > +(defsubst tramp-get-buffer-default-directory (buffer)
> > + "Return `default-directory' for BUFFER."
> > + (buffer-local-value 'default-directory buffer))
>
> Not needed here. This is defined in tramp.el.
>
> > +A buffer is considered remote if either its `default-directory' or its
> > +buffer file name is considered remote by the function
> > +`tramp-tramp-file-p'."
>
> ... "is a remote file name."
>
> > (tramp-compat-seq-keep
> > - (lambda (x)
> > - (when (tramp-tramp-file-p (tramp-get-default-directory x)) x))
> > + (lambda (buffer)
> > + (when (or
> > + (tramp-tramp-file-p (tramp-get-buffer-file-name buffer))
> > + (tramp-tramp-file-p (tramp-get-buffer-default-directory
> buffer)))
> > + buffer))
>
> Simplify as
>
> --8<---------------cut here---------------start------------->8---
> (when (tramp-tramp-file-p
> (or (buffer-file-name buffer)
> (tramp-get-buffer-default-directory buffer)))
> buffer)
> --8<---------------cut here---------------end--------------->8---
>
> > +(defun tramp-list-remote-buffer-connections ()
> > + "Return a list of all remote buffer connections.
> > +A buffer is considered remote if either its `default-directory' or the
> > +function `buffer-file-name' is considered remote by
> > +`tramp-tramp-file-p'."
>
> ... "is a remote file name."
>
> Best regards, Michael.
>
[Message part 2 (text/html, inline)]
[0001-Add-tramp-cleanup-bufferless-connections-bug-76417.patch (application/octet-stream, attachment)]
Reply sent
to
Michael Albinus <michael.albinus <at> gmx.de>
:
You have taken responsibility.
(Tue, 25 Feb 2025 11:45:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ship Mints <shipmints <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 25 Feb 2025 11:45:02 GMT)
Full text and
rfc822 format available.
Message #36 received at 76417-done <at> debbugs.gnu.org (full text, mbox):
Version: 31.1
Ship Mints <shipmints <at> gmail.com> writes:
> Latest patch attached including texi update.
Thanks, pushed to the repositories. Closing the bug report.
> -Stephane
Best regards, Michael.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 26 Mar 2025 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 142 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.