comparison lisp/files.el @ 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 e29fcfd8df5f
children cdca98f2d36f
comparison
equal deleted inserted replaced
5202:1c615eb1e4b2 5203:733f067a73ce
2042 (let ((mode (intern (concat (downcase (symbol-name val)) 2042 (let ((mode (intern (concat (downcase (symbol-name val))
2043 "-mode")))) 2043 "-mode"))))
2044 ;; Without this guard, `normal-mode' would potentially run 2044 ;; Without this guard, `normal-mode' would potentially run
2045 ;; the major mode function twice: once via `set-auto-mode' 2045 ;; the major mode function twice: once via `set-auto-mode'
2046 ;; and once via `hack-local-variables'. 2046 ;; and once via `hack-local-variables'.
2047 (if (not (eq mode major-mode)) 2047 (if (and (not (eq mode major-mode)) (fboundp mode))
2048 (funcall mode)) 2048 (funcall mode))
2049 )) 2049 ))
2050 (set-any-p 2050 (set-any-p
2051 (hack-one-local-variable key val)) 2051 (hack-one-local-variable key val))
2052 (t 2052 (t
2089 2089
2090 (defun hack-one-local-variable (var val) 2090 (defun hack-one-local-variable (var val)
2091 "\"Set\" one variable in a local variables spec. 2091 "\"Set\" one variable in a local variables spec.
2092 A few variable names are treated specially." 2092 A few variable names are treated specially."
2093 (cond ((eq var 'mode) 2093 (cond ((eq var 'mode)
2094 (funcall (intern (concat (downcase (symbol-name val)) 2094 (and (fboundp (setq val (intern (concat (downcase (symbol-name val))
2095 "-mode")))) 2095 "-mode"))))
2096 (funcall val)))
2096 ((eq var 'coding) 2097 ((eq var 'coding)
2097 ;; We have already handled coding: tag in set-auto-coding. 2098 ;; We have already handled coding: tag in set-auto-coding.
2098 nil) 2099 nil)
2099 ((memq var ignored-local-variables) 2100 ((memq var ignored-local-variables)
2100 nil) 2101 nil)