emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA] New package: so-long


From: Phil Sainty
Subject: [ELPA] New package: so-long
Date: Sun, 17 Jul 2016 02:48:08 +1200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]