• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/

Lines Matching defs:file

10 ;; This file is part of GNU Emacs.
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 ;; The file-cache package is an attempt to make it easy to locate files
45 ;; Use the following functions to add items to the file cache:
47 ;; * `file-cache-add-file': Adds a single file to the cache
49 ;; * `file-cache-add-file-list': Adds a list of files to the cache
52 ;; `file-cache-delete-regexps' to eliminate unwanted files:
54 ;; * `file-cache-add-directory': Adds the files in a directory to the
58 ;; * `file-cache-add-directory-list': Same as above, but acts on a list
61 ;; * `file-cache-add-directory-using-find': Uses the `find' command to
64 ;; * `file-cache-add-directory-using-locate': Uses the `locate' command to
67 ;; * `file-cache-add-directory-recursively': Uses the find-lisp package to
70 ;; Use the function `file-cache-clear-cache' to remove all items from the
71 ;; cache. There are a number of `file-cache-delete' functions provided
81 ;; You can use the file-cache with any function that expects a filename as
85 ;; M-x find-file
87 ;; 2) Begin typing a file name.
89 ;; 3) Invoke `file-cache-minibuffer-complete' (bound by default to
93 ;; will change to the full name of that file.
96 ;; invoking `file-cache-minibuffer-complete' repeatedly will cycle through
111 ;; (message "Loading file cache...")
112 ;; (file-cache-add-directory-using-find "~/projects")
113 ;; (file-cache-add-directory-list load-path)
114 ;; (file-cache-add-directory "~/")
115 ;; (file-cache-add-file-list (list "~/foo/bar" "~/baz/bar"))
123 ;; '(my-file-cache-initialize))
125 ;; (defun my-file-cache-initialize ()
127 ;; (message "Loading file cache...")
128 ;; (file-cache-add-directory-using-find "~/projects")
129 ;; (file-cache-add-directory-list load-path)
130 ;; (file-cache-add-directory "~/")
131 ;; (file-cache-add-file-list (list "~/foo/bar" "~/baz/bar"))
148 (defgroup file-cache nil
152 :prefix "file-cache-")
159 (defcustom file-cache-filter-regexps
162 "*List of regular expressions used as filters by the file cache.
164 Note that the functions `file-cache-add-file' and `file-cache-add-file-list'
167 :group 'file-cache)
169 (defcustom file-cache-find-command "find"
170 "*External program used by `file-cache-add-directory-using-find'."
172 :group 'file-cache)
174 (defcustom file-cache-find-command-posix-flag 'not-defined
175 "*Set to t, if `file-cache-find-command' handles wildcards POSIX style.
178 call the `file-cache-add-directory-using-find'.
185 :group 'file-cache)
187 (defcustom file-cache-locate-command "locate"
188 "*External program used by `file-cache-add-directory-using-locate'."
190 :group 'file-cache)
193 (defcustom file-cache-no-match-message " [File Cache: No match]"
196 :group 'file-cache)
198 (defcustom file-cache-sole-match-message " [File Cache: sole completion]"
201 :group 'file-cache)
203 (defcustom file-cache-non-unique-message
207 :group 'file-cache)
209 (defcustom file-cache-completion-ignore-case
213 "If non-nil, file-cache completion should ignore case.
216 :group 'file-cache
219 (defcustom file-cache-case-fold-search
223 "If non-nil, file-cache completion should ignore case.
226 :group 'file-cache
229 (defcustom file-cache-ignore-case
231 "Non-nil means ignore case when checking completions in the file cache.
234 :group 'file-cache
237 (defvar file-cache-multiple-directory-message nil)
242 (defcustom file-cache-completions-buffer "*Completions*"
243 "Buffer to display completions when using the file cache."
245 :group 'file-cache)
247 (defcustom file-cache-buffer "*File Cache*"
248 "Buffer to hold the cache of file names."
250 :group 'file-cache)
252 (defcustom file-cache-buffer-default-regexp "^.+$"
253 "Regexp to match files in `file-cache-buffer'."
255 :group 'file-cache)
257 (defvar file-cache-last-completion nil)
259 (defvar file-cache-alist nil
260 "Internal data structure to hold cache of file names.")
262 (defvar file-cache-completions-keymap nil
263 "Keymap for file cache completions buffer.")
270 (defun file-cache-add-directory (directory &optional regexp)
271 "Add DIRECTORY to the file cache.
277 (if (not (file-accessible-directory-p directory))
279 (let* ((dir (expand-file-name directory))
284 '(lambda (file)
285 (if (file-directory-p file)
286 (setq dir-files (delq file dir-files))
289 (if (string-match regexp file)
290 (setq dir-files (delq file dir-files))))
291 file-cache-filter-regexps)))
293 (file-cache-add-file-list dir-files))))
296 (defun file-cache-add-directory-list (directory-list &optional regexp)
297 "Add DIRECTORY-LIST (a list of directory names) to the file cache.
303 '(lambda (dir) (file-cache-add-directory dir regexp))
306 (defun file-cache-add-file-list (file-list)
307 "Add FILE-LIST (a list of files names) to the file cache."
309 (mapcar 'file-cache-add-file file-list))
314 (defun file-cache-add-file (file)
315 "Add FILE to the file cache."
317 (if (not (file-exists-p file))
318 (message "Filecache: file %s does not exist" file)
319 (let* ((file-name (file-name-nondirectory file))
320 (dir-name (file-name-directory file))
322 file-name file-cache-alist
323 file-cache-ignore-case))
335 (setq file-cache-alist
336 (cons (cons file-name (list dir-name))
337 file-cache-alist)))
341 (defun file-cache-add-directory-using-find (directory)
342 "Use the `find' command to add files to the file cache.
345 (let ((dir (expand-file-name directory)))
347 (if (eq file-cache-find-command-posix-flag 'not-defined)
348 (setq file-cache-find-command-posix-flag
349 (executable-command-find-posix-p file-cache-find-command))))
350 (set-buffer (get-buffer-create file-cache-buffer))
352 (call-process file-cache-find-command nil
353 (get-buffer file-cache-buffer) nil
356 (if file-cache-find-command-posix-flag
361 (file-cache-add-from-file-cache-buffer)))
364 (defun file-cache-add-directory-using-locate (string)
365 "Use the `locate' command to add files to the file cache.
368 (set-buffer (get-buffer-create file-cache-buffer))
370 (call-process file-cache-locate-command nil
371 (get-buffer file-cache-buffer) nil
373 (file-cache-add-from-file-cache-buffer))
376 (defun file-cache-add-directory-recursively (dir &optional regexp)
377 "Adds DIR and any subdirectories to the file-cache.
386 (lambda(file)
387 (or (file-directory-p file)
392 (and (string-match regexp file)
395 file-cache-filter-regexps)
397 (file-cache-add-file file))))
400 (defun file-cache-add-from-file-cache-buffer (&optional regexp)
401 "Add any entries found in the file cache buffer.
402 Each entry matches the regular expression `file-cache-buffer-default-regexp'
404 (set-buffer file-cache-buffer)
409 file-cache-filter-regexps)
413 (or regexp file-cache-buffer-default-regexp)
417 (file-cache-add-file full-filename))))
423 (defun file-cache-clear-cache ()
424 "Clear the file cache."
426 (setq file-cache-alist nil))
429 (defun file-cache-delete-file (file)
430 "Delete FILE from the file cache."
432 (list (completing-read "Delete file from cache: " file-cache-alist)))
433 (setq file-cache-alist
434 (delq (assoc-string file file-cache-alist file-cache-ignore-case)
435 file-cache-alist)))
437 (defun file-cache-delete-file-list (file-list)
438 "Delete FILE-LIST (a list of files) from the file cache."
440 (mapcar 'file-cache-delete-file file-list))
442 (defun file-cache-delete-file-regexp (regexp)
443 "Delete files matching REGEXP from the file cache."
449 file-cache-alist)
450 (file-cache-delete-file-list delete-list)
451 (message "Filecache: deleted %d files from file cache"
454 (defun file-cache-delete-directory (directory)
455 "Delete DIRECTORY from the file cache."
456 (interactive "DDelete directory from file cache: ")
457 (let ((dir (expand-file-name directory))
461 (if (file-cache-do-delete-directory dir entry)
463 file-cache-alist)
468 (defun file-cache-do-delete-directory (dir entry)
470 (directory (file-cache-canonical-directory dir))
474 (setq file-cache-alist
475 (delq entry file-cache-alist))
480 (defun file-cache-delete-directory-list (directory-list)
481 "Delete DIRECTORY-LIST (a list of directories) from the file cache."
483 (mapcar 'file-cache-delete-directory directory-list))
489 ;; Returns the name of a directory for a file in the cache
490 (defun file-cache-directory-name (file)
492 file file-cache-alist
493 file-cache-ignore-case)))
499 (error "Filecache: unknown type in file-cache-alist for key %s" file))
506 (error "Filecache: no directory found for key %s" file))
509 (let* ((minibuffer-dir (file-name-directory (minibuffer-contents)))
524 (setq file-cache-multiple-directory-message
528 ;; Returns the name of a file in the cache
529 (defun file-cache-file-name (file)
530 (let ((directory (file-cache-directory-name file)))
531 (concat directory file)))
535 (defun file-cache-canonical-directory (dir)
554 (defun file-cache-minibuffer-complete (arg)
564 (completion-ignore-case file-cache-completion-ignore-case)
565 (case-fold-search file-cache-case-fold-search)
566 (string (file-name-nondirectory (minibuffer-contents)))
567 (completion-string (try-completion string file-cache-alist))
570 (file-cache-string)
575 (setq file-cache-string (file-cache-file-name string))
576 (if (string= file-cache-string (minibuffer-contents))
577 (file-cache-temp-minibuffer-message file-cache-sole-match-message)
579 (insert file-cache-string)
580 (if file-cache-multiple-directory-message
581 (file-cache-temp-minibuffer-message
582 file-cache-multiple-directory-message))
590 (assoc-string string file-cache-alist
591 file-cache-ignore-case))
593 (string= file-cache-last-completion completion-string))
596 (insert (file-cache-file-name completion-string))
597 (setq file-cache-last-completion nil)
599 (file-cache-temp-minibuffer-message file-cache-non-unique-message)
600 (setq file-cache-last-completion string)
602 (setq file-cache-last-completion string)
603 (setq completion-list (all-completions string file-cache-alist)
613 (append (list 'file-cache-completion-setup-function)
616 (with-output-to-temp-buffer file-cache-completions-buffer
620 (setq file-cache-string (file-cache-file-name completion-string))
621 (if (string= file-cache-string (minibuffer-contents))
622 (file-cache-temp-minibuffer-message
623 file-cache-sole-match-message)
625 (insert file-cache-string)
626 (if file-cache-multiple-directory-message
627 (file-cache-temp-minibuffer-message
628 file-cache-multiple-directory-message)))
633 (file-cache-temp-minibuffer-message file-cache-no-match-message))
638 (defun file-cache-temp-minibuffer-message (msg)
655 (defun file-cache-completion-setup-function ()
656 (set-buffer file-cache-completions-buffer)
658 (if file-cache-completions-keymap
660 (setq file-cache-completions-keymap
662 (define-key file-cache-completions-keymap [mouse-2]
663 'file-cache-mouse-choose-completion)
664 (define-key file-cache-completions-keymap "\C-m"
665 'file-cache-choose-completion))
667 (use-local-map file-cache-completions-keymap)
670 (defun file-cache-choose-completion ()
676 (file-cache-minibuffer-complete nil)
680 (defun file-cache-mouse-choose-completion (event)
686 (file-cache-minibuffer-complete nil)
690 (defun file-cache-complete ()
698 (setq completion (try-completion pattern file-cache-alist))
699 (setq all (all-completions pattern file-cache-alist nil))
718 (defun file-cache-files-matching-internal (regexp)
730 file-cache-alist)
733 (defun file-cache-files-matching (regexp)
738 (file-cache-files-matching-internal regexp))
756 (defun file-cache-debug-read-from-minibuffer (file)
759 (list (completing-read "File Cache: " file-cache-alist)))
760 (message "%s" (assoc-string file file-cache-alist
761 file-cache-ignore-case))
764 (defun file-cache-display ()
765 "Display the file cache."
775 file-cache-alist)
783 ;;;###autoload (define-key minibuffer-local-completion-map [C-tab] 'file-cache-minibuffer-complete)
784 ;;;###autoload (define-key minibuffer-local-map [C-tab] 'file-cache-minibuffer-complete)
785 ;;;###autoload (define-key minibuffer-local-must-match-map [C-tab] 'file-cache-minibuffer-complete)