diff options
author | Eli Zaretskii <[email protected]> | 2006-12-08 18:05:12 +0000 |
---|---|---|
committer | Eli Zaretskii <[email protected]> | 2006-12-08 18:05:12 +0000 |
commit | 1dd46c28628ccb093b972bfba50ed16f5c8deedb (patch) | |
tree | 170f8d014867ae83cb0df7429f211231dd7ab7ca /lisp | |
parent | 8adbd6c21497dc6e8e6816714c8cbc50ef1e4d93 (diff) |
(insert-file-1): Compare file size to large-file-warning-threshold and request
confirmation when warranted.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/files.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el index 396e4c28b3..186dd8f3a0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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))) |