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 "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 for confirmation to open it literally (read-only, disabled undo and in
fundamental-mode) for performance sake." fundamental-mode) for performance sake."
(let* ((filename (buffer-file-name)) (let ((size (nth 7 (file-attributes buffer-file-name))))
(size (nth 7 (file-attributes filename))))
(when (and (not (memq major-mode doom-large-file-modes-list)) (when (and (not (memq major-mode doom-large-file-modes-list))
size (> size (* 1024 1024 doom-large-file-size)) size (> size (* 1024 1024 doom-large-file-size))
(y-or-n-p (y-or-n-p
(format (concat "%s is a large file, open literally to " (format (concat "%s is a large file, open literally to "
"avoid performance issues?") "avoid performance issues?")
(file-relative-name filename)))) (file-relative-name buffer-file-name))))
(setq buffer-read-only t) (setq buffer-read-only t)
(buffer-disable-undo) (buffer-disable-undo)
(fundamental-mode)))) (fundamental-mode))))