From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Adrian Robert" Newsgroups: gmane.emacs.devel Subject: Re: Large-file check in files.el Date: Wed, 2 Apr 2008 20:59:03 +0300 Message-ID: <55f7df060804021059k67d01f4cmb528794524869a73@mail.gmail.com> References: <55f7df060803312155wdfe27c0w5bbbaac1562285a4@mail.gmail.com> <55f7df060804010502j689f88c4k8888030298f3d065@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1207159159 8345 80.91.229.12 (2 Apr 2008 17:59:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Apr 2008 17:59:19 +0000 (UTC) To: "emacs- devel" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 02 19:59:51 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 1Jh7FW-0002Qs-GS for ged-emacs-devel@m.gmane.org; Wed, 02 Apr 2008 19:59:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jh7Eu-0004zQ-AU for ged-emacs-devel@m.gmane.org; Wed, 02 Apr 2008 13:59:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jh7Ep-0004yd-RV for emacs-devel@gnu.org; Wed, 02 Apr 2008 13:59:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jh7Eo-0004xu-De for emacs-devel@gnu.org; Wed, 02 Apr 2008 13:59:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jh7En-0004xm-VP for emacs-devel@gnu.org; Wed, 02 Apr 2008 13:59:06 -0400 Original-Received: from wr-out-0506.google.com ([64.233.184.239]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jh7En-0004zH-Fe for emacs-devel@gnu.org; Wed, 02 Apr 2008 13:59:05 -0400 Original-Received: by wr-out-0506.google.com with SMTP id 57so2099302wri.12 for ; Wed, 02 Apr 2008 10:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=XNAD/r/wPrVJuPZ4APi/64TK2RQZjUQN0oQeXwcXpPo=; b=l/qUx8n8o3vQb+Y22pt8wXMSgdUAKwsa51/yBEnukhNrNLi5AH0fJ+2JUmf9VgtIiJJ85iZO4gFNdjXS1934fyQAqhX4XNw4cul3VkTNbVSy7ygY0RcjNYmarr907PL93ttFpcr4lQWbr/hIOFUz5JXDMVHf7pF4GfylKmccj8w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=QqlsbWZqhCmvHXDVfKZKYX2uQ4cAitJdS4ghq7YALVyNSM0ZOA89rQRKKfDzmdtmx1jkrKx0E3HrMbtJuXa3jgea3Qpwev5T0YPTa4ubm0ewX0T70uSEv5DuAEgwrQKVk/x3f5EpfFiu82SjDNR0StXfN3sPWRa0jxXD4h9ei88= Original-Received: by 10.140.125.1 with SMTP id x1mr5144394rvc.287.1207159143223; Wed, 02 Apr 2008 10:59:03 -0700 (PDT) Original-Received: by 10.141.193.8 with HTTP; Wed, 2 Apr 2008 10:59:03 -0700 (PDT) In-Reply-To: Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) 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:94216 Archived-At: > I'd call it "warn-about-large-file" or something like that and would let > it do the (error "Aborted!"). I did this and improved the doc. ------------ 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 2 Apr 2008 16:57:05 -0000 *************** *** 1507,1512 **** --- 1507,1523 ---- :version "22.1" :type '(choice integer (const :tag "Never request confirmation" nil))) + (defun abort-if-file-too-large (size op-type) + "If file SIZE larger than LARGE-FILE-WARNING-THRESHOLD, allow user to abort. + OP-TYPE specifies the file operation being performed (for message to user)." + (when (and large-file-warning-threshold size + (> size large-file-warning-threshold) + (not (y-or-n-p + (format "File %s is large (%dMB), really %s? " + (file-name-nondirectory filename) + (/ size 1048576) op-type)))) + (error "Aborted"))) + (defun find-file-noselect (filename &optional nowarn rawfile wildcards) "Read file FILENAME into a buffer and return the buffer. If a buffer exists visiting FILENAME, return that one, but *************** *** 1558,1573 **** (if (or find-file-existing-other-name find-file-visit-truename) (setq buf other)))) ;; Check to see if the file looks uncommonly large. ! (when (and large-file-warning-threshold (nth 7 attributes) ! ;; Don't ask again if we already have the file or ! ;; if we're asked to be quiet. ! (not (or buf nowarn)) ! (> (nth 7 attributes) large-file-warning-threshold) ! (not (y-or-n-p ! (format "File %s is large (%dMB), really open? " ! (file-name-nondirectory filename) ! (/ (nth 7 attributes) 1048576))))) ! (error "Aborted")) (if buf ;; We are using an existing buffer. (let (nonexistent) --- 1569,1576 ---- (if (or find-file-existing-other-name find-file-visit-truename) (setq buf other)))) ;; Check to see if the file looks uncommonly large. ! (when (not (or buf nowarn)) ! (abort-if-file-too-large (nth 7 attributes) "open")) (if buf ;; We are using an existing buffer. (let (nonexistent) *************** *** 1796,1801 **** --- 1799,1806 ---- (if (file-directory-p filename) (signal 'file-error (list "Opening input file" "file is a directory" filename))) + ;; Check whether the file is uncommonly large + (abort-if-file-too-large (nth 7 (file-attributes filename)) "insert") (let* ((buffer (find-buffer-visiting (abbreviate-file-name (file-truename filename)) #'buffer-modified-p)) (tem (funcall insert-func filename)))