Function: set-auto-mode--find-matching-alist-entry
set-auto-mode--find-matching-alist-entry is a byte-compiled function
defined in files.el.gz.
Signature
(set-auto-mode--find-matching-alist-entry ALIST NAME CASE-INSENSITIVE)
Documentation
Find first matching entry in ALIST for file NAME.
If CASE-INSENSITIVE, the file system of file NAME is case-insensitive.
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun set-auto-mode--find-matching-alist-entry (alist name case-insensitive)
"Find first matching entry in ALIST for file NAME.
If CASE-INSENSITIVE, the file system of file NAME is case-insensitive."
(let (mode)
(while name
(let ((newmode
(if case-insensitive
;; Filesystem is case-insensitive.
(let ((case-fold-search t))
(assoc-default name alist 'string-match))
;; Filesystem is case-sensitive.
(or
;; First match case-sensitively.
(let ((case-fold-search nil))
(assoc-default name alist 'string-match))
;; Fallback to case-insensitive match.
(and auto-mode-case-fold
(let ((case-fold-search t))
(assoc-default name alist 'string-match)))))))
(when newmode
(when mode
;; We had already found a mode but in a (REGEXP MODE t)
;; entry, so we still have to run MODE. Let's do it now.
;; FIXME: It's kind of ugly to run the function here.
;; An alternative could be to return a list of functions and
;; callers.
(set-auto-mode-0 mode t))
(setq mode newmode))
(if (and newmode
(not (functionp newmode))
(consp newmode)
(cadr newmode))
;; It's a (REGEXP MODE t): Keep looking but remember the MODE.
(setq mode (car newmode)
name (substring name 0 (match-beginning 0)))
(setq name nil))))
mode))