]> git.notmuchmail.org Git - notmuch/commit
emacs: Eliminate buffer invisibility specs from show and wash
authorAustin Clements <amdragon@MIT.EDU>
Tue, 18 Dec 2012 06:40:10 +0000 (01:40 -0500)
committerDavid Bremner <bremner@debian.org>
Fri, 21 Dec 2012 13:43:45 +0000 (09:43 -0400)
commit8ba60168897e81133c85d9f4928b96ad4a4b6ffd
treef020533db24b5f2c05ad6fd1b6e1fd14c7e58447
parent92d7ae3876c3387f2e446630f22f95958994e609
emacs: Eliminate buffer invisibility specs from show and wash

Previously, all visibility in show buffers for headers, message
bodies, and washed text was specified by generating one or more
symbols for each region and creating overlays with their 'invisible
property set to carefully crafted combinations of these symbols.
Visibility was controlled not by modifying the overlays directly, but
by adding and removing the generated symbols from a gigantic buffer
invisibilty spec.

This has myriad negative consequences.  It's slow because Emacs'
display engine has to traverse the buffer invisibility list for every
overlay and, since every overlay has its own symbol, this makes
rendering O(N^2) in the number of overlays.  It composes poorly
because symbol-type 'invisible properties are taken from the highest
priority overlay over a given character (which is often ambiguous!),
rather than being gathered from all overlays over a character.  As a
result, we have to include symbols related to message hiding in the
wash code lest the wash overlays un-hide parts of hidden messages.  It
also requires various workarounds for isearch to properly open
overlays, to set up buffer-invisibility-spec for
remove-from-invisibility-spec to work right, and to explicitly refresh
the display after updating the buffer invisibility spec.

None of this is necessary.

This patch converts show and wash to use simple boolean 'invisible
properties and to not use the buffer invisibility spec.  Rather than
adding and removing generated symbols from the invisibility spec, the
code now directly toggles the 'invisible property of the appropriate
overlay.  This speeds up rendering because the display engine only has
to check the boolean values of the overlays over a character.  It
composes nicely because text will be invisible if *any* overlay over
it has 'invisible t, which means we can overlap invisibility overlays
with abandon.  We no longer need any of the workarounds mentioned
above.  And it fixes a minor bug for free: now, when isearch opens a
washed region, the button text will update to say "Click/Enter to
hide" rather than remaining unchanged.
emacs/notmuch-show.el
emacs/notmuch-wash.el