Refactor doom|check-large-file

This commit is contained in:
Henrik Lissner 2018-05-07 18:14:45 +02:00
parent 3ad39af712
commit cecff39a7e
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -56,14 +56,13 @@ modes are active and the buffer is read-only.")
"Check if the buffer's file is large (see `doom-large-file-size'). If so, ask
for confirmation to open it literally (read-only, disabled undo and in
fundamental-mode) for performance sake."
(let* ((filename (buffer-file-name))
(size (nth 7 (file-attributes filename))))
(let ((size (nth 7 (file-attributes buffer-file-name))))
(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?")
(file-relative-name filename))))
(file-relative-name buffer-file-name))))
(setq buffer-read-only t)
(buffer-disable-undo)
(fundamental-mode))))