diff options
author | Richard M. Stallman <rms@gnu.org> | 2004-01-27 18:59:34 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2004-01-27 18:59:34 +0000 |
commit | a939e580eb6df47bba7913debd12c001090efa8d (patch) | |
tree | a9d4d696f8e332e03786bd1d75eec9a4df3b0f3c /lisp/filecache.el | |
parent | e193ee63d9f45eb3f42d91ee94d8070298f4abaf (diff) | |
download | emacs-a939e580eb6df47bba7913debd12c001090efa8d.tar.gz |
(file-cache-find-posix-p): New function. Detect Cygwin.
(file-cache-add-directory-using-find): Added Cygwin support.
(file-cache-find-command-posix-flag): New user variable.
(file-cache-add-directory): Check for directories and remove them from
dir-files.
Diffstat (limited to 'lisp/filecache.el')
-rw-r--r-- | lisp/filecache.el | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/lisp/filecache.el b/lisp/filecache.el index 71b67af355f..d983472041b 100644 --- a/lisp/filecache.el +++ b/lisp/filecache.el @@ -170,6 +170,19 @@ do not use this variable." :type 'string :group 'file-cache) +(defcustom file-cache-find-command-posix-flag 'not-defined + "*Set to t, if `file-cache-find-command' handles wildcards POSIX style. +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) + (defcustom file-cache-locate-command "locate" "*External program used by `file-cache-add-directory-using-locate'." :type 'string @@ -267,11 +280,13 @@ be added to the cache." ;; Filter out files we don't want to see (mapcar '(lambda (file) - (mapcar - '(lambda (regexp) - (if (string-match regexp file) - (setq dir-files (delq file dir-files)))) - file-cache-filter-regexps)) + (if (file-directory-p file) + (setq dir-files (delq file dir-files)) + (mapcar + '(lambda (regexp) + (if (string-match regexp file) + (setq dir-files (delq file dir-files)))) + file-cache-filter-regexps))) dir-files) (file-cache-add-file-list dir-files)))) @@ -317,17 +332,39 @@ in each directory, not to the directory list itself." file-cache-alist))) ))) +(defun file-cache-find-posix-p () + "Check if `file-cache-find-command' handles wildcards POSIX style." + (or (not (memq system-type '(ms-dos windows-nt))) ;; Include all POSIX systems. + (with-temp-buffer ;; Cygwin? + (call-process file-cache-find-command + nil + (current-buffer) + nil + "--version") + (goto-char (point-min)) + ;; Cygwin + (if (re-search-forward "GNU" nil t) + (buffer-string))))) + (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))) + (if (eq file-cache-find-command-posix-flag 'not-defined) + (setq file-cache-find-command-posix-flag (file-cache-find-posix-p))) (set-buffer (get-buffer-create file-cache-buffer)) (erase-buffer) (call-process file-cache-find-command nil (get-buffer file-cache-buffer) nil dir "-name" - (if (eq system-type 'windows-nt) "'*'" "*") + (cond + (file-cache-find-command-posix-flag + "\\*") + ((eq system-type 'windows-nt) + "'*'") + (t + "*")) "-print") (file-cache-add-from-file-cache-buffer))) |