summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Lord <phillip.lord@russet.org.uk>2017-01-21 16:43:38 +0000
committerPhillip Lord <phillip.lord@russet.org.uk>2017-01-29 16:36:08 +0000
commit0f07c30b6af3d9aa0a6a034099aa384daf0a10d6 (patch)
tree30420445b4aa75ebb50cee6831dde58a6a3fe4c1
parentad07fe2ca8e3e1e8685248e9ebc144a12bae3a55 (diff)
downloademacs-fix/bootstrap-build-minimize-squash.tar.gz
Add error handling to magic-mode-alistfix/bootstrap-build-minimize-squash
* lisp/files.el (set-auto-mode): Add explicit error handling in two places.
-rw-r--r--lisp/files.el32
1 files changed, 23 insertions, 9 deletions
diff --git a/lisp/files.el b/lisp/files.el
index b57e35b9a0a..6a68c631549 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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,17 @@ 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)))))