Mercurial > emacs
changeset 74501:65224088bcb2
(insert-file-1): Compare file size to large-file-warning-threshold and request
confirmation when warranted.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 08 Dec 2006 18:05:12 +0000 |
parents | fc3f19833659 |
children | 71ba31e36296 |
files | lisp/files.el |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/files.el Fri Dec 08 17:50:37 2006 +0000 +++ b/lisp/files.el Fri Dec 08 18:05:12 2006 +0000 @@ -1695,6 +1695,16 @@ (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)))