all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
Cc: pbreton <pbreton@cs.umb.edu>, Emacs Development <emacs-devel@gnu.org>
Subject: Re: filecache.el questions
Date: Wed, 01 Oct 2008 15:33:20 -0500	[thread overview]
Message-ID: <868wt82gz3.fsf@lifelogs.com> (raw)
In-Reply-To: <864p3w457n.fsf@lifelogs.com> (Ted Zlatanov's message of "Wed, 01 Oct 2008 12:04:28 -0500")

(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	other threads:[~2008-10-01 20:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-01 17:04 filecache.el questions Ted Zlatanov
2008-10-01 20:33 ` Ted Zlatanov [this message]
2008-10-02 11:36 ` Mathias Dahl
2008-10-02 17:29   ` Ted Zlatanov

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

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

  git send-email \
    --in-reply-to=868wt82gz3.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.org \
    --cc=pbreton@cs.umb.edu \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.