Skip to content

Instantly share code, notes, and snippets.

@vishesh
Created March 13, 2021 19:15
Show Gist options
  • Select an option

  • Save vishesh/6ec8e00bcb5c5cf4ee53134a4a8d9d86 to your computer and use it in GitHub Desktop.

Select an option

Save vishesh/6ec8e00bcb5c5cf4ee53134a4a8d9d86 to your computer and use it in GitHub Desktop.
;;;----------------------------------------------------------------------------
;;; 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