emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Large-file check in files.el


From: Adrian Robert
Subject: Large-file check in files.el
Date: Tue, 1 Apr 2008 07:55:59 +0300

Hi,

In find-file-noselect, confirmation is required for filesize >
large-file-warning-threshold, yet in insert-file-1, it is not.  Is
there a reason large files should be allowed to be inserted -- but not
loaded by themselves -- without confirmation?  If not, I propose the
patch below.

thanks,
Adrian
------------

Index: files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.966
diff -c -b -r1.966 files.el
*** files.el    14 Mar 2008 17:14:09 -0000      1.966
--- files.el    1 Apr 2008 04:55:25 -0000
***************
*** 1796,1801 ****
--- 1796,1811 ----
    (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)))


Diffs between working revision and workfile end here.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]