Mercurial > emacs
comparison lisp/files.el @ 75003:bb4f2b144d6f
(auto-mode-case-fold): New defcustom.
(set-auto-mode): If non-nil, perform second case-sensitive pass
through auto-mode-alist if first pass failed.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sun, 31 Dec 2006 00:29:49 +0000 |
parents | 2711fe24b0e3 |
children | 20d27ba582d9 |
comparison
equal
deleted
inserted
replaced
75002:7237d52e0b4c | 75003:bb4f2b144d6f |
---|---|
1873 (setq font-lock-keywords (cadr font-lock-keywords)) | 1873 (setq font-lock-keywords (cadr font-lock-keywords)) |
1874 (font-lock-mode 1)) | 1874 (font-lock-mode 1)) |
1875 | 1875 |
1876 (if (fboundp 'ucs-set-table-for-input) ; don't lose when building | 1876 (if (fboundp 'ucs-set-table-for-input) ; don't lose when building |
1877 (ucs-set-table-for-input))) | 1877 (ucs-set-table-for-input))) |
1878 | |
1879 (defcustom auto-mode-case-fold nil | |
1880 "Non-nil means to try second pass through `auto-mode-alist'. | |
1881 This means that if the first case-sensitive search through the alist fails | |
1882 to find a matching major mode, a second case-insensitive search is made. | |
1883 On systems with case-insensitive file names, this variable is ignored, | |
1884 since only a single case-sensitive search through the alist is made." | |
1885 :group 'files | |
1886 :version "22.1" | |
1887 :type 'boolean) | |
1878 | 1888 |
1879 (defvar auto-mode-alist | 1889 (defvar auto-mode-alist |
1880 ;; Note: The entries for the modes defined in cc-mode.el (c-mode, | 1890 ;; Note: The entries for the modes defined in cc-mode.el (c-mode, |
1881 ;; c++-mode, java-mode and more) are added through autoload | 1891 ;; c++-mode, java-mode and more) are added through autoload |
1882 ;; directives in that file. That way is discouraged since it | 1892 ;; directives in that file. That way is discouraged since it |
2236 (let ((name buffer-file-name)) | 2246 (let ((name buffer-file-name)) |
2237 ;; Remove backup-suffixes from file name. | 2247 ;; Remove backup-suffixes from file name. |
2238 (setq name (file-name-sans-versions name)) | 2248 (setq name (file-name-sans-versions name)) |
2239 (while name | 2249 (while name |
2240 ;; Find first matching alist entry. | 2250 ;; Find first matching alist entry. |
2241 (let ((case-fold-search | 2251 (setq mode |
2242 (memq system-type '(vax-vms windows-nt cygwin)))) | 2252 (if (memq system-type '(vax-vms windows-nt cygwin)) |
2243 (if (and (setq mode (assoc-default name auto-mode-alist | 2253 ;; System is case-insensitive. |
2244 'string-match)) | 2254 (let ((case-fold-search t)) |
2245 (consp mode) | 2255 (assoc-default name auto-mode-alist |
2246 (cadr mode)) | 2256 'string-match)) |
2247 (setq mode (car mode) | 2257 ;; System is case-sensitive. |
2248 name (substring name 0 (match-beginning 0))) | 2258 (or |
2249 (setq name))) | 2259 ;; First match case-sensitively. |
2260 (let ((case-fold-search nil)) | |
2261 (assoc-default name auto-mode-alist | |
2262 'string-match)) | |
2263 ;; Fallback to case-insensitive match. | |
2264 (and auto-mode-case-fold | |
2265 (let ((case-fold-search t)) | |
2266 (assoc-default name auto-mode-alist | |
2267 'string-match)))))) | |
2268 (if (and mode | |
2269 (consp mode) | |
2270 (cadr mode)) | |
2271 (setq mode (car mode) | |
2272 name (substring name 0 (match-beginning 0))) | |
2273 (setq name)) | |
2250 (when mode | 2274 (when mode |
2251 (set-auto-mode-0 mode keep-mode-if-same))))))))) | 2275 (set-auto-mode-0 mode keep-mode-if-same))))))))) |
2252 | 2276 |
2253 ;; When `keep-mode-if-same' is set, we are working on behalf of | 2277 ;; When `keep-mode-if-same' is set, we are working on behalf of |
2254 ;; set-visited-file-name. In that case, if the major mode specified is the | 2278 ;; set-visited-file-name. In that case, if the major mode specified is the |