mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
show: Convert show_message to use sprinter
Unlike the previous patches, this function is used for all formats. However, for formats other than the JSON format, the sprinter methods used by show_message are all no-ops, so this code continues to function correctly for all of the formats. Converting show_message eliminates show_null_message in the process, since this maps directly to an sprinter method.
This commit is contained in:
parent
26ba4abe53
commit
305a7ade1e
1 changed files with 5 additions and 26 deletions
|
@ -841,15 +841,6 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp),
|
||||||
return NOTMUCH_STATUS_SUCCESS;
|
return NOTMUCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static notmuch_status_t
|
|
||||||
show_null_message (const notmuch_show_format_t *format)
|
|
||||||
{
|
|
||||||
/* Output a null message. Currently empty for all formats except Json */
|
|
||||||
if (format->null_message)
|
|
||||||
printf ("%s", format->null_message);
|
|
||||||
return NOTMUCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static notmuch_status_t
|
static notmuch_status_t
|
||||||
show_message (void *ctx,
|
show_message (void *ctx,
|
||||||
const notmuch_show_format_t *format,
|
const notmuch_show_format_t *format,
|
||||||
|
@ -884,23 +875,16 @@ show_messages (void *ctx,
|
||||||
notmuch_message_t *message;
|
notmuch_message_t *message;
|
||||||
notmuch_bool_t match;
|
notmuch_bool_t match;
|
||||||
notmuch_bool_t excluded;
|
notmuch_bool_t excluded;
|
||||||
int first_set = 1;
|
|
||||||
int next_indent;
|
int next_indent;
|
||||||
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
|
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (format->message_set_start)
|
sp->begin_list (sp);
|
||||||
fputs (format->message_set_start, stdout);
|
|
||||||
|
|
||||||
for (;
|
for (;
|
||||||
notmuch_messages_valid (messages);
|
notmuch_messages_valid (messages);
|
||||||
notmuch_messages_move_to_next (messages))
|
notmuch_messages_move_to_next (messages))
|
||||||
{
|
{
|
||||||
if (!first_set && format->message_set_sep)
|
sp->begin_list (sp);
|
||||||
fputs (format->message_set_sep, stdout);
|
|
||||||
first_set = 0;
|
|
||||||
|
|
||||||
if (format->message_set_start)
|
|
||||||
fputs (format->message_set_start, stdout);
|
|
||||||
|
|
||||||
message = notmuch_messages_get (messages);
|
message = notmuch_messages_get (messages);
|
||||||
|
|
||||||
|
@ -915,12 +899,9 @@ show_messages (void *ctx,
|
||||||
res = status;
|
res = status;
|
||||||
next_indent = indent + 1;
|
next_indent = indent + 1;
|
||||||
} else {
|
} else {
|
||||||
status = show_null_message (format);
|
sp->null (sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status && format->message_set_sep)
|
|
||||||
fputs (format->message_set_sep, stdout);
|
|
||||||
|
|
||||||
status = show_messages (ctx,
|
status = show_messages (ctx,
|
||||||
format, sp,
|
format, sp,
|
||||||
notmuch_message_get_replies (message),
|
notmuch_message_get_replies (message),
|
||||||
|
@ -931,12 +912,10 @@ show_messages (void *ctx,
|
||||||
|
|
||||||
notmuch_message_destroy (message);
|
notmuch_message_destroy (message);
|
||||||
|
|
||||||
if (format->message_set_end)
|
sp->end (sp);
|
||||||
fputs (format->message_set_end, stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format->message_set_end)
|
sp->end (sp);
|
||||||
fputs (format->message_set_end, stdout);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue