[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Large-file check in files.el
From: |
Stefan Monnier |
Subject: |
Re: Large-file check in files.el |
Date: |
Tue, 01 Apr 2008 01:57:43 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
> 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.
That makes sense. But please factor out the size-check code into its
own function which you can then call from both places. This will be
better than duplicating the code like your patch currently does.
Stefan
> 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.