In my .emacs file, I have:
(setq-default major-mode
(lambda ()
(let ((buffer-file-name
(replace-regexp-in-string
"\\.tmp$" ""
(or buffer-file-name (buffer-name)))))
(set-auto-mode)
)))
This ended up causing files such as 'foo.el.tmp' to open in emacs-lisp-mode
.
Once I upgraded Emacs, this started breaking; when I open a buffer that doesn't exist that should be open in fundamental-mode, such as 'asdfg', I get an error:
image-type-from-buffer: Variable binding depth exceeds max-specpdl-size
This seems to be due to (set-auto-mode) in major-mode calling now being recursive.
What's the best way to do this?
major-mode
to a lambda form? See the doc for it - the value is expected to be a symbol. Dunno whether that is relevant to your issue, however.