I'm not sure whether the use of
apply is recommended here. Is there a better/standard solution for setting the major mode dynamically? I couldn't find any other.
Whenever I get the
X has auto save data; consider M-x recover-this-file
message in Emacs, I wonder what the difference between the current file and the auto-save version is. Since most of the time I can't be bothered to look it up, I tried to automate the task:
(defun ediff-auto-save ()
"Ediff current file and its auto-save pendant."
(let ((auto-file-name (make-auto-save-file-name))
(ediff-files buffer-file-name auto-file-name)
(switch-to-buffer-other-window (file-name-nondirectory auto-file-name))
(apply file-major-mode '())
(other-window 1))) ;; back to ediff panel
The code does what I want, it opens the auto-save file and starts ediff. I also set the auto-save file's major mode to the major mode of the original file for consistent font lock.