[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reverting *Locate* buffers.

From: Michael Albinus
Subject: Re: Reverting *Locate* buffers.
Date: Mon, 03 Jul 2006 15:43:10 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/20.7 (hpux)

Luc Teirlinck <address@hidden> writes:

> Michael Albinus wrote:
>    The solution would be to set temporarily default-directory to "/" or
>    whatover local during loading of Tramp. But I have no idea how to say
>    it
> I did not think hard about the problem and hence I may not understand
> it, but is I guess that there must be some reason why just saving the
> default directory at the start of tramp, setting it to "/" and setting
> it back to the saved value at the end of tramp does not work?

The problem is that default directory must not be a remote filename
when (auto)loading tramp.el. Any counter measure "at the start of
tramp" (i.e. inside tramp.el) is too late.

> Anyway, assuming that the problem really is hard to solve, I propose
> the following patch.  The main difference with what you proposed is
> that the default value of `locate-update-path' is "/" and that Tramp
> does not get loaded if `locate-update-path' has that default value.
> There are two reasons for this.  It makes it easier to revert to the
> old default and that default does not load Tramp (it does not need
> to).  Secondly, I would be very hesitant about asking for a root
> password without the user having explicitly asked for that behavior
> (through setting `locate-update-path').  If the user has no authority
> to be root and inadvertently gives his own password at the prompt,
> then mail may be sent to the "appropriate authorities", possibly
> embarrassing the user.

That's OK for me.

> I propose the following patch and if nobody objects, I will install
> it.  if the recursive load problem would be solved some other way,
> then obviously, the requiring of Tramp could be undone.

It's really too hot these days. One obvious solution avoiding to
require Tramp explicitely coould be this:

;; From Stephen Eglen <address@hidden>
(defun locate-update (ignore1 ignore2)
  "Revert the *Locate* buffer.
If `locate-update-when-revert' is non-nil, offer to update the
locate database using the shell command in `locate-update-command'."
  (let ((str (car locate-history-list)))
    (and locate-update-when-revert
         (yes-or-no-p "Update locate database (may take a few seconds)? ")
         ;; `expand-file-name' is used in order to autoload Tramp if
         ;; necessary.  It cannot be loaded when `default-directory'
         ;; is remote.
         (let ((default-directory (expand-file-name locate-update-path)))
           (shell-command locate-update-command)))
    (locate str)))

Best regards, Michael.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]