Created
March 13, 2021 19:15
-
-
Save vishesh/6ec8e00bcb5c5cf4ee53134a4a8d9d86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;;---------------------------------------------------------------------------- | |
| ;;; Large files | |
| ;;;---------------------------------------------------------------------------- | |
| (defun fast-file-view-mode () | |
| "Makes the buffer readonly and disables fontlock and other bells and whistles for faster viewing" | |
| (interactive) | |
| (setq buffer-read-only t) | |
| (buffer-disable-undo) | |
| (fundamental-mode) | |
| (font-lock-mode -1) | |
| (anzu-mode -1)) | |
| (defun large-find-file-hook () | |
| "If a file is over a given size, make the buffer read only." | |
| (when (> (buffer-size) (* 1024 1024)) | |
| (fast-file-view-mode))) | |
| (add-hook 'find-file-hook 'large-find-file-hook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment