emacs-devel
[Top][All Lists]
Advanced

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

Re: Reverting *Locate* buffers.


From: Luc Teirlinck
Subject: Re: Reverting *Locate* buffers.
Date: Sun, 2 Jul 2006 21:51:20 -0500 (CDT)

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?

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.

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.

===File ~/locate-diff=======================================
*** locate.el   15 Mar 2006 19:31:47 -0600      1.36
--- locate.el   02 Jul 2006 17:35:17 -0500      
***************
*** 191,201 ****
--- 191,222 ----
    :group 'locate
    :version "22.1")
  
+ (defcustom locate-update-when-revert nil
+   "This option affects how the *Locate* buffer gets reverted.
+ If non-nil, offer to update the locate database when reverting that buffer.
+ \(Normally, you need to have root privileges for this to work.  See the
+ option `locate-update-path'.)
+ If nil, reverting does not update the locate database."
+   :type 'boolean
+   :group 'locate
+   :version "22.1")
+ 
  (defcustom locate-update-command "updatedb"
    "The executable program used to update the locate database."
    :type 'string
    :group 'locate)
  
+ (defcustom locate-update-path "/"
+   "The default directory from where `locate-update-command' is called.
+ Usually, root permissions are required to run that command.  This
+ can be achieved by setting this option to \"/su::\" or \"/sudo::\"
+ \(if you have the appropriate authority).  If your current user
+ permissions are sufficient to run the command, you can set this
+ option to \"/\"."
+   :type 'string
+   :group 'locate
+   :version "22.1")
+ 
  (defcustom locate-prompt-for-command nil
    "If non-nil, the `locate' command prompts for a command to run.
  Otherwise, that behavior is invoked via a prefix argument."
***************
*** 557,568 ****
  
  ;; From Stephen Eglen <address@hidden>
  (defun locate-update (ignore1 ignore2)
!   "Update the locate database.
! Database is updated using the shell command in `locate-update-command'."
    (let ((str (car locate-history-list)))
!     (cond ((yes-or-no-p "Update locate database (may take a few seconds)? ")
!          (shell-command locate-update-command)
!          (locate str)))))
  
  ;;; Modified three functions from `dired.el':
  ;;;   dired-find-directory,
--- 578,595 ----
  
  ;; 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)? ")
!        (progn
!          (unless (equal locate-update-path "/")
!            (require 'tramp))
!          (let ((default-directory locate-update-path))
!            (shell-command locate-update-command))))
!     (locate str)))
  
  ;;; Modified three functions from `dired.el':
  ;;;   dired-find-directory,
============================================================




reply via email to

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