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:
2026-05-30 00:55:50 -03:00
parent 6458dad64e
commit 1e75763616

View File

@@ -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.