* Intelligently opening large files in emacs
@ 2014-03-18 7:20 Dushyant Juneja
2014-03-18 8:37 ` Jambunathan K
2014-03-19 0:29 ` Stefan
0 siblings, 2 replies; 10+ messages in thread
From: Dushyant Juneja @ 2014-03-18 7:20 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I'm relatively new to emacs, but am pretty fascinated by its features. One
pain point is that it is rather slow in opening large data files bound to
specific modes. I generally observe it for circuit mode files (files
utilizing verilog-mode, spice-mode and spectre-mode). Is there a
possibility to help this?
I find that M-x ffap-literally is rather fast, so can the following be done
somehow:
If file is larger than default warning limit, open it literally.
Else open it with usual mode bindings.
Also, please share as to how may I modify the default size limit.
Regards,
Dushyant Juneja
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Intelligently opening large files in emacs
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
[not found] ` <mailman.17417.1395136301.10748.help-gnu-emacs@gnu.org>
2014-03-19 0:29 ` Stefan
1 sibling, 2 replies; 10+ messages in thread
From: Jambunathan K @ 2014-03-18 8:37 UTC (permalink / raw)
To: Dushyant Juneja; +Cc: help-gnu-emacs
You are looking for vlf.el. See http://elpa.gnu.org/packages/.
Install it via
M-x list-packages
Dushyant Juneja <juneja.dushyant@gmail.com> writes:
> Hi,
>
> I'm relatively new to emacs, but am pretty fascinated by its features. One
> pain point is that it is rather slow in opening large data files bound to
> specific modes. I generally observe it for circuit mode files (files
> utilizing verilog-mode, spice-mode and spectre-mode). Is there a
> possibility to help this?
>
> I find that M-x ffap-literally is rather fast, so can the following be done
> somehow:
>
> If file is larger than default warning limit, open it literally.
> Else open it with usual mode bindings.
>
> Also, please share as to how may I modify the default size limit.
>
> Regards,
> Dushyant Juneja
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Intelligently opening large files in emacs
2014-03-18 8:37 ` Jambunathan K
@ 2014-03-18 9:51 ` Dushyant Juneja
2014-03-18 15:05 ` Jambunathan K
` (2 more replies)
[not found] ` <mailman.17417.1395136301.10748.help-gnu-emacs@gnu.org>
1 sibling, 3 replies; 10+ messages in thread
From: Dushyant Juneja @ 2014-03-18 9:51 UTC (permalink / raw)
To: Jambunathan K, help-gnu-emacs
Hi Jambunathan,
Thanks for the suggestion. Indeed, I was looking at vlf earlier. However,
with apologies to the developer, I found M-x find-file-literally to be a
much better alternative on my 64bit system.
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.
Regards,
Dushyant Juneja
Analog Devices, Inc. (India)
On Tue, Mar 18, 2014 at 2:07 PM, Jambunathan K <kjambunathan@gmail.com>wrote:
>
> You are looking for vlf.el. See http://elpa.gnu.org/packages/.
>
> Install it via
>
> M-x list-packages
>
>
> Dushyant Juneja <juneja.dushyant@gmail.com> writes:
>
> > Hi,
> >
> > I'm relatively new to emacs, but am pretty fascinated by its features.
> One
> > pain point is that it is rather slow in opening large data files bound to
> > specific modes. I generally observe it for circuit mode files (files
> > utilizing verilog-mode, spice-mode and spectre-mode). Is there a
> > possibility to help this?
> >
> > I find that M-x ffap-literally is rather fast, so can the following be
> done
> > somehow:
> >
> > If file is larger than default warning limit, open it literally.
> > Else open it with usual mode bindings.
> >
> > Also, please share as to how may I modify the default size limit.
> >
> > Regards,
> > Dushyant Juneja
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Intelligently opening large files in emacs
2014-03-18 9:51 ` Dushyant Juneja
@ 2014-03-18 15:05 ` Jambunathan K
2014-03-18 16:55 ` Eli Zaretskii
[not found] ` <mailman.17438.1395161765.10748.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 10+ messages in thread
From: Jambunathan K @ 2014-03-18 15:05 UTC (permalink / raw)
To: Dushyant Juneja; +Cc: help-gnu-emacs
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.
Feel free to steal from the snippet below. (Remember to alter 1e3 apart
from other things).
(defun my-find-file (filename)
(interactive "fFile name:")
(let ((size-in-bytes (nth 7 (file-attributes filename))))
(if (< size-in-bytes 1e3)
(find-file-literally filename)
(vlf filename))))
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Intelligently opening large files in emacs
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>
2 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2014-03-18 16:55 UTC (permalink / raw)
To: help-gnu-emacs
> From: Dushyant Juneja <juneja.dushyant@gmail.com>
> Date: Tue, 18 Mar 2014 15:21:16 +0530
>
> 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.
Why not just open every file with find-file-literally?
If that loses something, then how come you are prepared to lose that
for files larger than some arbitrary threshold, but not for smaller
files?
IOW, the size of the file usually says nothing about its contents or
the mode in which you'd like to visit that file. So doing this based
on size alone sounds like not a good idea to me.
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.17438.1395161765.10748.help-gnu-emacs@gnu.org>]
* Re: Intelligently opening large files in emacs
[not found] ` <mailman.17438.1395161765.10748.help-gnu-emacs@gnu.org>
@ 2014-03-18 18:25 ` Bug Dout
0 siblings, 0 replies; 10+ messages in thread
From: Bug Dout @ 2014-03-18 18:25 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
Excellent point. In some very informal tests I didn't notice much
difference in opening "large" files either way on a desktop PC (Windows
7x64). I ran into GNU Emacs' ridiculous "exceeds maximum buffer size"
long before any noticeable opening delay.
> IOW, the size of the file usually says nothing about its contents or
> the mode in which you'd like to visit that file. So doing this based
> on size alone sounds like not a good idea to me.
>
--
"In order to discover new lands one must have the courage to lose
sight of the shore."
--Andre Gide
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.17417.1395136301.10748.help-gnu-emacs@gnu.org>]
* Re: Intelligently opening large files in emacs
[not found] ` <mailman.17417.1395136301.10748.help-gnu-emacs@gnu.org>
@ 2014-03-18 16:45 ` Felix Dietrich
0 siblings, 0 replies; 10+ messages in thread
From: Felix Dietrich @ 2014-03-18 16:45 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Intelligently opening large files in emacs
2014-03-18 7:20 Intelligently opening large files in emacs Dushyant Juneja
2014-03-18 8:37 ` Jambunathan K
@ 2014-03-19 0:29 ` Stefan
2014-03-19 4:52 ` Marcin Borkowski
1 sibling, 1 reply; 10+ messages in thread
From: Stefan @ 2014-03-19 0:29 UTC (permalink / raw)
To: help-gnu-emacs
> I'm relatively new to emacs, but am pretty fascinated by its features. One
> pain point is that it is rather slow in opening large data files bound to
> specific modes.
I must admit, I'm not surprised.
> I generally observe it for circuit mode files (files utilizing
> verilog-mode, spice-mode and spectre-mode). Is there a possibility to
> help this?
In the longer run, we should aim to make Emacs fast enough even in
those modes. I can't promise anything, but if you can provide sample
files and steps to trigger the slow behavior, maybe someone will be able
to find the culprit as well as a fix/workaround. Of course, it is quite
likely that the slowdown is due to a combination of things, so "the fix"
is a long and painful one, so it might be difficult to find someone
motivated enough.
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Intelligently opening large files in emacs
2014-03-19 0:29 ` Stefan
@ 2014-03-19 4:52 ` Marcin Borkowski
0 siblings, 0 replies; 10+ messages in thread
From: Marcin Borkowski @ 2014-03-19 4:52 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-03-18, o godz. 20:29:01
Stefan <monnier@iro.umontreal.ca> napisał(a):
> > I'm relatively new to emacs, but am pretty fascinated by its
> > features. One pain point is that it is rather slow in opening large
> > data files bound to specific modes.
>
> I must admit, I'm not surprised.
Just could not resist: are you not surprised by the "rather slow" part
or the "pretty fascinated" one? (I guess "both" might be the correct
answer.)
;)
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-03-19 4:52 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2014-03-19 0:29 ` Stefan
2014-03-19 4:52 ` Marcin Borkowski
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).