diff options
author | Phillip Lord <phillip.lord@russet.org.uk> | 2017-01-21 16:43:38 +0000 |
---|---|---|
committer | Phillip Lord <phillip.lord@russet.org.uk> | 2017-02-28 21:12:59 +0000 |
commit | 75727406535572fb8d18e0c4d92f5a033a1a0933 (patch) | |
tree | 6e22ea17d81a94022a025bd1341b5475a3ea5191 /lisp/files.el | |
parent | 1b946305182312faa7fcd838caf55dcb07b2ab04 (diff) | |
download | emacs-75727406535572fb8d18e0c4d92f5a033a1a0933.tar.gz |
Add error handling to magic-mode-alist
* lisp/files.el (set-auto-mode): Add explicit error handling in two
places.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lisp/files.el b/lisp/files.el index b7d104853c3..7c9271e2f44 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,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))))) |