diff lisp/files.el @ 4720:3c92890f3750

Add `file-system-ignore-case-p', use it. 2009-10-24 Aidan Kehoe <kehoea@parhasard.net> * files.el (default-file-system-ignore-case): New variable. (file-system-case-alist): New variable. (file-system-ignore-case-p): New function; return t if file names under PATH should be treated case-insensitively. * minibuf.el (read-file-name-1, read-file-name-internal-1) (read-file-name-internal-1): * package-admin.el (package-admin-check-manifest): Use file-system-ignore-case-p instead of checking system-type directly in these functions. (Even though minibuf.el is dumped before files.el, the function is only called in interactive usage, there's no dump time order dependency here.)
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 24 Oct 2009 15:33:23 +0100
parents 13273cffca2a
children e29fcfd8df5f
line wrap: on
line diff
--- a/lisp/files.el	Mon Oct 19 12:47:21 2009 +0100
+++ b/lisp/files.el	Sat Oct 24 15:33:23 2009 +0100
@@ -4514,4 +4514,39 @@
 
 ;; END SYNC WITH FSF 21.2.
 
+;; XEmacs:
+(defvar default-file-system-ignore-case (and
+                                         (memq system-type '(windows-nt
+                                                             cygwin32
+							     darwin))
+                                         t)
+  "What `file-system-ignore-case-p' returns by default.
+This is in the case that nothing in `file-system-case-alist' matches.")
+
+;; Question; do any of the Linuxes mount Windows partitions in a fixed
+;; place?
+(defvar file-system-case-alist nil
+  "Alist to decide where file name case is significant. 
+
+The format is ((PATTERN . VAL) ...), where PATTERN is a regular expression
+matching a file name, and VAL is t if corresponding file names are
+case-insensitive, nil if corresponding file names are case sensitive. Only
+the first match will be used.
+
+This list is used by `file-system-ignore-case-p', itself used in tab
+completion; see also `default-file-system-ignore-case'.")
+
+(defun file-system-ignore-case-p (path)
+  "Return t if PATH resides on a file system with case-insensitive names.
+Otherwise, return nil.  See `file-system-case-alist' and
+`default-file-system-ignore-case'."
+  (check-argument-type #'stringp path)
+  (if file-system-case-alist
+      (loop
+        for (pattern . val)
+        in file-system-case-alist
+        do (and (string-match pattern path) (return val))
+        finally (return default-file-system-ignore-case))
+    default-file-system-ignore-case))
+
 ;;; files.el ends here