unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Large-file check in files.el
@ 2008-04-01  4:55 Adrian Robert
  2008-04-01  5:57 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Adrian Robert @ 2008-04-01  4:55 UTC (permalink / raw)
  To: emacs- devel

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.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-04-03 14:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-01  4:55 Large-file check in files.el Adrian Robert
2008-04-01  5:57 ` Stefan Monnier
2008-04-01 12:02   ` Adrian Robert
2008-04-01 15:56     ` Stefan Monnier
2008-04-02 17:59       ` Adrian Robert
2008-04-03 14:03         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).