* lisp/files.el (set-auto-mode): Add explicit error handling in two
places.
(narrow-to-region (point-min)
(min (point-max)
(+ (point-min) magic-mode-regexp-match-limit)))
- (assoc-default nil magic-mode-alist
- (lambda (re _dummy)
- (if (functionp re)
- (funcall re)
- (looking-at re)))))))
+ (assoc-default
+ nil magic-mode-alist
+ (lambda (re _dummy)
+ (cond
+ ((functionp re)
+ (funcall re))
+ ((stringp re)
+ (looking-at re))
+ (t
+ (error
+ "Problem in magic-mode-alist with element %s"
+ re))))))))
(set-auto-mode-0 done keep-mode-if-same)))
;; Next compare the filename against the entries in auto-mode-alist.
(unless done
(min (point-max)
(+ (point-min) magic-mode-regexp-match-limit)))
(assoc-default nil magic-fallback-mode-alist
- (lambda (re _dummy)
- (if (functionp re)
- (funcall re)
- (looking-at re)))))))
+ (lambda (re _dummy)
+ (cond
+ ((functionp re)
+ (funcall re))
+ ((stringp re)
+ (looking-at re))
+ (t
+ (error
+ "Problem with magic-fallback-mode-alist element: %s"
+ re))
+ ))))))
(set-auto-mode-0 done keep-mode-if-same)))
(unless done
(set-buffer-major-mode (current-buffer)))))