unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [ELPA] New package: so-long
@ 2016-07-16 14:48 Phil Sainty
  2016-07-16 19:35 ` Marcin Borkowski
  2016-07-17 15:03 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Phil Sainty @ 2016-07-16 14:48 UTC (permalink / raw)
  To: emacs-devel

so-long.el prevents large 'minified' files (programming code with
extremely long lines) bringing Emacs to its knees.

Many Emacs modes struggle with buffers which contain excessively
long lines.  This commonly occurs with minified code (i.e. code
that has been compacted into the smallest file size possible,
which often entails removing newlines should they not be strictly
necessary).  Programming modes often won't be written with any
expectation of encountering line lengths like this, and so
performance can suffer significantly.

I would most regularly encounter this issue when stepping through
a grep results buffer, suddenly finding myself somewhere in the
middle of a huge minified javascript file, whereupon Emacs would
become unresponsive for many long seconds while various modes
struggled to process the enormous lines.  Eventually I would be
able to kill the buffer, manually move past any remaining grep
hits for that file, and resume what I was doing; but the whole
incident would always be very annoying and distracting.

so-long.el is a workaround for situations like that.

When such files are detected, and the selected major mode is one
which we target, we invoke `so-long-mode'.  This is a minimal
major mode with the primary function (other than simply not being
the original mode) of explicitly disabling a (configurable) list
of minor modes with performance implications.  A custom hook is
also run (in addition to the normal major mode hook) to provide
further options for dealing with performance concerns.

The following minor modes are handled by default:

* font-lock-mode
* highlight-changes-mode
* hi-lock-mode
* hl-line-mode
* linum-mode
* nlinum-mode
* prettify-symbols-mode
* visual-line-mode
* whitespace-mode

n.b. I'm not 100% sure that all of those are problematic, but
they seemed like reasonable targets.  Some are certainly
excessive in smaller buffers of minified code, but I am aiming to
maximise performance by default, so that Emacs is as responsive
as possible in even very large buffers of minified code.

Some other "modes of interest" are known to me (and documented
on the EmacsWiki page), but the current default value is for
built-in modes only.  I would welcome any recommendations for
improving the default configuration prior to an initial GNU ELPA
release.

These kinds of minified files are typically not intended to be
edited; so not providing the usual editing mode in such cases
will rarely be an issue.  However, should the user wish to do so,
the original mode may be reinstated easily in any given buffer
using `so-long-mode-revert' (the key binding for which is
advertised when the mode is entered).


Documentation and examples are in the commentary, and at:
https://www.emacswiki.org/emacs/SoLong

The source code is now maintained at:
http://git.savannah.gnu.org/cgit/so-long.git
http://git.savannah.gnu.org/cgit/so-long.git/plain/so-long.el


-Phil




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ELPA] New package: so-long
  2016-07-16 14:48 [ELPA] New package: so-long Phil Sainty
@ 2016-07-16 19:35 ` Marcin Borkowski
  2016-07-17 15:03 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Marcin Borkowski @ 2016-07-16 19:35 UTC (permalink / raw)
  To: Phil Sainty; +Cc: emacs-devel

Hi Phil,

this looks great, thanks a lot!  I can't wait to try it out.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ELPA] New package: so-long
  2016-07-16 14:48 [ELPA] New package: so-long Phil Sainty
  2016-07-16 19:35 ` Marcin Borkowski
@ 2016-07-17 15:03 ` Stefan Monnier
  2016-07-18 11:19   ` Phil Sainty
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2016-07-17 15:03 UTC (permalink / raw)
  To: emacs-devel

> so-long.el prevents large 'minified' files (programming code with
> extremely long lines) bringing Emacs to its knees.

This looks very helpful.  I wonder if we could improve the detection
part with some help from the C code.  I'm thinking of trying to keep
track of "the last \n before point" and calling a hook whenever this is
larger than a threshold.


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ELPA] New package: so-long
  2016-07-17 15:03 ` Stefan Monnier
@ 2016-07-18 11:19   ` Phil Sainty
  2016-07-18 14:47     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Phil Sainty @ 2016-07-18 11:19 UTC (permalink / raw)
  To: emacs-devel

On 18/07/16 03:03, Stefan Monnier wrote:
> This looks very helpful.  I wonder if we could improve the detection
> part with some help from the C code.  I'm thinking of trying to keep
> track of "the last \n before point" and calling a hook whenever this
> is larger than a threshold.

That sounds pretty interesting, although I have virtually no familiarity
with the C code, so I'm not in much of a position to discuss that side
of things. If there's a sensible way to support long line detection in
the core, though, I'm all for it.


-Phil



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ELPA] New package: so-long
  2016-07-18 11:19   ` Phil Sainty
@ 2016-07-18 14:47     ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2016-07-18 14:47 UTC (permalink / raw)
  To: emacs-devel

> That sounds pretty interesting, although I have virtually no familiarity
> with the C code, so I'm not in much of a position to discuss that side
> of things. If there's a sensible way to support long line detection in
> the core, though, I'm all for it.

Maybe M-x report-emacs-bug RET and requesting this functionality would
be a good first step ;-)


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-18 14:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-16 14:48 [ELPA] New package: so-long Phil Sainty
2016-07-16 19:35 ` Marcin Borkowski
2016-07-17 15:03 ` Stefan Monnier
2016-07-18 11:19   ` Phil Sainty
2016-07-18 14:47     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).