From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Large-file check in files.el Date: Tue, 01 Apr 2008 01:57:43 -0400 Message-ID: References: <55f7df060803312155wdfe27c0w5bbbaac1562285a4@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1207029495 25341 80.91.229.12 (1 Apr 2008 05:58:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Apr 2008 05:58:15 +0000 (UTC) Cc: emacs- devel To: "Adrian Robert" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 01 07:58:46 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JgZW9-0002mt-Bk for ged-emacs-devel@m.gmane.org; Tue, 01 Apr 2008 07:58:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JgZVX-0001UW-5V for ged-emacs-devel@m.gmane.org; Tue, 01 Apr 2008 01:58:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JgZVT-0001Tc-0L for emacs-devel@gnu.org; Tue, 01 Apr 2008 01:58:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JgZVN-0001Jm-Gs for emacs-devel@gnu.org; Tue, 01 Apr 2008 01:58:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JgZVN-0001JQ-A2 for emacs-devel@gnu.org; Tue, 01 Apr 2008 01:57:57 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182] helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JgZVM-0003zA-WA for emacs-devel@gnu.org; Tue, 01 Apr 2008 01:57:57 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq0EAD9s8UdMCrUE/2dsb2JhbACBWqkM X-IronPort-AV: E=Sophos;i="4.25,585,1199682000"; d="scan'208";a="17268460" Original-Received: from smtp.pppoe.ca (HELO smtp.teksavvy.com) ([65.39.196.238]) by ironport2-out.teksavvy.com with ESMTP; 01 Apr 2008 01:57:43 -0400 Original-Received: from pastel.home ([76.10.181.4]) by smtp.teksavvy.com (Internet Mail Server v1.0) with ESMTP id HJG90643; Tue, 01 Apr 2008 01:57:43 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 7C03D7FDF; Tue, 1 Apr 2008 01:57:43 -0400 (EDT) In-Reply-To: <55f7df060803312155wdfe27c0w5bbbaac1562285a4@mail.gmail.com> (Adrian Robert's message of "Tue, 1 Apr 2008 07:55:59 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:94091 Archived-At: > 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.