2002-04-30 20:42:40 +00:00
|
|
|
;;; filecache.el --- find files using a pre-loaded cache
|
2009-10-24 03:51:51 +00:00
|
|
|
|
2013-01-01 09:11:05 +00:00
|
|
|
;; Copyright (C) 1996, 2000-2013 Free Software Foundation, Inc.
|
2009-10-24 03:51:51 +00:00
|
|
|
|
1998-05-01 04:50:27 +00:00
|
|
|
;; Author: Peter Breton <pbreton@cs.umb.edu>
|
1997-06-22 20:08:32 +00:00
|
|
|
;; Created: Sun Nov 10 1996
|
1998-05-26 09:23:23 +00:00
|
|
|
;; Keywords: convenience
|
1998-01-03 00:04:35 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-06-22 20:08:32 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1998-01-03 00:04:35 +00:00
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
1997-06-22 20:08:32 +00:00
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1998-01-03 00:04:35 +00:00
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 08:06:51 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1998-01-03 00:04:35 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; The file-cache package is an attempt to make it easy to locate files
|
|
|
|
;; by name, without having to remember exactly where they are located.
|
|
|
|
;; This is very handy when working with source trees. You can also add
|
|
|
|
;; frequently used files to the cache to create a hotlist effect.
|
|
|
|
;; The cache can be used with any interactive command which takes a
|
|
|
|
;; filename as an argument.
|
|
|
|
;;
|
|
|
|
;; It is worth noting that this package works best when most of the files
|
|
|
|
;; in the cache have unique names, or (if they have the same name) exist in
|
|
|
|
;; only a few directories. The worst case is many files all with
|
|
|
|
;; the same name and in different directories, for example a big source tree
|
|
|
|
;; with a Makefile in each directory. In such a case, you should probably
|
|
|
|
;; use an alternate strategy to find the files.
|
|
|
|
;;
|
|
|
|
;; ADDING FILES TO THE CACHE:
|
|
|
|
;;
|
|
|
|
;; Use the following functions to add items to the file cache:
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1997-06-22 20:08:32 +00:00
|
|
|
;; * `file-cache-add-file': Adds a single file to the cache
|
|
|
|
;;
|
|
|
|
;; * `file-cache-add-file-list': Adds a list of files to the cache
|
|
|
|
;;
|
|
|
|
;; The following functions use the regular expressions in
|
|
|
|
;; `file-cache-delete-regexps' to eliminate unwanted files:
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1997-06-22 20:08:32 +00:00
|
|
|
;; * `file-cache-add-directory': Adds the files in a directory to the
|
|
|
|
;; cache. You can also specify a regular expression to match the files
|
|
|
|
;; which should be added.
|
|
|
|
;;
|
|
|
|
;; * `file-cache-add-directory-list': Same as above, but acts on a list
|
|
|
|
;; of directories. You can use `load-path', `exec-path' and the like.
|
|
|
|
;;
|
|
|
|
;; * `file-cache-add-directory-using-find': Uses the `find' command to
|
|
|
|
;; add a directory tree to the cache.
|
|
|
|
;;
|
|
|
|
;; * `file-cache-add-directory-using-locate': Uses the `locate' command to
|
|
|
|
;; add files matching a pattern to the cache.
|
|
|
|
;;
|
2003-03-22 12:43:50 +00:00
|
|
|
;; * `file-cache-add-directory-recursively': Uses the find-lisp package to
|
|
|
|
;; add all files matching a pattern to the cache.
|
|
|
|
;;
|
1997-06-22 20:08:32 +00:00
|
|
|
;; Use the function `file-cache-clear-cache' to remove all items from the
|
|
|
|
;; cache. There are a number of `file-cache-delete' functions provided
|
|
|
|
;; as well, but in general it is probably better to not worry too much
|
|
|
|
;; about extra files in the cache.
|
|
|
|
;;
|
|
|
|
;; The most convenient way to initialize the cache is with an
|
1998-05-01 04:50:27 +00:00
|
|
|
;; `eval-after-load' function, as noted in the ADDING FILES
|
|
|
|
;; AUTOMATICALLY section.
|
1997-06-22 20:08:32 +00:00
|
|
|
;;
|
|
|
|
;; FINDING FILES USING THE CACHE:
|
|
|
|
;;
|
|
|
|
;; You can use the file-cache with any function that expects a filename as
|
|
|
|
;; an argument. For example:
|
|
|
|
;;
|
|
|
|
;; 1) Invoke a function which expects a filename as an argument:
|
|
|
|
;; M-x find-file
|
|
|
|
;;
|
|
|
|
;; 2) Begin typing a file name.
|
|
|
|
;;
|
|
|
|
;; 3) Invoke `file-cache-minibuffer-complete' (bound by default to
|
|
|
|
;; C-TAB) to complete on the filename using the cache.
|
|
|
|
;;
|
|
|
|
;; 4) When you have found a unique completion, the minibuffer contents
|
|
|
|
;; will change to the full name of that file.
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1997-06-22 20:08:32 +00:00
|
|
|
;; If there are a number of directories which contain the completion,
|
|
|
|
;; invoking `file-cache-minibuffer-complete' repeatedly will cycle through
|
|
|
|
;; them.
|
|
|
|
;;
|
|
|
|
;; 5) You can then edit the minibuffer contents, or press RETURN.
|
|
|
|
;;
|
|
|
|
;; It is much easier to simply try it than trying to explain it :)
|
|
|
|
;;
|
1998-05-01 04:50:27 +00:00
|
|
|
;;; ADDING FILES AUTOMATICALLY
|
1997-06-22 20:08:32 +00:00
|
|
|
;;
|
|
|
|
;; For maximum utility, you should probably define an `eval-after-load'
|
|
|
|
;; form which loads your favorite files:
|
|
|
|
;;
|
2000-08-28 20:20:49 +00:00
|
|
|
;; (eval-after-load
|
1997-06-22 20:08:32 +00:00
|
|
|
;; "filecache"
|
|
|
|
;; '(progn
|
|
|
|
;; (message "Loading file cache...")
|
|
|
|
;; (file-cache-add-directory-using-find "~/projects")
|
|
|
|
;; (file-cache-add-directory-list load-path)
|
|
|
|
;; (file-cache-add-directory "~/")
|
|
|
|
;; (file-cache-add-file-list (list "~/foo/bar" "~/baz/bar"))
|
|
|
|
;; ))
|
|
|
|
;;
|
|
|
|
;; If you clear and reload the cache frequently, it is probably easiest
|
|
|
|
;; to put your initializations in a function:
|
|
|
|
;;
|
2000-08-28 20:20:49 +00:00
|
|
|
;; (eval-after-load
|
1997-06-22 20:08:32 +00:00
|
|
|
;; "filecache"
|
|
|
|
;; '(my-file-cache-initialize))
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1997-06-22 20:08:32 +00:00
|
|
|
;; (defun my-file-cache-initialize ()
|
|
|
|
;; (interactive)
|
|
|
|
;; (message "Loading file cache...")
|
|
|
|
;; (file-cache-add-directory-using-find "~/projects")
|
|
|
|
;; (file-cache-add-directory-list load-path)
|
|
|
|
;; (file-cache-add-directory "~/")
|
|
|
|
;; (file-cache-add-file-list (list "~/foo/bar" "~/baz/bar"))
|
|
|
|
;; ))
|
|
|
|
;;
|
|
|
|
;; Of course, you can still add files to the cache afterwards, via
|
|
|
|
;; Lisp functions.
|
|
|
|
;;
|
|
|
|
;; RELATED WORK:
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1997-06-22 20:08:32 +00:00
|
|
|
;; This package is a distant relative of Noah Friedman's fff utilities.
|
|
|
|
;; Our goal is pretty similar, but the implementation strategies are
|
|
|
|
;; different.
|
1998-01-03 00:04:35 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;;; Code:
|
|
|
|
|
1998-01-07 10:31:09 +00:00
|
|
|
(defgroup file-cache nil
|
|
|
|
"Find files using a pre-loaded cache."
|
|
|
|
:group 'files
|
1998-05-26 09:23:23 +00:00
|
|
|
:group 'convenience
|
1998-01-07 10:31:09 +00:00
|
|
|
:prefix "file-cache-")
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1998-05-01 04:50:27 +00:00
|
|
|
;; Customization Variables
|
1997-06-22 20:08:32 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;; User-modifiable variables
|
2000-08-28 20:20:49 +00:00
|
|
|
(defcustom file-cache-filter-regexps
|
2009-11-30 13:49:13 +00:00
|
|
|
;; These are also used in buffers containing lines of file names,
|
|
|
|
;; so the end-of-name is matched with $ rather than \\'.
|
2000-08-28 20:20:49 +00:00
|
|
|
(list "~$" "\\.o$" "\\.exe$" "\\.a$" "\\.elc$" ",v$" "\\.output$"
|
1999-02-17 18:16:13 +00:00
|
|
|
"\\.$" "#$" "\\.class$")
|
2008-12-03 05:48:14 +00:00
|
|
|
"List of regular expressions used as filters by the file cache.
|
1997-06-22 20:08:32 +00:00
|
|
|
File names which match these expressions will not be added to the cache.
|
2000-08-28 20:20:49 +00:00
|
|
|
Note that the functions `file-cache-add-file' and `file-cache-add-file-list'
|
1998-01-07 10:31:09 +00:00
|
|
|
do not use this variable."
|
|
|
|
:type '(repeat regexp)
|
|
|
|
:group 'file-cache)
|
1997-06-22 20:08:32 +00:00
|
|
|
|
1998-01-07 10:31:09 +00:00
|
|
|
(defcustom file-cache-find-command "find"
|
2008-12-03 05:48:14 +00:00
|
|
|
"External program used by `file-cache-add-directory-using-find'."
|
1998-01-07 10:31:09 +00:00
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2004-01-27 18:59:34 +00:00
|
|
|
(defcustom file-cache-find-command-posix-flag 'not-defined
|
2008-12-03 05:48:14 +00:00
|
|
|
"Set to t, if `file-cache-find-command' handles wildcards POSIX style.
|
2004-01-27 18:59:34 +00:00
|
|
|
This variable is automatically set to nil or non-nil
|
|
|
|
if it has the initial value `not-defined' whenever you first
|
|
|
|
call the `file-cache-add-directory-using-find'.
|
|
|
|
|
|
|
|
Under Windows operating system where Cygwin is available, this value
|
|
|
|
should be t."
|
|
|
|
:type '(choice (const :tag "Yes" t)
|
|
|
|
(const :tag "No" nil)
|
|
|
|
(const :tag "Unknown" not-defined))
|
|
|
|
:group 'file-cache)
|
|
|
|
|
1998-01-07 10:31:09 +00:00
|
|
|
(defcustom file-cache-locate-command "locate"
|
2008-12-03 05:48:14 +00:00
|
|
|
"External program used by `file-cache-add-directory-using-locate'."
|
1998-01-07 10:31:09 +00:00
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
;; Minibuffer messages
|
1998-01-07 10:31:09 +00:00
|
|
|
(defcustom file-cache-no-match-message " [File Cache: No match]"
|
|
|
|
"Message to display when there is no completion."
|
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
|
|
|
|
|
|
|
(defcustom file-cache-sole-match-message " [File Cache: sole completion]"
|
|
|
|
"Message to display when there is only one completion."
|
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
|
|
|
|
|
|
|
(defcustom file-cache-non-unique-message
|
|
|
|
" [File Cache: complete but not unique]"
|
|
|
|
"Message to display when there is a non-unique completion."
|
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2000-08-28 20:20:49 +00:00
|
|
|
(defcustom file-cache-completion-ignore-case
|
2010-11-10 04:24:47 +00:00
|
|
|
(if (memq system-type '(ms-dos windows-nt cygwin))
|
2000-08-28 20:20:49 +00:00
|
|
|
t
|
|
|
|
completion-ignore-case)
|
1999-10-07 15:21:51 +00:00
|
|
|
"If non-nil, file-cache completion should ignore case.
|
|
|
|
Defaults to the value of `completion-ignore-case'."
|
2009-11-30 13:49:13 +00:00
|
|
|
:type 'boolean
|
|
|
|
:group 'file-cache)
|
1999-10-07 15:21:51 +00:00
|
|
|
|
2000-08-28 20:20:49 +00:00
|
|
|
(defcustom file-cache-case-fold-search
|
2010-11-10 04:24:47 +00:00
|
|
|
(if (memq system-type '(ms-dos windows-nt cygwin))
|
2000-08-28 20:20:49 +00:00
|
|
|
t
|
|
|
|
case-fold-search)
|
|
|
|
"If non-nil, file-cache completion should ignore case.
|
|
|
|
Defaults to the value of `case-fold-search'."
|
2009-11-30 13:49:13 +00:00
|
|
|
:type 'boolean
|
|
|
|
:group 'file-cache)
|
2000-08-28 20:20:49 +00:00
|
|
|
|
2003-12-29 19:12:17 +00:00
|
|
|
(defcustom file-cache-ignore-case
|
2010-11-10 04:24:47 +00:00
|
|
|
(memq system-type '(ms-dos windows-nt cygwin))
|
2003-12-29 19:12:17 +00:00
|
|
|
"Non-nil means ignore case when checking completions in the file cache.
|
|
|
|
Defaults to nil on DOS and Windows, and t on other systems."
|
2009-11-30 13:49:13 +00:00
|
|
|
:type 'boolean
|
|
|
|
:group 'file-cache)
|
2000-08-28 20:20:49 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
(defvar file-cache-multiple-directory-message nil)
|
|
|
|
|
|
|
|
;; Internal variables
|
|
|
|
;; This should be named *Completions* because that's what the function
|
|
|
|
;; switch-to-completions in simple.el expects
|
1998-01-07 10:31:09 +00:00
|
|
|
(defcustom file-cache-completions-buffer "*Completions*"
|
|
|
|
"Buffer to display completions when using the file cache."
|
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
|
|
|
|
2000-08-28 20:20:49 +00:00
|
|
|
(defcustom file-cache-buffer "*File Cache*"
|
1998-01-07 10:31:09 +00:00
|
|
|
"Buffer to hold the cache of file names."
|
|
|
|
:type 'string
|
|
|
|
:group 'file-cache)
|
|
|
|
|
|
|
|
(defcustom file-cache-buffer-default-regexp "^.+$"
|
|
|
|
"Regexp to match files in `file-cache-buffer'."
|
|
|
|
:type 'regexp
|
|
|
|
:group 'file-cache)
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
(defvar file-cache-last-completion nil)
|
|
|
|
|
|
|
|
(defvar file-cache-alist nil
|
2009-11-19 22:02:53 +00:00
|
|
|
"Internal data structure to hold cache of file names.
|
|
|
|
It is a list of entries of the form (FILENAME DIRNAME1 DIRNAME2 ...)
|
|
|
|
where FILENAME is a file name component and the entry represents N
|
|
|
|
files of names DIRNAME1/FILENAME, DIRNAME2/FILENAME, ...")
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2008-04-14 18:11:52 +00:00
|
|
|
(defvar file-cache-completions-keymap
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(set-keymap-parent map completion-list-mode-map)
|
2009-10-24 03:51:51 +00:00
|
|
|
(define-key map [mouse-2] 'file-cache-choose-completion)
|
2008-04-14 18:11:52 +00:00
|
|
|
(define-key map "\C-m" 'file-cache-choose-completion)
|
|
|
|
map)
|
1997-06-22 20:08:32 +00:00
|
|
|
"Keymap for file cache completions buffer.")
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Functions to add files to the cache
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2012-11-18 05:38:13 +00:00
|
|
|
(defun file-cache--read-list (file op-prompt)
|
|
|
|
(let* ((fun (if file 'read-file-name 'read-directory-name))
|
|
|
|
(type (if file "file" "directory"))
|
|
|
|
(prompt-1 (concat op-prompt " " type ": "))
|
|
|
|
(prompt-2 (concat op-prompt " another " type "?"))
|
|
|
|
(continue t)
|
|
|
|
result)
|
|
|
|
(while continue
|
|
|
|
(push (funcall fun prompt-1 nil nil t) result)
|
|
|
|
(setq continue (y-or-n-p prompt-2)))
|
|
|
|
(nreverse result)))
|
|
|
|
|
2006-09-10 16:26:31 +00:00
|
|
|
;;;###autoload
|
1997-06-22 20:08:32 +00:00
|
|
|
(defun file-cache-add-directory (directory &optional regexp)
|
2012-11-18 05:38:13 +00:00
|
|
|
"Add all files in DIRECTORY to the file cache.
|
|
|
|
If called from Lisp with a non-nil REGEXP argument is non-nil,
|
|
|
|
only add files whose names match REGEXP."
|
|
|
|
(interactive (list (read-directory-name "Add files from directory: "
|
|
|
|
nil nil t)
|
|
|
|
nil))
|
1998-05-01 04:50:27 +00:00
|
|
|
;; Not an error, because otherwise we can't use load-paths that
|
|
|
|
;; contain non-existent directories.
|
2012-11-18 05:38:13 +00:00
|
|
|
(when (file-accessible-directory-p directory)
|
1998-05-01 04:50:27 +00:00
|
|
|
(let* ((dir (expand-file-name directory))
|
2009-11-30 13:49:13 +00:00
|
|
|
(dir-files (directory-files dir t regexp)))
|
1998-05-01 04:50:27 +00:00
|
|
|
;; Filter out files we don't want to see
|
2009-11-30 13:49:13 +00:00
|
|
|
(dolist (file dir-files)
|
2012-11-18 05:38:13 +00:00
|
|
|
(if (file-directory-p file)
|
|
|
|
(setq dir-files (delq file dir-files))
|
|
|
|
(dolist (regexp file-cache-filter-regexps)
|
|
|
|
(if (string-match regexp file)
|
|
|
|
(setq dir-files (delq file dir-files))))))
|
1998-05-01 04:50:27 +00:00
|
|
|
(file-cache-add-file-list dir-files))))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2006-09-10 16:26:31 +00:00
|
|
|
;;;###autoload
|
2012-11-18 05:38:13 +00:00
|
|
|
(defun file-cache-add-directory-list (directories &optional regexp)
|
|
|
|
"Add DIRECTORIES (a list of directory names) to the file cache.
|
|
|
|
If called interactively, read the directory names one by one.
|
2000-08-28 20:20:49 +00:00
|
|
|
If the optional REGEXP argument is non-nil, only files which match it
|
2010-04-23 00:15:47 +00:00
|
|
|
will be added to the cache. Note that the REGEXP is applied to the
|
|
|
|
files in each directory, not to the directory list itself."
|
2012-11-18 05:38:13 +00:00
|
|
|
(interactive (list (file-cache--read-list nil "Add")))
|
|
|
|
(dolist (dir directories)
|
|
|
|
(file-cache-add-directory dir regexp))
|
|
|
|
(let ((n (length directories)))
|
|
|
|
(message "Filecache: cached file names from %d director%s."
|
|
|
|
n (if (= n 1) "y" "ies"))))
|
|
|
|
|
|
|
|
(defun file-cache-add-file-list (files)
|
|
|
|
"Add FILES (a list of file names) to the file cache.
|
|
|
|
If called interactively, read the file names one by one."
|
|
|
|
(interactive (list (file-cache--read-list t "Add")))
|
|
|
|
(dolist (f files)
|
|
|
|
(file-cache-add-file f))
|
|
|
|
(let ((n (length files)))
|
|
|
|
(message "Filecache: cached %d file name%s."
|
|
|
|
n (if (= n 1) "" "s"))))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
;; Workhorse function
|
2006-09-10 16:26:31 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
1997-06-22 20:08:32 +00:00
|
|
|
(defun file-cache-add-file (file)
|
|
|
|
"Add FILE to the file cache."
|
|
|
|
(interactive "fAdd File: ")
|
2012-11-17 06:16:46 +00:00
|
|
|
(setq file (file-truename file))
|
|
|
|
(unless (file-exists-p file)
|
|
|
|
(error "Filecache: file %s does not exist" file))
|
|
|
|
(let* ((file-name (file-name-nondirectory file))
|
|
|
|
(dir-name (file-name-directory file))
|
|
|
|
(the-entry (assoc-string file-name file-cache-alist
|
|
|
|
file-cache-ignore-case)))
|
2012-11-18 05:38:13 +00:00
|
|
|
(cond ((null the-entry)
|
|
|
|
;; If the entry wasn't in the cache, add it.
|
|
|
|
(push (list file-name dir-name) file-cache-alist)
|
|
|
|
(if (called-interactively-p 'interactive)
|
|
|
|
(message "Filecache: cached file name %s." file)))
|
|
|
|
((not (member dir-name (cdr the-entry)))
|
|
|
|
(setcdr the-entry (cons dir-name (cdr the-entry)))
|
|
|
|
(if (called-interactively-p 'interactive)
|
|
|
|
(message "Filecache: cached file name %s." file)))
|
|
|
|
(t
|
|
|
|
(if (called-interactively-p 'interactive)
|
|
|
|
(message "Filecache: %s is already cached." file))))))
|
2000-08-28 20:20:49 +00:00
|
|
|
|
2006-09-10 16:26:31 +00:00
|
|
|
;;;###autoload
|
1997-06-22 20:08:32 +00:00
|
|
|
(defun file-cache-add-directory-using-find (directory)
|
|
|
|
"Use the `find' command to add files to the file cache.
|
|
|
|
Find is run in DIRECTORY."
|
|
|
|
(interactive "DAdd files under directory: ")
|
|
|
|
(let ((dir (expand-file-name directory)))
|
2004-12-13 19:46:36 +00:00
|
|
|
(when (memq system-type '(windows-nt cygwin))
|
|
|
|
(if (eq file-cache-find-command-posix-flag 'not-defined)
|
|
|
|
(setq file-cache-find-command-posix-flag
|
|
|
|
(executable-command-find-posix-p file-cache-find-command))))
|
1997-06-22 20:08:32 +00:00
|
|
|
(set-buffer (get-buffer-create file-cache-buffer))
|
|
|
|
(erase-buffer)
|
2000-08-28 20:20:49 +00:00
|
|
|
(call-process file-cache-find-command nil
|
1997-06-22 20:08:32 +00:00
|
|
|
(get-buffer file-cache-buffer) nil
|
2000-08-28 20:20:49 +00:00
|
|
|
dir "-name"
|
2004-12-13 19:43:13 +00:00
|
|
|
(if (memq system-type '(windows-nt cygwin))
|
|
|
|
(if file-cache-find-command-posix-flag
|
|
|
|
"\\*"
|
|
|
|
"'*'")
|
|
|
|
"*")
|
1997-06-22 20:08:32 +00:00
|
|
|
"-print")
|
|
|
|
(file-cache-add-from-file-cache-buffer)))
|
|
|
|
|
2006-09-10 16:26:31 +00:00
|
|
|
;;;###autoload
|
1997-06-22 20:08:32 +00:00
|
|
|
(defun file-cache-add-directory-using-locate (string)
|
|
|
|
"Use the `locate' command to add files to the file cache.
|
|
|
|
STRING is passed as an argument to the locate command."
|
|
|
|
(interactive "sAdd files using locate string: ")
|
|
|
|
(set-buffer (get-buffer-create file-cache-buffer))
|
|
|
|
(erase-buffer)
|
2000-08-28 20:20:49 +00:00
|
|
|
(call-process file-cache-locate-command nil
|
1997-06-22 20:08:32 +00:00
|
|
|
(get-buffer file-cache-buffer) nil
|
|
|
|
string)
|
|
|
|
(file-cache-add-from-file-cache-buffer))
|
|
|
|
|
2012-11-02 22:44:38 +00:00
|
|
|
(autoload 'find-lisp-find-files "find-lisp")
|
|
|
|
|
2006-09-10 16:26:31 +00:00
|
|
|
;;;###autoload
|
2003-03-22 12:43:50 +00:00
|
|
|
(defun file-cache-add-directory-recursively (dir &optional regexp)
|
|
|
|
"Adds DIR and any subdirectories to the file-cache.
|
2010-04-23 00:15:47 +00:00
|
|
|
This function does not use any external programs.
|
2003-03-22 12:43:50 +00:00
|
|
|
If the optional REGEXP argument is non-nil, only files which match it
|
2010-04-23 00:15:47 +00:00
|
|
|
will be added to the cache. Note that the REGEXP is applied to the
|
|
|
|
files in each directory, not to the directory list itself."
|
2003-03-22 12:43:50 +00:00
|
|
|
(interactive "DAdd directory: ")
|
|
|
|
(mapcar
|
2012-11-02 22:44:38 +00:00
|
|
|
(lambda (file)
|
|
|
|
(or (file-directory-p file)
|
|
|
|
(let (filtered)
|
|
|
|
(dolist (regexp file-cache-filter-regexps)
|
|
|
|
(and (string-match regexp file)
|
|
|
|
(setq filtered t)))
|
|
|
|
filtered)
|
|
|
|
(file-cache-add-file file)))
|
|
|
|
(find-lisp-find-files dir (or regexp "^"))))
|
2003-03-22 12:43:50 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
(defun file-cache-add-from-file-cache-buffer (&optional regexp)
|
|
|
|
"Add any entries found in the file cache buffer.
|
|
|
|
Each entry matches the regular expression `file-cache-buffer-default-regexp'
|
|
|
|
or the optional REGEXP argument."
|
|
|
|
(set-buffer file-cache-buffer)
|
2009-11-30 13:49:13 +00:00
|
|
|
(dolist (elt file-cache-filter-regexps)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(delete-matching-lines elt))
|
1997-06-22 20:08:32 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(let ((full-filename))
|
|
|
|
(while (re-search-forward
|
2000-08-28 20:20:49 +00:00
|
|
|
(or regexp file-cache-buffer-default-regexp)
|
1997-06-22 20:08:32 +00:00
|
|
|
(point-max) t)
|
|
|
|
(setq full-filename (buffer-substring-no-properties
|
2000-08-28 20:20:49 +00:00
|
|
|
(match-beginning 0) (match-end 0)))
|
1997-06-22 20:08:32 +00:00
|
|
|
(file-cache-add-file full-filename))))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Functions to delete from the cache
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun file-cache-clear-cache ()
|
|
|
|
"Clear the file cache."
|
|
|
|
(interactive)
|
|
|
|
(setq file-cache-alist nil))
|
|
|
|
|
|
|
|
;; This clears *all* files with the given name
|
|
|
|
(defun file-cache-delete-file (file)
|
2012-11-18 05:38:13 +00:00
|
|
|
"Delete FILE (a relative file name) from the file cache.
|
|
|
|
Return nil if FILE was not in the file cache, non-nil otherwise."
|
1997-06-22 20:08:32 +00:00
|
|
|
(interactive
|
|
|
|
(list (completing-read "Delete file from cache: " file-cache-alist)))
|
2012-11-18 05:38:13 +00:00
|
|
|
(let ((elt (assoc-string file file-cache-alist file-cache-ignore-case)))
|
|
|
|
(setq file-cache-alist (delq elt file-cache-alist))
|
|
|
|
elt))
|
|
|
|
|
|
|
|
(defun file-cache-delete-file-list (files &optional message)
|
|
|
|
"Delete FILES (a list of files) from the file cache.
|
|
|
|
If called interactively, read the file names one by one.
|
|
|
|
If MESSAGE is non-nil, or if called interactively, print a
|
|
|
|
message reporting the number of file names deleted."
|
|
|
|
(interactive (list (file-cache--read-list t "Uncache") t))
|
|
|
|
(let ((n 0))
|
|
|
|
(dolist (f files)
|
|
|
|
(if (file-cache-delete-file f)
|
|
|
|
(setq n (1+ n))))
|
|
|
|
(message "Filecache: uncached %d file name%s."
|
|
|
|
n (if (= n 1) "" "s"))))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
(defun file-cache-delete-file-regexp (regexp)
|
|
|
|
"Delete files matching REGEXP from the file cache."
|
|
|
|
(interactive "sRegexp: ")
|
|
|
|
(let ((delete-list))
|
2009-11-30 13:49:13 +00:00
|
|
|
(dolist (elt file-cache-alist)
|
|
|
|
(and (string-match regexp (car elt))
|
|
|
|
(push (car elt) delete-list)))
|
2012-11-18 05:38:13 +00:00
|
|
|
(file-cache-delete-file-list delete-list)))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
(defun file-cache-delete-directory (directory)
|
|
|
|
"Delete DIRECTORY from the file cache."
|
|
|
|
(interactive "DDelete directory from file cache: ")
|
|
|
|
(let ((dir (expand-file-name directory))
|
2012-11-18 05:38:13 +00:00
|
|
|
(n 0))
|
2009-11-30 13:49:13 +00:00
|
|
|
(dolist (entry file-cache-alist)
|
|
|
|
(if (file-cache-do-delete-directory dir entry)
|
2012-11-18 05:38:13 +00:00
|
|
|
(setq n (1+ n))))
|
|
|
|
(message "Filecache: uncached %d file name%s."
|
|
|
|
n (if (= n 1) "" "s"))))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
(defun file-cache-do-delete-directory (dir entry)
|
|
|
|
(let ((directory-list (cdr entry))
|
2009-11-30 13:49:13 +00:00
|
|
|
(directory (file-cache-canonical-directory dir)))
|
1997-06-22 20:08:32 +00:00
|
|
|
(and (member directory directory-list)
|
|
|
|
(if (equal 1 (length directory-list))
|
2000-08-28 20:20:49 +00:00
|
|
|
(setq file-cache-alist
|
1997-06-22 20:08:32 +00:00
|
|
|
(delq entry file-cache-alist))
|
2009-11-30 13:49:13 +00:00
|
|
|
(setcdr entry (delete directory directory-list))))))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2012-11-18 05:38:13 +00:00
|
|
|
(defun file-cache-delete-directory-list (directories)
|
|
|
|
"Delete DIRECTORIES (a list of directory names) from the file cache.
|
|
|
|
If called interactively, read the directory names one by one."
|
|
|
|
(interactive (list (file-cache--read-list nil "Uncache")))
|
|
|
|
(dolist (d directories)
|
|
|
|
(file-cache-delete-directory d)))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Utility functions
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;; Returns the name of a directory for a file in the cache
|
|
|
|
(defun file-cache-directory-name (file)
|
2003-12-29 19:12:17 +00:00
|
|
|
(let* ((directory-list (cdr (assoc-string
|
|
|
|
file file-cache-alist
|
|
|
|
file-cache-ignore-case)))
|
1997-06-22 20:08:32 +00:00
|
|
|
(len (length directory-list))
|
|
|
|
(directory)
|
2009-11-30 13:49:13 +00:00
|
|
|
(num))
|
1997-06-22 20:08:32 +00:00
|
|
|
(if (not (listp directory-list))
|
2004-02-16 13:41:03 +00:00
|
|
|
(error "Filecache: unknown type in file-cache-alist for key %s" file))
|
2000-08-28 20:20:49 +00:00
|
|
|
(cond
|
1997-06-22 20:08:32 +00:00
|
|
|
;; Single element
|
|
|
|
((eq 1 len)
|
|
|
|
(setq directory (elt directory-list 0)))
|
|
|
|
;; No elements
|
|
|
|
((eq 0 len)
|
2004-02-16 13:41:03 +00:00
|
|
|
(error "Filecache: no directory found for key %s" file))
|
1997-06-22 20:08:32 +00:00
|
|
|
;; Multiple elements
|
|
|
|
(t
|
2000-12-01 03:35:56 +00:00
|
|
|
(let* ((minibuffer-dir (file-name-directory (minibuffer-contents)))
|
2009-11-30 13:49:13 +00:00
|
|
|
(dir-list (member minibuffer-dir directory-list)))
|
1997-06-22 20:08:32 +00:00
|
|
|
(setq directory
|
|
|
|
;; If the directory is in the list, return the next element
|
|
|
|
;; Otherwise, return the first element
|
2000-08-28 20:20:49 +00:00
|
|
|
(if dir-list
|
|
|
|
(or (elt directory-list
|
1997-06-22 20:08:32 +00:00
|
|
|
(setq num (1+ (- len (length dir-list)))))
|
|
|
|
(elt directory-list (setq num 0)))
|
2009-11-30 13:49:13 +00:00
|
|
|
(elt directory-list (setq num 0)))))))
|
1997-06-22 20:08:32 +00:00
|
|
|
;; If there were multiple directories, set up a minibuffer message
|
|
|
|
(setq file-cache-multiple-directory-message
|
|
|
|
(and num (format " [%d of %d]" (1+ num) len)))
|
|
|
|
directory))
|
|
|
|
|
|
|
|
;; Returns the name of a file in the cache
|
|
|
|
(defun file-cache-file-name (file)
|
|
|
|
(let ((directory (file-cache-directory-name file)))
|
|
|
|
(concat directory file)))
|
2000-08-28 20:20:49 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;; Return a canonical directory for comparison purposes.
|
|
|
|
;; Such a directory ends with a forward slash.
|
|
|
|
(defun file-cache-canonical-directory (dir)
|
|
|
|
(let ((directory dir))
|
|
|
|
(if (not (char-equal ?/ (string-to-char (substring directory -1))))
|
|
|
|
(concat directory "/")
|
|
|
|
directory)))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Minibuffer functions
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
1998-01-03 00:04:35 +00:00
|
|
|
;; The prefix argument works around a bug in the minibuffer completion.
|
|
|
|
;; The completion function doesn't distinguish between the states:
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1998-01-03 00:04:35 +00:00
|
|
|
;; "Multiple completions of name" (eg, Makefile, Makefile.in)
|
|
|
|
;; "Name available in multiple directories" (/tmp/Makefile, ~me/Makefile)
|
2000-08-28 20:20:49 +00:00
|
|
|
;;
|
1998-01-03 00:04:35 +00:00
|
|
|
;; The default is to do the former; a prefix arg forces the latter.
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;;;###autoload
|
1998-01-03 00:04:35 +00:00
|
|
|
(defun file-cache-minibuffer-complete (arg)
|
|
|
|
"Complete a filename in the minibuffer using a preloaded cache.
|
|
|
|
Filecache does two kinds of substitution: it completes on names in
|
|
|
|
the cache, and, once it has found a unique name, it cycles through
|
2000-08-28 20:20:49 +00:00
|
|
|
the directories that the name is available in. With a prefix argument,
|
|
|
|
the name is considered already unique; only the second substitution
|
1998-01-03 00:04:35 +00:00
|
|
|
\(directories) is done."
|
2000-08-28 20:20:49 +00:00
|
|
|
(interactive "P")
|
|
|
|
(let*
|
1997-06-22 20:08:32 +00:00
|
|
|
(
|
1999-10-07 15:21:51 +00:00
|
|
|
(completion-ignore-case file-cache-completion-ignore-case)
|
2000-08-28 20:20:49 +00:00
|
|
|
(case-fold-search file-cache-case-fold-search)
|
2000-12-01 03:35:56 +00:00
|
|
|
(string (file-name-nondirectory (minibuffer-contents)))
|
1998-01-03 00:04:35 +00:00
|
|
|
(completion-string (try-completion string file-cache-alist))
|
1997-06-22 20:08:32 +00:00
|
|
|
(completion-list)
|
|
|
|
(len)
|
2009-11-30 13:49:13 +00:00
|
|
|
(file-cache-string))
|
2000-08-28 20:20:49 +00:00
|
|
|
(cond
|
1998-01-03 00:04:35 +00:00
|
|
|
;; If it's the only match, replace the original contents
|
|
|
|
((or arg (eq completion-string t))
|
|
|
|
(setq file-cache-string (file-cache-file-name string))
|
2000-12-01 03:35:56 +00:00
|
|
|
(if (string= file-cache-string (minibuffer-contents))
|
2009-11-30 13:49:13 +00:00
|
|
|
(minibuffer-message file-cache-sole-match-message)
|
2000-12-01 03:35:56 +00:00
|
|
|
(delete-minibuffer-contents)
|
2001-11-26 16:21:06 +00:00
|
|
|
(insert file-cache-string)
|
1998-01-03 00:04:35 +00:00
|
|
|
(if file-cache-multiple-directory-message
|
2009-11-30 13:49:13 +00:00
|
|
|
(minibuffer-message file-cache-multiple-directory-message))))
|
1998-01-03 00:04:35 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;; If it's the longest match, insert it
|
|
|
|
((stringp completion-string)
|
|
|
|
;; If we've already inserted a unique string, see if the user
|
|
|
|
;; wants to use that one
|
|
|
|
(if (and (string= string completion-string)
|
2003-12-29 19:12:17 +00:00
|
|
|
(assoc-string string file-cache-alist
|
|
|
|
file-cache-ignore-case))
|
1997-06-22 20:08:32 +00:00
|
|
|
(if (and (eq last-command this-command)
|
|
|
|
(string= file-cache-last-completion completion-string))
|
2000-08-28 20:20:49 +00:00
|
|
|
(progn
|
2000-12-01 03:35:56 +00:00
|
|
|
(delete-minibuffer-contents)
|
2001-11-26 16:21:06 +00:00
|
|
|
(insert (file-cache-file-name completion-string))
|
2009-11-30 13:49:13 +00:00
|
|
|
(setq file-cache-last-completion nil))
|
|
|
|
(minibuffer-message file-cache-non-unique-message)
|
|
|
|
(setq file-cache-last-completion string))
|
1997-06-22 20:08:32 +00:00
|
|
|
(setq file-cache-last-completion string)
|
|
|
|
(setq completion-list (all-completions string file-cache-alist)
|
|
|
|
len (length completion-list))
|
|
|
|
(if (> len 1)
|
|
|
|
(progn
|
|
|
|
(goto-char (point-max))
|
2001-11-26 16:21:06 +00:00
|
|
|
(insert
|
1997-06-22 20:08:32 +00:00
|
|
|
(substring completion-string (length string)))
|
|
|
|
;; Add our own setup function to the Completions Buffer
|
|
|
|
(let ((completion-setup-hook
|
2008-04-14 18:11:52 +00:00
|
|
|
(append completion-setup-hook
|
|
|
|
(list 'file-cache-completion-setup-function))))
|
1997-06-22 20:08:32 +00:00
|
|
|
(with-output-to-temp-buffer file-cache-completions-buffer
|
2008-04-14 18:11:52 +00:00
|
|
|
(display-completion-list completion-list string))))
|
1997-06-22 20:08:32 +00:00
|
|
|
(setq file-cache-string (file-cache-file-name completion-string))
|
2000-12-01 03:35:56 +00:00
|
|
|
(if (string= file-cache-string (minibuffer-contents))
|
2009-11-30 13:49:13 +00:00
|
|
|
(minibuffer-message file-cache-sole-match-message)
|
2000-12-01 03:35:56 +00:00
|
|
|
(delete-minibuffer-contents)
|
2001-11-26 16:21:06 +00:00
|
|
|
(insert file-cache-string)
|
1997-06-22 20:08:32 +00:00
|
|
|
(if file-cache-multiple-directory-message
|
2009-11-30 13:49:13 +00:00
|
|
|
(minibuffer-message file-cache-multiple-directory-message)))
|
1997-06-22 20:08:32 +00:00
|
|
|
)))
|
2000-08-28 20:20:49 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;; No match
|
|
|
|
((eq completion-string nil)
|
2009-11-30 13:49:13 +00:00
|
|
|
(minibuffer-message file-cache-no-match-message)))))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Completion functions
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun file-cache-completion-setup-function ()
|
2008-04-14 18:11:52 +00:00
|
|
|
(with-current-buffer standard-output ;; i.e. file-cache-completions-buffer
|
|
|
|
(use-local-map file-cache-completions-keymap)))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2009-10-24 03:51:51 +00:00
|
|
|
(defun file-cache-choose-completion (&optional event)
|
1997-06-22 20:08:32 +00:00
|
|
|
"Choose a completion in the `*Completions*' buffer."
|
2009-10-24 03:51:51 +00:00
|
|
|
(interactive (list last-nonmenu-event))
|
1997-06-22 20:08:32 +00:00
|
|
|
(let ((completion-no-auto-exit t))
|
2009-10-24 03:51:51 +00:00
|
|
|
(choose-completion event)
|
1997-06-22 20:08:32 +00:00
|
|
|
(select-window (active-minibuffer-window))
|
2009-10-24 03:51:51 +00:00
|
|
|
(file-cache-minibuffer-complete nil)))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2009-10-24 03:51:51 +00:00
|
|
|
(define-obsolete-function-alias 'file-cache-mouse-choose-completion
|
|
|
|
'file-cache-choose-completion "23.2")
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2003-03-22 12:43:50 +00:00
|
|
|
(defun file-cache-complete ()
|
|
|
|
"Complete the word at point, using the filecache."
|
|
|
|
(interactive)
|
2009-11-19 22:02:53 +00:00
|
|
|
(let ((start
|
2003-03-22 12:43:50 +00:00
|
|
|
(save-excursion
|
|
|
|
(skip-syntax-backward "^\"")
|
2009-11-19 22:02:53 +00:00
|
|
|
(point))))
|
|
|
|
(completion-in-region start (point) file-cache-alist)))
|
2003-03-22 12:43:50 +00:00
|
|
|
|
1999-10-07 15:21:51 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Show parts of the cache
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun file-cache-files-matching-internal (regexp)
|
|
|
|
"Output a list of files whose names (not including directories)
|
|
|
|
match REGEXP."
|
|
|
|
(let ((results))
|
2009-11-30 13:49:13 +00:00
|
|
|
(dolist (cache-element file-cache-alist)
|
|
|
|
(and (string-match regexp (elt cache-element 0))
|
|
|
|
(push (elt cache-element 0) results)))
|
|
|
|
(nreverse results)))
|
1999-10-07 15:21:51 +00:00
|
|
|
|
|
|
|
(defun file-cache-files-matching (regexp)
|
|
|
|
"Output a list of files whose names (not including directories)
|
|
|
|
match REGEXP."
|
|
|
|
(interactive "sFind files matching regexp: ")
|
2000-08-28 20:20:49 +00:00
|
|
|
(let ((results
|
1999-10-07 15:21:51 +00:00
|
|
|
(file-cache-files-matching-internal regexp))
|
|
|
|
buf)
|
2000-08-28 20:20:49 +00:00
|
|
|
(set-buffer
|
|
|
|
(setq buf (get-buffer-create
|
1999-10-07 15:21:51 +00:00
|
|
|
"*File Cache Files Matching*")))
|
|
|
|
(erase-buffer)
|
|
|
|
(insert
|
|
|
|
(mapconcat
|
|
|
|
'identity
|
|
|
|
results
|
|
|
|
"\n"))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(display-buffer buf)))
|
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Debugging functions
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun file-cache-debug-read-from-minibuffer (file)
|
|
|
|
"Debugging function."
|
2000-08-28 20:20:49 +00:00
|
|
|
(interactive
|
1997-06-22 20:08:32 +00:00
|
|
|
(list (completing-read "File Cache: " file-cache-alist)))
|
2003-12-29 19:12:17 +00:00
|
|
|
(message "%s" (assoc-string file file-cache-alist
|
2009-11-30 13:49:13 +00:00
|
|
|
file-cache-ignore-case)))
|
1997-06-22 20:08:32 +00:00
|
|
|
|
2003-03-22 12:43:50 +00:00
|
|
|
(defun file-cache-display ()
|
|
|
|
"Display the file cache."
|
|
|
|
(interactive)
|
|
|
|
(let ((buf "*File Cache Contents*"))
|
|
|
|
(with-current-buffer
|
|
|
|
(get-buffer-create buf)
|
|
|
|
(erase-buffer)
|
2009-11-30 13:49:13 +00:00
|
|
|
(dolist (item file-cache-alist)
|
|
|
|
(insert (nth 1 item) (nth 0 item) "\n"))
|
|
|
|
(pop-to-buffer buf))))
|
2003-03-22 12:43:50 +00:00
|
|
|
|
1997-06-22 20:08:32 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Keybindings
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(provide 'filecache)
|
|
|
|
|
|
|
|
;;; filecache.el ends here
|