Commit 1dd46c28 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

(insert-file-1): Compare file size to large-file-warning-threshold and request

confirmation when warranted.
parent 8adbd6c2
......@@ -1695,6 +1695,16 @@ This function ensures that none of these modifications will take place."
(if (file-directory-p filename)
(signal 'file-error (list "Opening input file" "file is a directory"
;; Check whether the file is uncommonly large (see find-file-noselect):
(let (size)
(when (and large-file-warning-threshold
(setq size (nth 7 (file-attributes filename)))
(> size large-file-warning-threshold)
(not (y-or-n-p
(format "File %s is large (%dMB), really insert? "
(file-name-nondirectory filename)
(/ size 1048576)))))
(error "Aborted")))
(let* ((buffer (find-buffer-visiting (abbreviate-file-name (file-truename filename))
(tem (funcall insert-func filename)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment