Perform large-file checks after major-mode is decided

Fixes an issue where pdfs (in pdf-view-mode) weren't been converted
correctly because the file was declared large while it was being read in
fundamental-mode.
This commit is contained in:
Henrik Lissner 2019-10-08 21:10:42 -04:00
parent cb495aabe6
commit dc24237800
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -39,13 +39,13 @@ possible."
(if (setq doom-large-file-p
(and buffer-file-name
(not doom-large-file-p)
(not (memq major-mode doom-large-file-excluded-modes))
(file-readable-p buffer-file-name)
(> (nth 7 (file-attributes buffer-file-name))
(* 1024 1024 doom-large-file-size))))
(delay-mode-hooks
(prog1 (apply orig-fn args)
(buffer-disable-undo)
(prog1 (apply orig-fn args)
(if (memq major-mode doom-large-file-excluded-modes)
(setq doom-large-file-p nil)
(so-long-minor-mode +1)
(message "Large file detected! Cutting a few corners to improve performance...")))
(apply orig-fn args)))