]> git.eshelyaron.com Git - emacs.git/commitdiff
(insert-file-1): Compare file size to large-file-warning-threshold and request
authorEli Zaretskii <eliz@gnu.org>
Fri, 8 Dec 2006 18:05:12 +0000 (18:05 +0000)
committerEli Zaretskii <eliz@gnu.org>
Fri, 8 Dec 2006 18:05:12 +0000 (18:05 +0000)
confirmation when warranted.

lisp/files.el

index 396e4c28b36fb96f1b0d65162777504a671d86b8..186dd8f3a0d3c27b0a5446696ccbe16fb5f88345 100644 (file)
@@ -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)))