Extend compat/README

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Fix the COERCE_STATUS macro

Fix the COERCE_STATUS macro to handle _internal_error being declared
as void function.

Note that the function _internal_error does not return. Evaluating to
NOTMUCH_STATUS_SUCCESS is done purely to appease the compiler.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Annotate internal_error with the attribute noreturn

Annotating functions that do not return with the noreturn attribute
(which is understood by both gcc and clang) prevents static analyzers
from generating false positives (internal_error is used to terminate
the process and is used extensively in error handling code paths).

Remove the return statement that was placed there to appease the
compiler. Functions annotated with noreturn are not supposed to return
any values.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Avoid potentially dereferencing a NULL pointer

GMIME_IS_MULTIPART and GMIME_IS_MESSAGE both handle NULL pointers
gracefully, but the G_OBJECT_TYPE used in the error handling block
dereferences it without checking it first.

Fix this by checking whether parent->part is valid.

Found using the clang static analyzer.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
emacs: simplify point placement in notmuch-hello refresh

notmuch-hello (called also through notmuch-hello-update, bound to '='
by default) tries to find the widget under or following point before
refresh, and put the point back to the widget afterwards. The code has
grown quite complicated, and has at least the following issues:

1) All the individual section functions have to include code to
   support point placement. If there is no such support, point is
   dropped to the search box. Only saved searches and all tags
   sections support point placement.

2) Point placement is based on widget-value. If there are two widgets
   with the same widget-value (for example a saved search with the
   same name as a tag) the point is moved to the earlier one, even if
   point was on the later one.

3) When first entering notmuch-hello notmuch-hello-target is nil, and
   point is dropped to the search box.

Moving the point to the search box is annoying because the user is
required to move the point before being able to enter key bindings.

Simplify the code by removing all point placement based on widgets, as
it does not work properly, and trying to fix that would unnecessarily
complicate the code.

Save current line and column before refresh, and restore them
afterwards. Sometimes, if notmuch-show-empty-saved-searches is nil,
and the refresh adds or removes saved searches from the list, this has
the appearance of moving the point relative to the nearest
widgets. This is a much smaller and less frequent problem than the
ones listed above.
test: Clear test-output output file before running Emacs tests

Most Emacs tests end with a call to (test-output), which saves the
buffer to a filed called OUTPUT.  Previously, if the test code failed
with an exception before this call, the test framework would then
compare against the OUTPUT file from the last Emacs test, resulting in
confusing diffs.

This requires one tweak to an emacs test that made two calls to
test_emacs and expected an OUTPUT file from the first call.  We simply
reverse the order of the test_emacs calls.
test: Add a test for HTML email with inline images

Currently this test passes in Emacs 23 but fails in Emacs 24 (at least
on some Linux distributions).
emacs: Work around gnus-inhibit-images bug in mm-shr

Emacs 24's mm-shr HTML email renderer fails to load gnus-art before
referencing gnus-inhibit-images, resulting in a void-variable error
when notmuch attempts to render an HTML email with inline images.
This works around this bug by advising mm-shr to load gnus-art.

mm-shr is the only function outside of gnus-art itself that references
gnus-inhibit-images, so this workaround should be correct.  If this
ever changes, hopefully they will have fixed this bug upstream first.

This fixes the "Rendering HTML mail with images" test for Emacs 24.
test: emacs: toggle eliding of non-matching messages in `notmuch-show'

See commits 44a544ed, 866ce8b1, 668b66ec.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
test: emacs: toggle eliding of non-matching messages in `notmuch-show'

See commits 44a544ed, 866ce8b1, 668b66ec.
test: emacs: toggle thread content indentation in `notmuch-show'

See commit c205e8ff.
test: handle filenames that have directories in them

Since $TEST_DIRECTORY is an absolute path, any filenames generated
with it will be complete paths. Only use the basename to generate
suffixes for filenames.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
test: Move tests from emacs to emacs-show

This requires changing the contents of the crypto tests, as one thread
that was marked read by the earlier tests in test/emacs is no longer
marked read.

This moves tests for:

- 09d19ac "test: emacs: toggle eliding of non-matching messages in
   `notmuch-show'", which should have actually read: "test: emacs:
   toggle processing of cryptographic MIME parts in `notmuch-show'".
   See commit 19ec74c5.

- 5ea1dbe "test: emacs: toggle eliding of non-matching messages in
  `notmuch-show'"

- 345faab "test: emacs: toggle thread content indentation in
  `notmuch-show'"

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
test: emacs: new tests "notmuch-show: {show, hide} message headers"

* test/emacs:

  - New subtest "notmuch-show: show message headers":
    Setting `notmuch-message-headers-visible' to t causes all headers
    defined in `notmuch-message-headers' to be shown.

  - New subtest "notmuch-show: hide message headers":
    Setting `notmuch-message-headers-visible' to nil causes all headers
    defined in `notmuch-message-headers' to be hidden.
    ("Subject:" may be an exception;  See the use of `headers-start' in
    `notmuch-show-insert-msg')

  - New subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-headers)":
    Setting `notmuch-message-headers-visible' to t causes all headers
    defined in `notmuch-message-headers' to be shown, but they can be
    hidden for the current message by running `notmuch-show-toggle-headers'.
test: emacs: new tests "notmuch-show: {, un}collapse all messages in thread"

* test/emacs:

  - New subtest "notmuch-show: collapse all messages in thread":
    `notmuch-show-open-or-close-all' with prefix arg ("C-u M-RET")
    collapses all messages in thread.

  - New subtest "notmuch-show: uncollapse all messages in thread":
    `notmuch-show-open-or-close-all' without prefix arg ("M-RET")
    uncollapses all messages in thread.
emacs: rename `notmuch-show-toggle-headers' to `notmuch-show-toggle-visibility-headers'

* emacs/notmuch-show.el

  (notmuch-show-toggle-headers):
    Rename to `notmuch-show-toggle-visibility-headers'.

  (notmuch-show-mode-map):
    Update "h" binding wrt renamed `notmuch-show-toggle-headers'.

  (notmuch-message-headers):
    Update docstring wrt renamed `notmuch-show-toggle-headers'.

  (notmuch-message-headers-visible):
    Update docstring wrt renamed `notmuch-show-toggle-headers'.
    Also fixed a small typo.

* test/emacs:

  Update subtest wrt renamed `notmuch-show-toggle-headers':
  - "notmuch-show: hide message headers (w/ notmuch-show-toggle-headers)"
cli: add '--debug' option to 'notmuch new'

This will be used in later patches to test the 'new.ignore'
config option more thoroughly.
cli: notmuch new: optionally output debug information when ignoring files/directories

When running 'notmuch new' with the '--debug' option, output debug
information regarding explicitly ignored files and directories.
test-lib.sh: pass 'NOTMUCH_NEW's args down to 'notmuch new'

Obviates the need to create a 'NOTMUCH_NEW' clone which runs
'notmuch new --debug'.  This will be used in a later patch.

Doesn't cause any issues for other tests.
test: another test wrt ignoring user-specified files and directories

Demonstrates that *every* file/directory which matches one of the values
in 'new.ignore' will be ignored, independent of its depth/location in
the mail store.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>