* filecache.el questions
@ 2008-10-01 17:04 Ted Zlatanov
2008-10-01 20:33 ` Ted Zlatanov
2008-10-02 11:36 ` Mathias Dahl
0 siblings, 2 replies; 4+ messages in thread
From: Ted Zlatanov @ 2008-10-01 17:04 UTC (permalink / raw
To: emacs-devel; +Cc: pbreton
Hi,
in using filecache.el I found two issues I have for now addressed on my
own:
1) the file-cache-alist is never saved. This is a problem with large
file sets (incidentally, it would be nice if Emacs had a native way of
storing large data sets in an external database, as I mentioned). I
wrote a serialization function that essentially dumps with prin1 and
princ and reads back with eval. I also added a variable with the list
of locations that should be scanned at startup.
I wanted to ask if I should submit that as a patch. filecache.el seems
pretty lean so I wasn't sure if I should add that kind of weight to it.
2) multiple alternatives are proposed sequentially (with repeated C-u
C-TAB). For example, if hello.c is in /data and /data2:
/tmp/hello.c[C-TAB] -> /data/hello.c[C-u C-TAB] -> /data2/hello.c[C-u C-TAB]
The message displayed is just "1 of 2" and "2 of 2". I modified the
message to say:
1 of 2
*1:/data/hello.c*
2:/data2/hello.c
2 of 2
1:/data/hello.c
*2:/data2/hello.c*
but that's just a hack, not as good as completing-read on the
alternatives (this is why I'm not submitting a patch). Has
completing-read been considered for the multiple matches case?
Thanks
Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: filecache.el questions
2008-10-01 17:04 filecache.el questions Ted Zlatanov
@ 2008-10-01 20:33 ` Ted Zlatanov
2008-10-02 11:36 ` Mathias Dahl
1 sibling, 0 replies; 4+ messages in thread
From: Ted Zlatanov @ 2008-10-01 20:33 UTC (permalink / raw
Cc: pbreton, Emacs Development
(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))
)
)
)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: filecache.el questions
2008-10-01 17:04 filecache.el questions Ted Zlatanov
2008-10-01 20:33 ` Ted Zlatanov
@ 2008-10-02 11:36 ` Mathias Dahl
2008-10-02 17:29 ` Ted Zlatanov
1 sibling, 1 reply; 4+ messages in thread
From: Mathias Dahl @ 2008-10-02 11:36 UTC (permalink / raw
To: Ted Zlatanov; +Cc: pbreton, emacs-devel
> in using filecache.el I found two issues I have for now addressed on my
> own:
>
> 1) the file-cache-alist is never saved. This is a problem with large
> file sets (incidentally, it would be nice if Emacs had a native way of
> storing large data sets in an external database, as I mentioned). I
> wrote a serialization function that essentially dumps with prin1 and
> princ and reads back with eval. I also added a variable with the list
> of locations that should be scanned at startup.
I had the same problem when I learnt about this and I created a page
over at EmacsWiki about it:
http://www.emacswiki.org/cgi-bin/wiki/FileNameCache
Nowadays I use `anything' and the `anything-c-source-file-cache'
source instead of my old iswitchb hack. I even have a special command
when I want to use `anything' just to get files from the cache (the
cache is so large that I don't want it to be used for normal
invocations of `anything'):
(defun anything-file-cache ()
(interactive)
(let ((anything-sources
(list anything-c-source-file-cache)))
(anything)))
Enjoy!
/Mathias
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: filecache.el questions
2008-10-02 11:36 ` Mathias Dahl
@ 2008-10-02 17:29 ` Ted Zlatanov
0 siblings, 0 replies; 4+ messages in thread
From: Ted Zlatanov @ 2008-10-02 17:29 UTC (permalink / raw
To: Mathias Dahl; +Cc: pbreton, emacs-devel
On Thu, 2 Oct 2008 13:36:36 +0200 "Mathias Dahl" <mathias.dahl@gmail.com> wrote:
>> in using filecache.el I found two issues I have for now addressed on my
>> own:
>>
>> 1) the file-cache-alist is never saved. This is a problem with large
>> file sets (incidentally, it would be nice if Emacs had a native way of
>> storing large data sets in an external database, as I mentioned). I
>> wrote a serialization function that essentially dumps with prin1 and
>> princ and reads back with eval. I also added a variable with the list
>> of locations that should be scanned at startup.
MD> I had the same problem when I learnt about this and I created a page
MD> over at EmacsWiki about it:
MD> http://www.emacswiki.org/cgi-bin/wiki/FileNameCache
My save method is a bit more complicated, since it uses a method similar
to how Gnus saves its newsrc file, and do more protection of the
contents (print-quoted, print-readably, etc.). The file has one big
setq statement:
(setq file-cache-alist '(...))
MD> Nowadays I use `anything' and the `anything-c-source-file-cache'
MD> source instead of my old iswitchb hack. I even have a special command
MD> when I want to use `anything' just to get files from the cache (the
MD> cache is so large that I don't want it to be used for normal
MD> invocations of `anything'):
MD> (defun anything-file-cache ()
MD> (interactive)
MD> (let ((anything-sources
MD> (list anything-c-source-file-cache)))
MD> (anything)))
That's a much better way than what I proposed. I hope anything.el makes
it into the Emacs core, it's a very useful package. I'll be using it
rather than play around with completing-read, etc.
Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-02 17:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-01 17:04 filecache.el questions Ted Zlatanov
2008-10-01 20:33 ` Ted Zlatanov
2008-10-02 11:36 ` Mathias Dahl
2008-10-02 17:29 ` Ted Zlatanov
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).