From: Felix Dietrich <felix.dietrich@sperrhaken.name>
To: help-gnu-emacs@gnu.org
Subject: Re: Intelligently opening large files in emacs
Date: Tue, 18 Mar 2014 17:45:34 +0100 [thread overview]
Message-ID: <87k3brv4k1.fsf@lapfel.fritz.box> (raw)
In-Reply-To: mailman.17417.1395136301.10748.help-gnu-emacs@gnu.org
Dushyant Juneja <juneja.dushyant@gmail.com> 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
next prev parent reply other threads:[~2014-03-18 16:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 7:20 Intelligently opening large files in emacs Dushyant Juneja
2014-03-18 8:37 ` Jambunathan K
2014-03-18 9:51 ` Dushyant Juneja
2014-03-18 15:05 ` Jambunathan K
2014-03-18 16:55 ` Eli Zaretskii
2014-03-19 0:25 ` Stefan
[not found] ` <mailman.17438.1395161765.10748.help-gnu-emacs@gnu.org>
2014-03-18 18:25 ` Bug Dout
[not found] ` <mailman.17417.1395136301.10748.help-gnu-emacs@gnu.org>
2014-03-18 16:45 ` Felix Dietrich [this message]
2014-03-19 0:29 ` Stefan
2014-03-19 4:52 ` Marcin Borkowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k3brv4k1.fsf@lapfel.fritz.box \
--to=felix.dietrich@sperrhaken.name \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).