feat(init): force fundamental-mode for files over 5MB
Prevents performance degradation by disabling undo and setting large files to read-only fundamental-mode on open.
This commit is contained in:
@@ -159,5 +159,15 @@ If PROJECT is not specified, assume current project root."
|
|||||||
(global-corfu-mode 1)
|
(global-corfu-mode 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(defun force-fundamental-for-large-files ()
|
||||||
|
"If a file is over 5MB, open it in fundamental-mode and disable undo."
|
||||||
|
(when (> (buffer-size) (* 5 1024 1024))
|
||||||
|
(setq buffer-read-only t)
|
||||||
|
(buffer-disable-undo)
|
||||||
|
(fundamental-mode)
|
||||||
|
(message "Buffer set to fundamental-mode and read-only due to size.")))
|
||||||
|
|
||||||
|
(add-hook 'find-file-hook #'force-fundamental-for-large-files)
|
||||||
|
|
||||||
(provide 'init-functions)
|
(provide 'init-functions)
|
||||||
;;; init-functions.el ends here.
|
;;; init-functions.el ends here.
|
||||||
|
|||||||
Reference in New Issue
Block a user