From: Eli Zaretskii Date: Fri, 8 Dec 2006 18:05:12 +0000 (+0000) Subject: (insert-file-1): Compare file size to large-file-warning-threshold and request X-Git-Tag: emacs-pretest-22.0.92~231 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1dd46c28628ccb093b972bfba50ed16f5c8deedb;p=emacs.git (insert-file-1): Compare file size to large-file-warning-threshold and request confirmation when warranted. --- diff --git a/lisp/files.el b/lisp/files.el index 396e4c28b36..186dd8f3a0d 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)))