]> git.eshelyaron.com Git - emacs.git/commitdiff
Add error handling to magic-mode-alist fix/bootstrap-build-minimize-squash
authorPhillip Lord <phillip.lord@russet.org.uk>
Sat, 21 Jan 2017 16:43:38 +0000 (16:43 +0000)
committerPhillip Lord <phillip.lord@russet.org.uk>
Sun, 29 Jan 2017 16:36:08 +0000 (16:36 +0000)
* lisp/files.el (set-auto-mode): Add explicit error handling in two
  places.

lisp/files.el

index b57e35b9a0a7dda6e5422a76aaf49a24a85f6225..6a68c63154958e0ac825f644acfa8dc55a44f357 100644 (file)
@@ -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)))))