From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Felix Dietrich Newsgroups: gmane.emacs.help Subject: Re: Intelligently opening large files in emacs Date: Tue, 18 Mar 2014 17:45:34 +0100 Organization: solani.org Message-ID: <87k3brv4k1.fsf@lapfel.fritz.box> References: <877g7rrjgw.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1395161412 12410 80.91.229.3 (18 Mar 2014 16:50:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Mar 2014 16:50:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 18 17:50:22 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WPxDZ-0003kI-PU for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Mar 2014 17:50:21 +0100 Original-Received: from localhost ([::1]:36422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPxDZ-0004cz-Ev for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Mar 2014 12:50:21 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!storethat.news.telefonica.de!telefonica.de!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-X-Trace: solani.org 1395161135 9589 eJwFwQkBwDAIA0BL0EJI5fAM/xJ25xeKDoPDfH0/towe25ocQ7xMCyl1Eqd3rXNeXR2KN8EfK2MRZg== (18 Mar 2014 16:45:35 GMT) Original-X-Complaints-To: abuse@news.solani.org Original-NNTP-Posting-Date: Tue, 18 Mar 2014 16:45:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-User-ID: eJwFwQkBwDAIA0BLtE0YyOH1L2F3fHq0PigVXK6tluAqemowXHlx7zeMwnnu8LHONkk5xUixGDDb0WZp+AFb6BXI Cancel-Lock: sha1:AEqUbKaG8mV1geUOMEsMZs4nWiI= sha1:t5PzqHuzMp0BEh/ivFz+AHplGpU= X-NNTP-Posting-Host: eJwFwQERACAIA8BKGzDQOJxo/wj+y5N5KlIZenprdRuB2d2YruJROGzs4bYUd4NWOQkv0j4RnRAe Original-Xref: usenet.stanford.edu gnu.emacs.help:204316 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96587 Archived-At: Dushyant Juneja writes: > My question hence is, is there a way to integrate find-file-literally in a > way that emacs automatically opens large files using this function, and the > smaller files using the usual find-file. Please help me if such is possible. Here is my take on the problem: (defvar file-size-literal-threshold large-file-warning-threshold "Maximum size of a file above which it will get opened literally") (defadvice find-file-noselect (before open-large-files-literally) (when (file-exists-p filename) (let ((filesize (nth 7 (file-attributes filename)))) (when (and (not rawfile) (> filesize file-size-literal-threshold) (abort-if-file-too-large filesize "open literally" filename)) (setq rawfile t) ;; open file literally (setq nowarn t) ;; get rid of the question whether to open a large file )))) (ad-activate 'find-file-noselect) For testing you can simply drop that code into your *scratch* buffer and do M-x eval-buffer . If you want to disable this advise eval: (ad-disable-advice 'find-file-noselect 'before 'open-large-files-literally) -- Felix Dietrich