[Top][All Lists]

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

Re: file-cache doc should state that the cache is non-persistent

From: Mathias Dahl
Subject: Re: file-cache doc should state that the cache is non-persistent
Date: Tue, 28 Mar 2006 15:49:37 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt)

"Drew Adams" <address@hidden> writes:

> Looking at both the File Name Cache node in the Emacs manual and the Lisp
> source code, I see nothing that indicates whether or not the cache is
> persistent.
> This is an important piece of information. The doc should make it clear that
> the cache is not persistent and that it launches `find' each time you use it
> to find a file.

You want my suggestion to be implemented, in other words... :)


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

;;; 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'"
  (let ((buf (get-buffer-create "*file-cache*")))
      (set-buffer buf)
      ;; If there is some neater way of doing the saving, I am all for
      ;; it...
         (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
  (let ((buf (get-buffer-create "*file-cache*")))
      (set-buffer buf)
      ;; 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

Richard answered that we could look into that later but for now, your
proposed documentation changes could be done.

reply via email to

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