emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: large-file-warning-threshold and insert-file


From: Kevin Rodgers
Subject: Re: large-file-warning-threshold and insert-file
Date: Mon, 04 Dec 2006 11:33:54 -0700
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

Richard Stallman wrote:
    Should `M-x insert-file' also check the file size and ask for
    confirmation?

That seems like a good idea.

Note that insert-file-1 is called by both insert-file and
insert-file-literally:

2006-12-01  Kevin Rodgers  <address@hidden>

        * files.el (insert-file-1): Compare file size to
        large-file-warning-threshold and request confirmation when
        warranted.


*** files.el.orig       2006-11-28 02:20:32 -0000
--- files.el    2006-12-01 11:53:47.316966000 -0700
***************
*** 1695,1700 ****
--- 1695,1710 ----
    (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)))

--
Kevin





reply via email to

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