unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Hadsell <ahadsell@mtdiablo.com>
To: gnu-emacs-bug@ftp.gnu.org
Subject: Re: Inconvenience with TRAMP and recentf
Date: Mon, 02 Jul 2007 11:08:21 -0400	[thread overview]
Message-ID: <uhcom972y.fsf@mtdiablo.com> (raw)
In-Reply-To: mailman.2935.1183346169.32220.bug-gnu-emacs@gnu.org

Eli Zaretskii <eliz@gnu.org> writes:

> Why does it make sense not to cleanup only remote files?

There is no delay (or other side effect, see below) due to cleaning up
local files.

> How about setting recentf-auto-cleanup to a number, which will cause
> the cleanup to happen when Emacs is idle for that many seconds?
> That should avoid the startup delay without having the adverse
> effects of keeping stale files on the list.

If I set recentf-auto-cleanup that way, it will attempt a cleanup
whenever emacs is idle for (say) 10 minutes.  If I then touch emacs
again, and let it go idle again, it will do another cleanup.  The
chances are excellent (I know this, because it's happened to me with
other features conditioned upon "x seconds of emacs inactivity") that
I will return to emacs during one of these spurts of idle-time
activity.  That means I'll wait for my (editor, news/mail reader,
console, operating system) to become available again.

Also, the delay is not the only side effect of TRAMP's promiscuity in
opening a session I didn't ask for:

  * It causes problems when the remote system is offline or the local
    system is disconnected.

  * It leaves traces in logs on the remote system, which I may need
    to explain to a paranoid sysadmin (Why were you connecting to my
    system at 3 a.m. yesterday?)

  * On a modem-connected system it can cause an unwanted dial-out.

If I enable the idle-time cleanup, these side effects happen every
time emacs is idle for the requisite time.

In my opinion, this access violates the principle of least surprise.
The fact that I once opened a TRAMP connection to a system doesn't
grant emacs a license to do so any other time.

However, you have convinced me that my original proposal was bogus; it
did not go far enough.  Rather than completely avoiding cleanup of
remote recentf entries, we should wait to clean them up until a new
TRAMP session is opened to that host.  

The sticky part of this approach is drawing the line between recentf
and TRAMP.  I would not object to recentf knowing the difference
between remote and local files, but I would rather not teach it about
which files belong to which host, especially since TRAMP already knows
that.  

So I guess the best approach would be:

  0) recentf-cleanup gains an optional boolean argument REMOTE.  When
     REMOTE is nil, recentf-cleanup igores remote files in
     recentf-list (i.e. it passes them through to the newlist
     unchanged).  When REMOTE is true, it processes remote files too.

  1) Whenever TRAMP opens a new session, it calls the new 
     tramp-session-opened-hook, which calls recentf-cleanup-remote,
     which calls (recentf-cleanup t).

  2) For remote files, recentf-expand-file-name does not call
     expand-file-name directly; it just calls the filename handlers.

  3) TRAMP provides a filename handler called
     tramp-maybe-expand-file-name, which calls
     tramp-handle-expand-file-name only if there is already a session
     open to the specified host; otherwise it returns the filename
     unmodified.

This would solve the immediate problem (in recentf-cleanup), but it
does not deal with any other calls to expand-file-name that might open
unwanted TRAMP sessions.  To do that, one would need to identify the
intent behind all expand-file-name calls in emacs, and classify them
as to whether or not they should open a new TRAMP session.  Seems like
a lot of work, and I'm lazy.

Your opinion?
-- 
Alan Hadsell

  parent reply	other threads:[~2007-07-02 15:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-01 22:15 Inconvenience with TRAMP and recentf Alan Hadsell
2007-07-02  3:15 ` Eli Zaretskii
2007-07-02  4:51 ` Michael Albinus
     [not found] ` <mailman.2935.1183346169.32220.bug-gnu-emacs@gnu.org>
2007-07-02 15:08   ` Alan Hadsell [this message]
     [not found] ` <mailman.2937.1183364176.32220.bug-gnu-emacs@gnu.org>
2007-07-02 15:31   ` Alan Hadsell
2007-07-02 19:37     ` Michael Albinus
     [not found]     ` <mailman.2973.1183405011.32220.bug-gnu-emacs@gnu.org>
2007-07-02 21:31       ` Alan Hadsell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uhcom972y.fsf@mtdiablo.com \
    --to=ahadsell@mtdiablo.com \
    --cc=gnu-emacs-bug@ftp.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).