Function: file-cache-add-directory

file-cache-add-directory is an autoloaded, interactive and byte-compiled function defined in filecache.el.gz.

Signature

(file-cache-add-directory DIRECTORY &optional REGEXP)

Documentation

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.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/filecache.el.gz
;;;###autoload
(defun file-cache-add-directory (directory &optional regexp)
  "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))
  ;; Not an error, because otherwise we can't use load-paths that
  ;; contain non-existent directories.
  (when (file-accessible-directory-p directory)
    (let* ((dir       (expand-file-name directory))
	   (dir-files (directory-files dir t regexp)))
      ;; Filter out files we don't want to see
      (dolist (file dir-files)
	(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))))))
      (file-cache-add-file-list dir-files))))