Change format of doom-large-file-size-alist

Instead of mapping major modes to file size thresholds, it maps file
regexps (like auto-mode-alist) since the major mode cannot be known
before set-auto-mode is called (in after-find-file).
This commit is contained in:
Henrik Lissner 2019-12-25 02:13:53 -05:00
parent 436d36fcd2
commit 44fcbb52dc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 5 additions and 6 deletions

View file

@ -12,8 +12,8 @@ successfully sets indent_style/indent_size.")
(defvar-local doom-large-file-p nil)
(put 'doom-large-file-p 'permanent-local t)
(defvar doom-large-file-size-alist '((t . 1.0))
"An alist mapping major mode to filesize thresholds.
(defvar doom-large-file-size-alist '(("." . 1.0))
"An alist mapping regexps (like `auto-mode-alist') to filesize thresholds.
If a file is opened and discovered to be larger than the threshold, Doom
performs emergency optimizations to prevent Emacs from hanging, crashing or
@ -42,11 +42,10 @@ possible."
(if (setq doom-large-file-p
(and buffer-file-name
(not doom-large-file-p)
(file-readable-p buffer-file-name)
(> (nth 7 (file-attributes buffer-file-name))
(* 1024 1024
(cdr (or (assq major-mode doom-large-file-size-alist)
(assq 't doom-large-file-size-alist)))))))
(assoc-default buffer-file-name doom-large-file-size-alist
#'string-match-p)))))
(prog1 (apply orig-fn args)
(if (memq major-mode doom-large-file-excluded-modes)
(setq doom-large-file-p nil)

View file

@ -5,7 +5,7 @@
;; Large clojure buffers tend to be slower than large buffers of other modes, so
;; it should have a lower threshold too.
(add-to-list 'doom-large-file-size-alist '(clojure-mode . 0.5))
(add-to-list 'doom-large-file-size-alist '("\\.\\(?:clj[sc]?\\|dtm\\|edn\\)\\'" . 0.5))
;;