diff --git a/src/mu-cmd.c b/src/mu-cmd.c index ce686937..1e879f4b 100644 --- a/src/mu-cmd.c +++ b/src/mu-cmd.c @@ -54,12 +54,15 @@ view_msg (MuMsg *msg, const gchar *fields, size_t summary_len) if ((date = mu_msg_get_date (msg))) g_print ("Date: %s\n", mu_str_date_s ("%c", date)); - /* TODO: reimplement the summary stuff... */ - /* if (summary_len > 0) { */ - /* field = mu_msg_get_summary (msg, summary_len); */ - /* g_print ("Summary: %s\n", field ? field : ""); */ - /* } else */ - if ((field = mu_msg_get_body_text (msg))) + if (!(field = mu_msg_get_body_text (msg))) + return TRUE; /* no body -- nothing more to do */ + + if (summary_len > 0) { + gchar *summ; + summ = mu_str_summarize (field, summary_len); + g_print ("Summary: %s\n", summ); + g_free (summ); + } else g_print ("\n%s\n", field); return TRUE; diff --git a/src/mu-output.c b/src/mu-output.c index daa24190..a9a97a62 100644 --- a/src/mu-output.c +++ b/src/mu-output.c @@ -169,7 +169,7 @@ static void print_summary (MuMsgIter *iter, size_t summary_len) { GError *err; - /* const char *summ; */ + char *summ; MuMsg *msg; if (summary_len == 0) @@ -183,9 +183,9 @@ print_summary (MuMsgIter *iter, size_t summary_len) return; } - /* TODO: summary again */ - /* summ = mu_msg_get_summary (msg, summary_len); */ - /* g_print ("Summary: %s\n", summ ? summ : ""); */ + summ = mu_str_summarize (mu_msg_get_body_text(msg), summary_len); + g_print ("Summary: %s\n", summ ? summ : ""); + g_free (summ); mu_msg_unref (msg); } diff --git a/src/tests/test-mu-query.c b/src/tests/test-mu-query.c index f0e5939c..f9424830 100644 --- a/src/tests/test-mu-query.c +++ b/src/tests/test-mu-query.c @@ -30,6 +30,7 @@ #include "test-mu-common.h" #include "src/mu-query.h" +#include "src/mu-str.h" static gchar* fill_database (void) @@ -211,6 +212,7 @@ test_mu_query_05 (void) MuMsg *msg; gchar *xpath; GError *err; + gchar *summ; xpath = fill_database (); g_assert (xpath != NULL); @@ -229,8 +231,10 @@ test_mu_query_05 (void) g_assert_cmpstr (mu_msg_get_subject(msg),==, "Greetings from Lothlórien"); /* TODO: fix this again */ - /* g_assert_cmpstr (mu_msg_get_summary(msg,5),==, */ - /* "Let's write some fünkÿ text using umlauts. Foo."); */ + + summ = mu_str_summarize (mu_msg_get_body_text(msg), 5); + g_assert_cmpstr (summ,==, "Let's write some fünkÿ text using umlauts. Foo."); + g_free (summ); mu_msg_unref (msg); mu_msg_iter_destroy (iter);