emacs-pretest-bug
[Top][All Lists]
Advanced

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

Look:

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'"
  (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

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]