Refactor doom|check-large-file
More checks, fewer false positives.
This commit is contained in:
parent
3228369d73
commit
421d00f085
1 changed files with 12 additions and 10 deletions
|
@ -49,16 +49,18 @@ successfully sets indent_style/indent_size.")
|
||||||
"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 ((size (nth 7 (file-attributes buffer-file-name))))
|
(when (and (not (memq major-mode doom-large-file-modes-list))
|
||||||
(when (and (not (memq major-mode doom-large-file-modes-list))
|
auto-mode-alist
|
||||||
size (> size (* 1024 1024 doom-large-file-size))
|
(get-buffer-window (current-buffer)))
|
||||||
(y-or-n-p
|
(when-let* ((size (nth 7 (file-attributes buffer-file-name))))
|
||||||
(format (concat "%s is a large file, open literally to "
|
(when (and (> size (* 1024 1024 doom-large-file-size))
|
||||||
"avoid performance issues?")
|
(y-or-n-p
|
||||||
(file-relative-name buffer-file-name))))
|
(format (concat "%s is a large file, open literally to "
|
||||||
(setq buffer-read-only t)
|
"avoid performance issues?")
|
||||||
(buffer-disable-undo)
|
(file-relative-name buffer-file-name))))
|
||||||
(fundamental-mode))))
|
(setq buffer-read-only t)
|
||||||
|
(buffer-disable-undo)
|
||||||
|
(fundamental-mode)))))
|
||||||
(add-hook 'find-file-hook #'doom|check-large-file)
|
(add-hook 'find-file-hook #'doom|check-large-file)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue