Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
57089611
Commit
57089611
authored
Mar 22, 2003
by
Peter Breton
Browse files
Add file-cache-add-directory-recursively function
Add file-cache-complete function Add file-cache-display function
parent
af0ad939
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
lisp/filecache.el
lisp/filecache.el
+69
-0
No files found.
lisp/filecache.el
View file @
57089611
...
...
@@ -63,6 +63,9 @@
;; * `file-cache-add-directory-using-locate': Uses the `locate' command to
;; add files matching a pattern to the cache.
;;
;; * `file-cache-add-directory-recursively': Uses the find-lisp package to
;; add all files matching a pattern to the cache.
;;
;; 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
...
...
@@ -138,6 +141,9 @@
;;; Code:
(
eval-when-compile
(
require
'find-lisp
))
(
defgroup
file-cache
nil
"Find files using a pre-loaded cache."
:group
'files
...
...
@@ -338,6 +344,30 @@ STRING is passed as an argument to the locate command."
string
)
(
file-cache-add-from-file-cache-buffer
))
(
defun
file-cache-add-directory-recursively
(
dir
&optional
regexp
)
"Adds DIR and any subdirectories to the file-cache.
This function does not use any external programs
If the optional REGEXP argument is non-nil, only files which match it
will be added to the cache. Note that the REGEXP is applied to the files
in each directory, not to the directory list itself."
(
interactive
"DAdd directory: "
)
(
require
'find-lisp
)
(
mapcar
(
function
(
lambda
(
file
)
(
or
(
file-directory-p
file
)
(
let
(
filtered
)
(
mapcar
(
function
(
lambda
(
regexp
)
(
and
(
string-match
regexp
file
)
(
setq
filtered
t
))
))
file-cache-filter-regexps
)
filtered
)
(
file-cache-add-file
file
))))
(
find-lisp-find-files
dir
(
if
regexp
regexp
"^"
))))
(
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'
...
...
@@ -625,6 +655,30 @@ the name is considered already unique; only the second substitution
)
)
(
defun
file-cache-complete
()
"Complete the word at point, using the filecache."
(
interactive
)
(
let
(
start
pattern
completion
all
)
(
save-excursion
(
skip-syntax-backward
"^\""
)
(
setq
start
(
point
)))
(
setq
pattern
(
buffer-substring-no-properties
start
(
point
)))
(
setq
completion
(
try-completion
pattern
file-cache-alist
))
(
setq
all
(
all-completions
pattern
file-cache-alist
nil
))
(
cond
((
eq
completion
t
))
((
null
completion
)
(
message
"Can't find completion for \"%s\""
pattern
)
(
ding
))
((
not
(
string=
pattern
completion
))
(
delete-region
start
(
point
))
(
insert
completion
)
)
(
t
(
with-output-to-temp-buffer
"*Completions*"
(
display-completion-list
all
))
))
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Show parts of the cache
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
...
...
@@ -674,6 +728,21 @@ match REGEXP."
(
message
"%s"
(
funcall
file-cache-assoc-function
file
file-cache-alist
))
)
(
defun
file-cache-display
()
"Display the file cache."
(
interactive
)
(
let
((
buf
"*File Cache Contents*"
))
(
with-current-buffer
(
get-buffer-create
buf
)
(
erase-buffer
)
(
mapcar
(
function
(
lambda
(
item
)
(
insert
(
nth
1
item
)
(
nth
0
item
)
"\n"
)))
file-cache-alist
)
(
pop-to-buffer
buf
)
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Keybindings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment