-
Notifications
You must be signed in to change notification settings - Fork 1
/
jmjeong-filecache.el
33 lines (28 loc) · 1.04 KB
/
jmjeong-filecache.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(require 'filecache)
(eval-after-load
"filecache"
'(progn
(message "Loading file cache...")
(file-cache-add-directory-using-find elisp-root-dir)))
;; add to file-cache when 'kill-bufffer'
(defun file-cache-add-this-file ()
(and buffer-file-name
(file-exists-p buffer-file-name)
(file-cache-add-file buffer-file-name)))
(add-hook 'kill-buffer-hook 'file-cache-add-this-file)
(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 "FFile: ")
(with-temp-file (expand-file-name file)
(prin1 file-cache-alist (current-buffer))))
(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 "fFile: ")
(file-cache-clear-cache)
(save-excursion
(set-buffer (find-file-noselect file))
(beginning-of-buffer)
(setq file-cache-alist (read (current-buffer)))))