changeset 5203:733f067a73ce

Check that MODENAME-mode is fboundp before calling it, files.el 2010-04-15 Aidan Kehoe <kehoea@parhasard.net> * files.el (hack-local-variables-prop-line) (hack-one-local-variable): Only attempt to call MODENAME-mode on encountering a -*-MODENAME-*- line if the corresponding symbol has a function binding, avoiding an error if, for example, opening a log file with XLFDs and wild cards. Thanks for the bug report, Henrique Martins!
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 15 Apr 2010 17:01:08 +0100
parents 1c615eb1e4b2
children fcdb86afcb91
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Apr 12 01:41:38 2010 -0500
+++ b/lisp/ChangeLog	Thu Apr 15 17:01:08 2010 +0100
@@ -1,3 +1,13 @@
+2010-04-15  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* files.el (hack-local-variables-prop-line)
+	(hack-one-local-variable):
+	Only attempt to call MODENAME-mode on encountering a
+	-*-MODENAME-*- line if the corresponding symbol has a function
+	binding, avoiding an error if, for example, opening a log file
+	with XLFDs and wild cards. Thanks for the bug report, Henrique
+	Martins!
+
 2010-04-09  Didier Verna  <didier@xemacs.org>
 
 	* hyper-apropos.el (hyper-apropos-get-doc): Use [not available]
--- a/lisp/files.el	Mon Apr 12 01:41:38 2010 -0500
+++ b/lisp/files.el	Thu Apr 15 17:01:08 2010 +0100
@@ -2044,7 +2044,7 @@
 		   ;; Without this guard, `normal-mode' would potentially run
 		   ;; the major mode function twice: once via `set-auto-mode'
 		   ;; and once via `hack-local-variables'.
-		   (if (not (eq mode major-mode))
+		   (if (and (not (eq mode major-mode)) (fboundp mode))
 		       (funcall mode))
 		   ))
 		(set-any-p
@@ -2091,8 +2091,9 @@
   "\"Set\" one variable in a local variables spec.
 A few variable names are treated specially."
   (cond ((eq var 'mode)
-	 (funcall (intern (concat (downcase (symbol-name val))
-				  "-mode"))))
+	 (and (fboundp (setq val (intern (concat (downcase (symbol-name val))
+						 "-mode"))))
+	      (funcall val)))
 	((eq var 'coding)
 	 ;; We have already handled coding: tag in set-auto-coding.
 	 nil)