Commit 75727406 authored by Phillip Lord's avatar Phillip Lord
Browse files

Add error handling to magic-mode-alist

* lisp/files.el (set-auto-mode): Add explicit error handling in two
  places.
parent 1b946305
......@@ -2909,11 +2909,18 @@ we don't actually set it to the same mode the buffer already has."
(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
......@@ -2965,10 +2972,16 @@ we don't actually set it to the same mode the buffer already has."
(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)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment