unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Proposing two new functions in filecache.el
@ 2005-12-15 18:27 Mathias Dahl
  2005-12-16  5:08 ` Richard M. Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Mathias Dahl @ 2005-12-15 18:27 UTC (permalink / raw)



I just learned about the very usefil File Name Cache and propose the
following or similar addition to filecache.el. 

The reason is that adding remote directories is a time-consuming
operation, and for directories that seldom change, there is no point
in creating the file cache each time Emacs is restarted. So, why not
add functionality to save and read the cache from a file?

;;; Code begins here

(defun file-cache-save-cache-to-file (file)
  "Save contents of `file-cache-alist' to FILE.
For later retrieval using `file-cache-read-cache-from-file'"
  (interactive)
  (let ((buf (get-buffer-create "*file-cache*")))
    (save-excursion
      (set-buffer buf)
      (erase-buffer)
      ;; If there is some neater way of doing the saving, I am all for
      ;; it...
      (insert
       (with-output-to-string
         (print file-cache-alist)))
      (write-region (point-min) (point-max) (expand-file-name file)))))

(defun file-cache-read-cache-from-file (file)
  "Clear `file-cache-alist' and read cache from FILE.
The file cache can be saved to a file using
`file-cache-save-cache-to-file'."
  (interactive)
  (file-cache-clear-cache)
  (let ((buf (get-buffer-create "*file-cache*")))
    (save-excursion
      (set-buffer buf)
      (erase-buffer)
      ;; Similary to the read function, if there is a better way to
      ;; restore file-cache-alist...
      (insert-file-contents file)
      (setq file-cache-alist 
            (car (read-from-string 
                  (buffer-substring (point-min) (point-max))))))))

;;; Code ends here

Here is some code to test and verify that it works:

First load the cache with some file names:

  (file-cache-add-directory "~/")

Next, check size of cache:

  (message "File cache size: %d" (length file-cache-alist))

Save cache to a file:

  (file-cache-save-cache-to-file "~/.file_cache")

Clear it and make sure it is empty:

  (file-cache-clear-cache)
  (message "File cache size: %d" (length file-cache-alist))

Read cache from file and verify we got the same number of cache items back:

  (file-cache-read-cache-from-file "~/.file_cache")
  (message "File cache size: %d" (length file-cache-alist))

In your .emacs file, you only need to do this:

  (require 'filecache)
  (file-cache-read-cache-from-file "~/.file_cache")

What do others think? Would this be acceptable/useful? If not, I will
happily keep this hack to myself.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Proposing two new functions in filecache.el
  2005-12-15 18:27 Proposing two new functions in filecache.el Mathias Dahl
@ 2005-12-16  5:08 ` Richard M. Stallman
  2005-12-16 11:55   ` roadmap? (was Re: Proposing two new functions in filecache.el) Ryan Barrett
  2005-12-16 13:18   ` Proposing two new functions in filecache.el Mathias Dahl
  0 siblings, 2 replies; 7+ messages in thread
From: Richard M. Stallman @ 2005-12-16  5:08 UTC (permalink / raw)
  Cc: emacs-devel

This is a new feature, not a bug fix.  We'd rather not add new
features until after the next release.  Could you come back with this
after then?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* roadmap? (was Re: Proposing two new functions in filecache.el)
  2005-12-16  5:08 ` Richard M. Stallman
@ 2005-12-16 11:55   ` Ryan Barrett
  2005-12-16 17:40     ` Xavier Maillard
                       ` (2 more replies)
  2005-12-16 13:18   ` Proposing two new functions in filecache.el Mathias Dahl
  1 sibling, 3 replies; 7+ messages in thread
From: Ryan Barrett @ 2005-12-16 11:55 UTC (permalink / raw)


On Fri, 16 Dec 2005, Richard M. Stallman wrote:

> This is a new feature, not a bug fix. We'd rather not add new features until
> after the next release. Could you come back with this after then?

this is reasonable, and it's why i've been holding back a new feature proposal
of my own.

out of curiosity, is there a roadmap or planned release schedule for emacs 22?
i looked on both the gnu.org and savannah emacs sites, but didn't see one. (i
won't mind if the answer is no. :P)

-Ryan

--
http://snarfed.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Proposing two new functions in filecache.el
  2005-12-16  5:08 ` Richard M. Stallman
  2005-12-16 11:55   ` roadmap? (was Re: Proposing two new functions in filecache.el) Ryan Barrett
@ 2005-12-16 13:18   ` Mathias Dahl
  1 sibling, 0 replies; 7+ messages in thread
From: Mathias Dahl @ 2005-12-16 13:18 UTC (permalink / raw)


"Richard M. Stallman" <rms@gnu.org> writes:

> This is a new feature, not a bug fix.  

OK, sorry for that.

> We'd rather not add new features until after the next release.
> Could you come back with this after then?

I can and I will. I'll put this in my calendar for, shall we say,
2010? ... :) (Sorry, couldn't resist).

Seriously, I'll get back on this subject in maybe half a year or so.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: roadmap? (was Re: Proposing two new functions in filecache.el)
  2005-12-16 11:55   ` roadmap? (was Re: Proposing two new functions in filecache.el) Ryan Barrett
@ 2005-12-16 17:40     ` Xavier Maillard
  2005-12-16 21:03     ` roadmap? Chong Yidong
  2005-12-17  1:04     ` roadmap? (was Re: Proposing two new functions in filecache.el) Richard M. Stallman
  2 siblings, 0 replies; 7+ messages in thread
From: Xavier Maillard @ 2005-12-16 17:40 UTC (permalink / raw)
  Cc: emacs-devel

   From: Ryan Barrett <emacs-devel@ryanb.org>

   out of curiosity, is there a roadmap or planned release schedule for emacs 22?
   i looked on both the gnu.org and savannah emacs sites, but didn't see one. (i
   won't mind if the answer is no. :P)

The answer is, AFAIK, no :)

Xavier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: roadmap?
  2005-12-16 11:55   ` roadmap? (was Re: Proposing two new functions in filecache.el) Ryan Barrett
  2005-12-16 17:40     ` Xavier Maillard
@ 2005-12-16 21:03     ` Chong Yidong
  2005-12-17  1:04     ` roadmap? (was Re: Proposing two new functions in filecache.el) Richard M. Stallman
  2 siblings, 0 replies; 7+ messages in thread
From: Chong Yidong @ 2005-12-16 21:03 UTC (permalink / raw)
  Cc: emacs-devel

Ryan Barrett <emacs-devel@ryanb.org> writes:

>> This is a new feature, not a bug fix. We'd rather not add new features until
>> after the next release. Could you come back with this after then?
>
> this is reasonable, and it's why i've been holding back a new feature proposal
> of my own.
>
> out of curiosity, is there a roadmap or planned release schedule for emacs 22?
> i looked on both the gnu.org and savannah emacs sites, but didn't see one. (i
> won't mind if the answer is no. :P)

There is neither a roadmap nor a planned release schedule.  See the
other thread on emacs-devel discussing whether a release will ever
happen (or at least sometime this decade.)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: roadmap? (was Re: Proposing two new functions in filecache.el)
  2005-12-16 11:55   ` roadmap? (was Re: Proposing two new functions in filecache.el) Ryan Barrett
  2005-12-16 17:40     ` Xavier Maillard
  2005-12-16 21:03     ` roadmap? Chong Yidong
@ 2005-12-17  1:04     ` Richard M. Stallman
  2 siblings, 0 replies; 7+ messages in thread
From: Richard M. Stallman @ 2005-12-17  1:04 UTC (permalink / raw)
  Cc: emacs-devel

We are not in a position to make a schedule that we could hold to.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-12-17  1:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-15 18:27 Proposing two new functions in filecache.el Mathias Dahl
2005-12-16  5:08 ` Richard M. Stallman
2005-12-16 11:55   ` roadmap? (was Re: Proposing two new functions in filecache.el) Ryan Barrett
2005-12-16 17:40     ` Xavier Maillard
2005-12-16 21:03     ` roadmap? Chong Yidong
2005-12-17  1:04     ` roadmap? (was Re: Proposing two new functions in filecache.el) Richard M. Stallman
2005-12-16 13:18   ` Proposing two new functions in filecache.el Mathias Dahl

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).