flush temporary attachment files before viewing

I was having problems with the temporary attachment files being empty
when external programs (vim and w3m, and using system(), so blocking)
opened them from my mime-view hook. Flushing the content before yielding
in Attachment#write_to_disk fixes the problem for all the cases where I
encountered the problem.

Signed-off-by: Johannes Larsen <johs.a.larsen@gmail.com>
textfield: fix typo in comment
sup: use ncursesw gem
Merge #183: Wrap form_driver_w for wide char input

form_driver does not work correctly on all systems (specifically Mac OS X),
it is difficult or impossible to determine whether the input char is a
char or key code resulting from a char sequence in a multibyte char.

If no form_driver_w is present we fall back to form_driver.
form_driver_w is included in ncursesw-1.4.2 with the Ncurses 5.9 20131207
patchlevel.

http://lists.gnu.org/archive/html/bug-ncurses/2013-12/msg00010.html

original patch:

http://lists.gnu.org/archive/html/bug-ncurses/2013-11/msg00015.html

Author: Paweł Wilk <siefca@gnu.org>

Squashed commit of the following:

commit 7a513f25d755523576268bfa5c77fafc838564b6
Author: Paweł Wilk <siefca@gnu.org>
Date:   Tue Nov 26 19:49:30 2013 +0100

    Added conditional select in Ncurses::nonblocking_getwch to prevent erroneous CharCode spawning

commit 0b6859eb1b5b02e98f07214e45baab550e6f07e7
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 21:14:52 2013 +0100

    BufferManager.sigwinch_happened! modified to run once if it already happened

commit 857cb60058f966e22bd0f06950c5b8fa3d8e622f
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 20:44:21 2013 +0100

    Added workaround for screen redrawing when sigwinch happened

commit d72d72fb27b23af8d386faa36e1d78c0087c1115
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 20:43:46 2013 +0100

    Optimizations in Ncurses::CharCode.get

commit c2139b6df4aba9551adf4275cb1d8bc70e4727e2
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 18:19:57 2013 +0100

    Fixed uninitialized instance variable warning

commit 72fb7e43b7237ebc582ca58fe2df115ea3747ef3
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:43:16 2013 +0100

    Added critical patches for Ncurses::Form::DriverHelpers#form_driver and Ncurses.get_wch

commit 340fb7f249b799cafb2b1e40f8b8b31e82f449d2
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:42:24 2013 +0100

    Ncurses::Form::DriverHelpers improved; now all wrappers are reusing core wrapper

commit ca362c294c08cd7ee81bf52722c819c4c31c6a04
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:40:38 2013 +0100

    Ncurses::CharCode#enc_char improved

commit 380079ea0627c9f1440b5097563e6dece352cae4
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:40:01 2013 +0100

    Added Ncurses::CharCode::Empty.empty override

commit 8da83d9952fd6020175ac4b89e404adc5a72d6fe
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:39:28 2013 +0100

    Cleanups

commit de9f7bc1b2cd5d71d870c02d0fe2242786f00445
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:39:02 2013 +0100

    Added Ncurses::CharCode.dumb! switch to control behavior when CharCode cannot detect keycodes

commit ffad7e5e9d6951ae0834be9c453b91e305dbbcdf
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 17:35:30 2013 +0100

    Added Ncurses::CharCode.generate to save objects from spawning when ERR is returned by get(w)ch

commit ad6f6f2c0c8020ff3b5affe242c40972d6a3a4ba
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 03:02:01 2013 +0100

    Removed printing of warning about a missing form_driver_w() function

commit ea277c19791330943a3696cb97d9a6ad99454d80
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 02:55:23 2013 +0100

    Cleanups

commit 505532e288072be92ade36bec94555044dce9b2d
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:24:08 2013 +0100

    TextField now uses form_driver helpers from Ncurses::Form::DriverHelpers

commit 91037291c28f00cee2da5ea505657aa814ddcffc
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:23:22 2013 +0100

    Added Form::DriverHelpers module with methods that ease usage of form_driver

commit 05c2b5611d5e96d68e4685c4c27a5d267cde4a48
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:22:08 2013 +0100

    Improved Ncurses::CharCode#replace method (detects if input is a charcode or a character)

commit a2f0dac449bc743236f3925b35aa6de43fc189d0
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:21:11 2013 +0100

    Removed previous wrapper for form_driver_w()

commit 3a5cbdc8c1941745bcd1498644be02e2487e7905
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:20:12 2013 +0100

    Cleanups

commit a9585535f6b647c3094f5f4485f8128f127c4357
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:19:51 2013 +0100

    Replacement wrapper for form_driver_w() moved to Ncurses::prepare_form_driver and called after initscr

commit 7766cbfb20941dd6d67456008af1125b99d6a6be
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sun Nov 24 01:17:37 2013 +0100

    Multiple typos fixed

commit 8bf705c135d9458be759cd72ebef7eef98085a8d
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sat Nov 23 20:58:54 2013 +0100

    Key for continuing search in buffer in Buffer#handle_input is now compared directly

commit 1dcfabd56c423762734b4a7594d209ceeb07fe16
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sat Nov 23 20:57:22 2013 +0100

    Moved ncurses tweaks to lib/sup/util/ncurses.rb, added CharCode::Empty singleton class

commit ed85b526c52b21c58b029921b51c0183aa747876
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sat Nov 23 17:37:50 2013 +0100

    TextField class is now making use of Ncurses::Form.form_driver_w

commit 9ce61341efdba172fddf41b10e0277e646177208
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sat Nov 23 17:37:10 2013 +0100

    Cleanups in buffer.rb

commit f8f7116c542de63c2ce3f04e96d18779fe28e3b0
Author: Paweł Wilk <siefca@gnu.org>
Date:   Sat Nov 23 17:36:49 2013 +0100

    Added compat proxy for the Ncurses::Form.form_driver_w module method

commit 171eada22b63b3e105eae4f80b157f0e2bdd0a0d
Author: Paweł Wilk <siefca@gnu.org>
Date:   Fri Nov 22 02:36:27 2013 +0100

    Fixed TextField#handle_input (keysyms taken into account) and prepared for form_driver workaroud

commit 3217a655a09fe6adb35049fdaa16af7e1788d0ee
Author: Paweł Wilk <siefca@gnu.org>
Date:   Fri Nov 22 02:32:28 2013 +0100

    Added Ncurses::curyx module method (helper for reading whole cursor position)

commit 60b02d6f6257601737086fddfcd33fba60d033a6
Author: Paweł Wilk <siefca@gnu.org>
Date:   Thu Nov 21 19:08:51 2013 +0100

    Ncurses::CharCode::get now uses chr to create character based on code returned by get_wch

commit 58088c4f5fa27dce2234c43d3c1beba7539ce87b
Author: Paweł Wilk <siefca@gnu.org>
Date:   Thu Nov 21 17:55:45 2013 +0100

    Typo fixed

commit ca8e98447c209680988b162e9f980ff69cd693db
Author: Paweł Wilk <siefca@gnu.org>
Date:   Thu Nov 21 17:21:49 2013 +0100

    Ncurses::CharCode class refactored, code adapted to use its instances

    Details:

    - changed Ncurses::CharCode to work with wide characters,
    - removed select wrapper when reading input,
    - moved input reading into Ncurses::CharCode class,
    - implemented passing Ncurses::CharCode objects as far as possible.

commit f0168bea3ada9cd5c3168c9fc324ed3aa458119e
Author: Paweł Wilk <siefca@gnu.org>
Date:   Tue Nov 19 23:20:13 2013 +0100

    Adapted Keymap, Buffer and TextField classes to make use of CharCode objects

commit dfea936ae8661e71b80618f44a8bd9f3ca68634c
Author: Paweł Wilk <siefca@gnu.org>
Date:   Tue Nov 19 23:17:11 2013 +0100

    Added Ncurses::CharCode helper class for storing and transferring wide characters
Merge #189: Added hidden_alternates config option

Addresses listed in hidden_alternates will not be shown in the
account_selector. They will still be treated as aliases to the account
in all other respects.

Pull request: #189

Section in sup-config left out for now, implementation available in #189.
index, thread_index_mode: dont sync on updated message
index: add option for sync_back (default true) when syncing message
prepare release 0.15.2
Merge branch 'develop'
release 0.15.2