mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-06 05:52:32 -08: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
1 changed files with 10 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue