aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/filecache.el
diff options
context:
space:
mode:
authorStefan Monnier2009-11-19 22:02:53 +0000
committerStefan Monnier2009-11-19 22:02:53 +0000
commitbed4c9727800580ebfb81d8f76db4d0ab22aabdb (patch)
treeb4388d3f74b9d5b70919f735c776982dd3859a37 /lisp/filecache.el
parent8c22699f8bba9f6627b4663c64b899cd1525b0c0 (diff)
downloademacs-bed4c9727800580ebfb81d8f76db4d0ab22aabdb.tar.gz
emacs-bed4c9727800580ebfb81d8f76db4d0ab22aabdb.zip
(file-cache-add-file): Use push and cons.
(file-cache-delete-file-regexp): Use push. (file-cache-complete): Use completion-in-region.
Diffstat (limited to 'lisp/filecache.el')
-rw-r--r--lisp/filecache.el40
1 files changed, 12 insertions, 28 deletions
diff --git a/lisp/filecache.el b/lisp/filecache.el
index 2abb4fc4acc..6f550a4b5ec 100644
--- a/lisp/filecache.el
+++ b/lisp/filecache.el
@@ -255,7 +255,10 @@ Defaults to nil on DOS and Windows, and t on other systems."
255(defvar file-cache-last-completion nil) 255(defvar file-cache-last-completion nil)
256 256
257(defvar file-cache-alist nil 257(defvar file-cache-alist nil
258 "Internal data structure to hold cache of file names.") 258 "Internal data structure to hold cache of file names.
259It is a list of entries of the form (FILENAME DIRNAME1 DIRNAME2 ...)
260where FILENAME is a file name component and the entry represents N
261files of names DIRNAME1/FILENAME, DIRNAME2/FILENAME, ...")
259 262
260(defvar file-cache-completions-keymap 263(defvar file-cache-completions-keymap
261 (let ((map (make-sparse-keymap))) 264 (let ((map (make-sparse-keymap)))
@@ -332,13 +335,9 @@ in each directory, not to the directory list itself."
332 (and (listp (cdr the-entry)) 335 (and (listp (cdr the-entry))
333 (member dir-name (cdr the-entry)))) 336 (member dir-name (cdr the-entry))))
334 nil 337 nil
335 (setcdr the-entry (append (list dir-name) (cdr the-entry))) 338 (setcdr the-entry (cons dir-name (cdr the-entry))))
336 )
337 ;; If not, add it to the cache 339 ;; If not, add it to the cache
338 (setq file-cache-alist 340 (push (list file-name dir-name) file-cache-alist)))))
339 (cons (cons file-name (list dir-name))
340 file-cache-alist)))
341 )))
342 341
343;;;###autoload 342;;;###autoload
344(defun file-cache-add-directory-using-find (directory) 343(defun file-cache-add-directory-using-find (directory)
@@ -446,9 +445,9 @@ or the optional REGEXP argument."
446 "Delete files matching REGEXP from the file cache." 445 "Delete files matching REGEXP from the file cache."
447 (interactive "sRegexp: ") 446 (interactive "sRegexp: ")
448 (let ((delete-list)) 447 (let ((delete-list))
449 (mapc '(lambda (elt) 448 (mapc (lambda (elt)
450 (and (string-match regexp (car elt)) 449 (and (string-match regexp (car elt))
451 (setq delete-list (cons (car elt) delete-list)))) 450 (push (car elt) delete-list)))
452 file-cache-alist) 451 file-cache-alist)
453 (file-cache-delete-file-list delete-list) 452 (file-cache-delete-file-list delete-list)
454 (message "Filecache: deleted %d files from file cache" 453 (message "Filecache: deleted %d files from file cache"
@@ -460,7 +459,7 @@ or the optional REGEXP argument."
460 (let ((dir (expand-file-name directory)) 459 (let ((dir (expand-file-name directory))
461 (result 0)) 460 (result 0))
462 (mapc 461 (mapc
463 '(lambda (entry) 462 (lambda (entry)
464 (if (file-cache-do-delete-directory dir entry) 463 (if (file-cache-do-delete-directory dir entry)
465 (setq result (1+ result)))) 464 (setq result (1+ result))))
466 file-cache-alist) 465 file-cache-alist)
@@ -669,26 +668,11 @@ the name is considered already unique; only the second substitution
669(defun file-cache-complete () 668(defun file-cache-complete ()
670 "Complete the word at point, using the filecache." 669 "Complete the word at point, using the filecache."
671 (interactive) 670 (interactive)
672 (let (start pattern completion all) 671 (let ((start
673 (save-excursion 672 (save-excursion
674 (skip-syntax-backward "^\"") 673 (skip-syntax-backward "^\"")
675 (setq start (point))) 674 (point))))
676 (setq pattern (buffer-substring-no-properties start (point))) 675 (completion-in-region start (point) file-cache-alist)))
677 (setq completion (try-completion pattern file-cache-alist))
678 (setq all (all-completions pattern file-cache-alist nil))
679 (cond ((eq completion t))
680 ((null completion)
681 (message "Can't find completion for \"%s\"" pattern)
682 (ding))
683 ((not (string= pattern completion))
684 (delete-region start (point))
685 (insert completion)
686 )
687 (t
688 (with-output-to-temp-buffer "*Completions*"
689 (display-completion-list all pattern))
690 ))
691 ))
692 676
693;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 677;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
694;; Show parts of the cache 678;; Show parts of the cache