Fwd: tramp removes valid recentf files when a remote is unreachable

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: tramp removes valid recentf files when a remote is unreachable

Marc Herbert
Hi,

I use both tramp and recentf constantly.

I use remote systems which are sometimes off, suspended or on a
different network and I don't always remember to wake them up /
connect to the VPN / etc. on every first attempt. When I try to open a
file on a system that is unreachable, all the files on that system get
cleared from the recentf list. This should be very easy to reproduce.
It is very time-consuming when there are many files buried below long
paths with many directories.

I configured recentf-auto-cleanup to "never" but tramp does not care
about that setting. I also tried various tramp settings but found none
that made a difference.

I found that this was added a few years ago because that could make
Emacs unusable:
https://lists.gnu.org/archive/html/tramp-devel/2019-02/msg00005.html
That does not seem to be the case anymore, well not for me anyway. Not
arguing about the default behavior I think it should be at least
possible to customize it and turn it off somewhere. Is it?

tramp-maybe-open-connection calls tramp-cleanup-connection that calls
the tramp-recentf-cleanup hook that calls recentf-cleanup.
Eventually I commented out the tramp->recentf hook entirely and that
seems to work well but carrying custom patches is of course not
sustainable and solves the problem just for me. Is there a better way?

Thanks in advance!

Marc

PS: I'm not subscribed to this list.

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: tramp removes valid recentf files when a remote is unreachable

Michael Albinus
Marc Herbert <[hidden email]> writes:

> Hi,

Hi Marc,

> I use both tramp and recentf constantly.
>
> I use remote systems which are sometimes off, suspended or on a
> different network and I don't always remember to wake them up /
> connect to the VPN / etc. on every first attempt. When I try to open a
> file on a system that is unreachable, all the files on that system get
> cleared from the recentf list. This should be very easy to reproduce.
> It is very time-consuming when there are many files buried below long
> paths with many directories.
>
> I configured recentf-auto-cleanup to "never" but tramp does not care
> about that setting. I also tried various tramp settings but found none
> that made a difference.

Well, that variable is not intended for this case.

> I found that this was added a few years ago because that could make
> Emacs unusable:
> https://lists.gnu.org/archive/html/tramp-devel/2019-02/msg00005.html
> That does not seem to be the case anymore, well not for me anyway. Not
> arguing about the default behavior I think it should be at least
> possible to customize it and turn it off somewhere. Is it?

After loading Tramp and recentf, you might call these lines in your
.emacs:

--8<---------------cut here---------------start------------->8---
(remove-hook 'tramp-cleanup-connection-hook
             #'tramp-recentf-cleanup)
(remove-hook 'tramp-cleanup-all-connections-hook
             #'tramp-recentf-cleanup-all))))
--8<---------------cut here---------------end--------------->8---

Likely, in your case just the first form is sufficient, don't know. If
this works well for you, I might add it to Tramp's FAQ.

> Thanks in advance!
>
> Marc

Best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: tramp removes valid recentf files when a remote is unreachable

Michael Albinus
Michael Albinus <[hidden email]> writes:

> (remove-hook 'tramp-cleanup-connection-hook
>              #'tramp-recentf-cleanup)
> (remove-hook 'tramp-cleanup-all-connections-hook
>              #'tramp-recentf-cleanup-all))))

Better:

--8<---------------cut here---------------start------------->8---
(remove-hook 'tramp-cleanup-connection-hook
             #'tramp-recentf-cleanup)
(remove-hook 'tramp-cleanup-all-connections-hook
             #'tramp-recentf-cleanup-all)
--8<---------------cut here---------------end--------------->8---

Cut'n'waste, sorry.

Best regards, Michael.

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: tramp removes valid recentf files when a remote is unreachable

Marc Herbert
> Likely, in your case just the first form is sufficient, don't know. If
> this works well for you, I might add it to Tramp's FAQ.

I added both and it seems to work, thanks a lot Michael!

Looking at a backtrace I used to debug this I would guess the first
one should be enough but don't take my word for it, it's not like I
have any extensive "test coverage" for this. Again it should be fairly
easy to reproduce.

Marc

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: tramp removes valid recentf files when a remote is unreachable

Marc Herbert
In reply to this post by Michael Albinus
> > I configured recentf-auto-cleanup to "never" but tramp does not care
> > about that setting. I also tried various tramp settings but found none
> > that made a difference.
>
> Well, that variable is not intended for this case.

BTW I just noticed the help string of recentf-keep by chance:

The default is to keep readable files.  Remote files are checked
   for readability only in case a connection is established to that
   remote system, otherwise they are kept in the recent list without
   checking their readability.


It seems to work. I tried only with the hooks removed as you suggested.