mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-29 07:58:28 +00:00
(insert-file-1): Compare file size to large-file-warning-threshold and request
confirmation when warranted.
This commit is contained in:
parent
8adbd6c214
commit
1dd46c2862
@ -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"
|
||||
filename)))
|
||||
;; 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))
|
||||
#'buffer-modified-p))
|
||||
(tem (funcall insert-func filename)))
|
||||
|
Loading…
Reference in New Issue
Block a user