From bed019eb18fbafffd397eaac7962e30428fe1e04 Mon Sep 17 00:00:00 2001 From: Phillip Lord Date: Mon, 16 Jan 2017 23:09:06 +0000 Subject: [PATCH] Fix file-mode errors in bootstrap. * lisp/files.el (set-auto-mode): Do not call `looking-at' on a symbol. * lisp/international/titdic-cnv.el (miscdic-convert): Use `insert-file-contents' rather than `find-file-noselect'. --- lisp/files.el | 28 ++++++++++++++++++++++------ lisp/international/titdic-cnv.el | 8 ++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index b57e35b..e7b15a8 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2911,9 +2911,18 @@ set-auto-mode (+ (point-min) magic-mode-regexp-match-limit))) (assoc-default nil magic-mode-alist (lambda (re _dummy) - (if (functionp re) - (funcall re) - (looking-at re))))))) + (cond + ;; Bug#25360 We might have a + ;; symbol which is not a + ;; function during bootstrap. + ((and + (symbolp re) + (functionp re)) + (funcall re)) + ((stringp re) + (looking-at re))) + (t (error "Problem with `magic-mode-alist'.")) + ))))) (set-auto-mode-0 done keep-mode-if-same))) ;; Next compare the filename against the entries in auto-mode-alist. (unless done @@ -2966,9 +2975,16 @@ set-auto-mode (+ (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))))))) + ;; Bug#25360 We might have a + ;; symbol which is not a + ;; function during bootstrap. + (cond + ((functionp re) + (funcall re)) + ((stringp re) + (looking-at re)) + (t (error "Problem with `magic-fallback-mode-alist'.")) + )))))) (set-auto-mode-0 done keep-mode-if-same))) (unless done (set-buffer-major-mode (current-buffer))))) diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el index 6f65d49..6986b3f 100644 --- a/lisp/international/titdic-cnv.el +++ b/lisp/international/titdic-cnv.el @@ -1168,10 +1168,10 @@ miscdic-convert "Chinese-GB")) "\" \"" title "\" t\n") (let* ((coding-system-for-read - (coding-system-change-eol-conversion coding 'unix)) - (dicbuf (find-file-noselect filename))) - (funcall converter dicbuf name title) - (kill-buffer dicbuf)) + (coding-system-change-eol-conversion coding 'unix))) + (with-temp-buffer + (insert-file-contents filename) + (funcall converter (current-buffer) name title))) (insert ";; Local Variables:\n" ";; version-control: never\n" ";; no-update-autoloads: t\n" -- 2.9.3