add `doom/large-file-check to prompt literal open of large files

This commit is contained in:
Bryan Gilbert 2017-05-06 11:53:10 -04:00
parent eba9c382eb
commit 712c01f4f4
2 changed files with 28 additions and 0 deletions

View file

@ -206,3 +206,17 @@ for function signatures or notes. Run again to clear the header line."
(setq content (replace-regexp-in-string "\n" " " content t t))
(setq content (replace-regexp-in-string "\\s-+" " " content))
content)))))
;;;###autoload
(defun doom/check-large-file ()
(let* ((filename (buffer-file-name))
(size (nth 7 (file-attributes filename))))
(when (and
(not (memq major-mode doom-large-file-modes-list))
size (> size (* 1024 1024 doom-large-file-size))
(y-or-n-p (format (concat "%s is a large file, open literally to "
"avoid performance issues?")
filename)))
(setq buffer-read-only t)
(buffer-disable-undo)
(fundamental-mode))))