bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] 21.3 filecache.el - Added Cygwin support


From: Jari Aalto+mail.emacs
Subject: [patch] 21.3 filecache.el - Added Cygwin support
Date: Sat, 24 Jan 2004 11:25:08 +0200

2004-01-24 Sat  Jari Aalto  <jari.aalto@poboxes.com>

        * filecache.el
        (file-cache-find-unix-p): New function. Detect Cygwin.
        (file-cache-add-directory-using-find): Added Cygwin support
        (file-cache-find-command-unix-flag): New user variable.


Index: filecache.el
===================================================================
RCS file: 
/cygdrive/h/data/version-control/cvsroot/emacs/gnu-emacs/lisp213/filecache.el,v
retrieving revision 1.2
diff -u -IId: -b -w -u -r1.2 filecache.el
--- filecache.el        24 Jan 2004 08:32:49 -0000      1.2
+++ filecache.el        24 Jan 2004 09:18:06 -0000
@@ -165,6 +165,17 @@
   :type 'string
   :group 'file-cache)
 
+(defcustom file-cache-find-command-unix-flag 'not-defined
+  "*Set to t, if `file-cache-find-command' us Unix type find.
+This variable is automatically set to nil or non-nil if the initial value
+is 'not-defined by first call to function
+`file-cache-add-directory-using-find'.
+
+Under Windows operating system where Cygwin is available, this value
+should be set to t."
+  :type  'boolean
+  :group 'file-cache)
+
 (defcustom file-cache-locate-command "locate"
   "*External program used by `file-cache-add-directory-using-locate'."
   :type 'string
@@ -316,17 +327,39 @@
                     file-cache-alist)))
       )))
 
+(defun file-cache-find-unix-p ()
+  "Check if `file-cache-find-command' is Unix type program."
+  (or (not (eq system-type 'windows-nt))  ;; Assume Unix system
+      (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-unix-flag 'not-defined)
+        (setq file-cache-find-command-unix-flag (file-cache-find-unix-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-unix-flag
+                    "\\*")
+                   ((eq system-type 'windows-nt)
+                    "'*'")
+                   (t
+                    "*"))
                   "-print")
     (file-cache-add-from-file-cache-buffer)))
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]