emacs-devel
[Top][All Lists]
Advanced

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

Re: filecache.el questions


From: Ted Zlatanov
Subject: Re: filecache.el questions
Date: Wed, 01 Oct 2008 15:33:20 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

(I heard from Paul, who I didn't CC correctly on my last e-mail so he
didn't see that this went to emacs-devel as well.  Fixing this.)

Paul Breton wrote:
> If the code is fairly small, I think it wouldn't hurt to add an
> optional way to save file-cache-alist. A list of locations sounds like
> overkill to me, however; I would have one variable to say whether or
> not to save it (defaulting to not), and another one to save where it
> should be saved.

> (Personally, I never save the cache because eventually it would get
> out of sync with the actual filesystem; initializing once per emacs
> session (which are fairly long-lived for me) works for me. However,
> people who use it differently might benefit from the new code).

I have to restart it often, and I need to scan a *lot* of directories,
so it makes sense for me.  

I added a file-cache-rescan function that will rescan and save, and
file-cache-initialize which will do a rescan if the save file doesn't
exist (intended to be called when you load the library).  It doesn't
have to have a list of file locations, you're right.  Does the
rescan/initialize mechanism seem OK?  The actual code is pretty
trivial, though I keep wishing it was even simpler through some Emacs
persistence mechanism.

> Similarly, it has never bothered me very much to simply cycle thru the
> various completions. I wouldn't use the display hack simply because it
> seems like it could get ugly when there are a lot of
> completions. Completing-read is a good idea; however, I haven't looked
> at this code in a long time and am still scratching my head over how
> the completion magic works :)

Here's a patch to do a completing-read when more than one directory is
available, using enable-recursive-minibuffers which is a bit hacky.  It
does work better than the current method, which just inserts the next
value in the list.  This replaces the current method; the two can
coexist as well.

Ted

Index: filecache.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/filecache.el,v
retrieving revision 1.37
diff -c -r1.37 filecache.el
*** filecache.el        6 May 2008 07:57:35 -0000       1.37
--- filecache.el        1 Oct 2008 20:23:24 -0000
***************
*** 511,525 ****
       (t
        (let* ((minibuffer-dir (file-name-directory (minibuffer-contents)))
             (dir-list       (member minibuffer-dir directory-list))
             )
!       (setq directory
!             ;; If the directory is in the list, return the next element
!             ;; Otherwise, return the first element
!             (if dir-list
!                 (or (elt directory-list
!                          (setq num (1+ (- len (length dir-list)))))
!                     (elt directory-list (setq num 0)))
!               (elt directory-list (setq num 0))))
        )
        )
       )
--- 511,521 ----
       (t
        (let* ((minibuffer-dir (file-name-directory (minibuffer-contents)))
             (dir-list       (member minibuffer-dir directory-list))
+            (enable-recursive-minibuffers t)
             )
!       (setq directory (completing-read 
!                        (format "Select a directory for %s: " file) 
!                        directory-list nil t))
        )
        )
       )




reply via email to

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