diff --git a/configs/init-functions.el b/configs/init-functions.el index 94b9768..d29f07d 100644 --- a/configs/init-functions.el +++ b/configs/init-functions.el @@ -159,5 +159,15 @@ If PROJECT is not specified, assume current project root." (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) ;;; init-functions.el ends here.