Skip to content

Commit

Permalink
rename quiet to verbose
Browse files Browse the repository at this point in the history
Invert the `Mailbox->quiet` logic to reduce the number of negative `if`s.

There are ~60 uses of the `quiet` flag, but the vast majority are of the
form: `if (!quiet)`

This is replaced by: `if (verbose)`
  • Loading branch information
flatcap committed May 19, 2020
1 parent fe49a10 commit 5508a7a
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 84 deletions.
2 changes: 1 addition & 1 deletion compmbox/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int execute_command(struct Mailbox *m, const char *command, const char *p
if (!m || !command || !progress)
return 0;

if (!m->quiet)
if (m->verbose)
mutt_message(progress, m->realpath);

int rc = 1;
Expand Down
2 changes: 1 addition & 1 deletion core/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct Mailbox
bool dontwrite : 1; ///< Don't write the mailbox on close
bool first_check_stats_done : 1; ///< True when the check have been done at least on time
bool peekonly : 1; ///< Just taking a glance, revert atime
bool quiet : 1; ///< Inhibit status messages?
bool verbose : 1; ///< Display status messages?
bool readonly : 1; ///< Don't allow changes to the mailbox

AclFlags rights; ///< ACL bits, see #AclFlags
Expand Down
10 changes: 5 additions & 5 deletions imap/imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ int imap_fast_trash(struct Mailbox *m, char *dest)
mutt_debug(LL_DEBUG1, "could not queue copy\n");
goto out;
}
else if (!m->quiet)
else if (m->verbose)
{
mutt_message(ngettext("Copying %d message to %s...", "Copying %d messages to %s...", rc),
rc, dest_mdata->name);
Expand Down Expand Up @@ -1692,7 +1692,7 @@ int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close)
if (e->deleted && e->changed)
e->active = false;
}
if (!m->quiet)
if (m->verbose)
{
mutt_message(ngettext("Marking %d message deleted...",
"Marking %d messages deleted...", rc),
Expand Down Expand Up @@ -1732,7 +1732,7 @@ int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close)
if ((e->env && e->env->changed) || e->attach_del)
{
/* L10N: The plural is chosen by the last %d, i.e. the total number */
if (!m->quiet)
if (m->verbose)
{
mutt_message(ngettext("Saving changed message... [%d/%d]",
"Saving changed messages... [%d/%d]", m->msg_count),
Expand Down Expand Up @@ -1823,7 +1823,7 @@ int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close)
/* We must send an EXPUNGE command if we're not closing. */
if (expunge && !close && (m->rights & MUTT_ACL_DELETE))
{
if (!m->quiet)
if (m->verbose)
mutt_message(_("Expunging messages from server..."));
/* Set expunge bit so we don't get spurious reopened messages */
mdata->reopen |= IMAP_EXPUNGE_EXPECTED;
Expand Down Expand Up @@ -2064,7 +2064,7 @@ static int imap_mbox_open(struct Mailbox *m)
m->rights = 0;
mdata->new_mail_count = 0;

if (!m->quiet)
if (m->verbose)
mutt_message(_("Selecting %s..."), mdata->name);

/* pipeline ACL test */
Expand Down
18 changes: 9 additions & 9 deletions imap/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ static int read_headers_normal_eval_cache(struct ImapAccountData *adata,
struct ImapMboxData *mdata = imap_mdata_get(m);
int idx = m->msg_count;

if (!m->quiet)
if (m->verbose)
{
/* L10N: Comparing the cached data with the IMAP server's data */
mutt_progress_init(&progress, _("Evaluating cache..."), MUTT_PROGRESS_READ, msn_end);
Expand All @@ -758,7 +758,7 @@ static int read_headers_normal_eval_cache(struct ImapAccountData *adata,
if (SigInt && query_abort_header_download(adata))
return -1;

if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, msgno, -1);

memset(&h, 0, sizeof(h));
Expand Down Expand Up @@ -950,7 +950,7 @@ static int read_headers_condstore_qresync_updates(struct ImapAccountData *adata,
struct Mailbox *m = adata->mailbox;
struct ImapMboxData *mdata = imap_mdata_get(m);

if (!m->quiet)
if (m->verbose)
{
/* L10N: Fetching IMAP flag changes, using the CONDSTORE extension */
mutt_progress_init(&progress, _("Fetching flag updates..."), MUTT_PROGRESS_READ, msn_end);
Expand All @@ -967,7 +967,7 @@ static int read_headers_condstore_qresync_updates(struct ImapAccountData *adata,
if (SigInt && query_abort_header_download(adata))
return -1;

if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, msgno, -1);

/* cmd_parse_fetch will update the flags */
Expand Down Expand Up @@ -1103,7 +1103,7 @@ static int read_headers_fetch_new(struct Mailbox *m, unsigned int msn_begin,
unlink(mutt_b2s(tempfile));
mutt_buffer_pool_release(&tempfile);

if (!m->quiet)
if (m->verbose)
{
mutt_progress_init(&progress, _("Fetching message headers..."),
MUTT_PROGRESS_READ, msn_end);
Expand Down Expand Up @@ -1136,7 +1136,7 @@ static int read_headers_fetch_new(struct Mailbox *m, unsigned int msn_begin,
if (initial_download && SigInt && query_abort_header_download(adata))
goto bail;

if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, msgno, -1);

rewind(fp);
Expand Down Expand Up @@ -1509,7 +1509,7 @@ int imap_append_message(struct Mailbox *m, struct Message *msg)
}
rewind(fp);

if (!m->quiet)
if (m->verbose)
mutt_progress_init(&progress, _("Uploading message..."), MUTT_PROGRESS_NET, len);

mutt_date_make_imap(internaldate, sizeof(internaldate), msg->received);
Expand Down Expand Up @@ -1551,7 +1551,7 @@ int imap_append_message(struct Mailbox *m, struct Message *msg)
sent += len;
if (flush_buffer(buf, &len, adata->conn) < 0)
goto fail;
if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, sent, -1);
}
}
Expand Down Expand Up @@ -1918,7 +1918,7 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)

/* This function is called in a few places after endwin()
* e.g. mutt_pipe_message(). */
output_progress = !isendwin() && !m->quiet;
output_progress = !isendwin() && m->verbose;
if (output_progress)
mutt_message(_("Fetching message..."));

Expand Down
16 changes: 8 additions & 8 deletions index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,10 +1266,10 @@ int mutt_index_menu(struct MuttWindow *dlg)

if (Context && Context->mailbox)
{
bool q = Context->mailbox->quiet;
Context->mailbox->quiet = true;
bool verbose = Context->mailbox->verbose;
Context->mailbox->verbose = false;
update_index(menu, Context, check, oldcount, index_hint);
Context->mailbox->quiet = q;
Context->mailbox->verbose = verbose;
menu->max = Context->mailbox->vcount;
}
else
Expand Down Expand Up @@ -1600,12 +1600,12 @@ int mutt_index_menu(struct MuttWindow *dlg)
if (Context->mailbox->msg_count > oldmsgcount)
{
struct Email *e_oldcur = get_cur_email(Context, menu);
bool quiet = Context->mailbox->quiet;
bool verbose = Context->mailbox->verbose;

if (rc < 0)
Context->mailbox->quiet = true;
Context->mailbox->verbose = false;
mutt_sort_headers(Context, (op == OP_RECONSTRUCT_THREAD));
Context->mailbox->quiet = quiet;
Context->mailbox->verbose = verbose;

/* Similar to OP_MAIN_ENTIRE_THREAD, keep displaying the old message, but
* update the index */
Expand Down Expand Up @@ -2222,7 +2222,7 @@ int mutt_index_menu(struct MuttWindow *dlg)
{
struct Progress progress;

if (!m->quiet)
if (m->verbose)
{
mutt_progress_init(&progress, _("Update tags..."),
MUTT_PROGRESS_WRITE, m->msg_tagged);
Expand All @@ -2240,7 +2240,7 @@ int mutt_index_menu(struct MuttWindow *dlg)
if (!message_is_tagged(Context, e))
continue;

if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, ++px, -1);
mx_tags_commit(m, e, buf);
if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
Expand Down
12 changes: 6 additions & 6 deletions maildir/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ int maildir_parse_dir(struct Mailbox *m, struct Maildir ***last,
if (count)
{
(*count)++;
if (!m->quiet && progress)
if (m->verbose && progress)
mutt_progress_update(progress, *count, -1);
}

Expand Down Expand Up @@ -696,7 +696,7 @@ void maildir_delayed_parsing(struct Mailbox *m, struct Maildir **md, struct Prog
continue;
}

if (!m->quiet && progress)
if (m->verbose && progress)
mutt_progress_update(progress, count, -1);

if (!sort)
Expand Down Expand Up @@ -795,7 +795,7 @@ int mh_read_dir(struct Mailbox *m, const char *subdir)
struct Maildir **last = NULL;
struct Progress progress;

if (!m->quiet)
if (m->verbose)
{
char msg[PATH_MAX];
snprintf(msg, sizeof(msg), _("Scanning %s..."), mailbox_path(m));
Expand All @@ -818,7 +818,7 @@ int mh_read_dir(struct Mailbox *m, const char *subdir)
if (maildir_parse_dir(m, &last, subdir, &count, &progress) < 0)
return -1;

if (!m->quiet)
if (m->verbose)
{
char msg[PATH_MAX];
snprintf(msg, sizeof(msg), _("Reading %s..."), mailbox_path(m));
Expand Down Expand Up @@ -1721,7 +1721,7 @@ int mh_mbox_sync(struct Mailbox *m, int *index_hint)
hc = mutt_hcache_open(C_HeaderCache, mailbox_path(m), NULL);
#endif

if (!m->quiet)
if (m->verbose)
{
char msg[PATH_MAX];
snprintf(msg, sizeof(msg), _("Writing %s..."), mailbox_path(m));
Expand All @@ -1730,7 +1730,7 @@ int mh_mbox_sync(struct Mailbox *m, int *index_hint)

for (i = 0; i < m->msg_count; i++)
{
if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, i, -1);

if (mh_sync_mailbox_message(m, i, hc) == -1)
Expand Down
20 changes: 10 additions & 10 deletions mbox/mbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int mmdf_parse_mailbox(struct Mailbox *m)

buf[sizeof(buf) - 1] = '\0';

if (!m->quiet)
if (m->verbose)
{
char msg[PATH_MAX];
snprintf(msg, sizeof(msg), _("Reading %s..."), mailbox_path(m));
Expand All @@ -234,7 +234,7 @@ static int mmdf_parse_mailbox(struct Mailbox *m)
return -1;

count++;
if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, count, (int) (loc / (m->size / 100 + 1)));

if (m->msg_count == m->email_max)
Expand Down Expand Up @@ -378,7 +378,7 @@ static int mbox_parse_mailbox(struct Mailbox *m)
if (!m->readonly)
m->readonly = access(mailbox_path(m), W_OK) ? true : false;

if (!m->quiet)
if (m->verbose)
{
char msg[PATH_MAX];
snprintf(msg, sizeof(msg), _("Reading %s..."), mailbox_path(m));
Expand Down Expand Up @@ -406,7 +406,7 @@ static int mbox_parse_mailbox(struct Mailbox *m)

count++;

if (!m->quiet)
if (m->verbose)
{
mutt_progress_update(&progress, count,
(int) (ftello(adata->fp) / (m->size / 100 + 1)));
Expand Down Expand Up @@ -556,7 +556,7 @@ static int reopen_mailbox(struct Mailbox *m, int *index_hint)
int rc = -1;

/* silent operations */
m->quiet = true;
m->verbose = false;

/* our heuristics require the old mailbox to be unsorted */
if (C_Sort != SORT_ORDER)
Expand Down Expand Up @@ -629,7 +629,7 @@ static int reopen_mailbox(struct Mailbox *m, int *index_hint)
email_free(&(e_old[i]));
FREE(&e_old);

m->quiet = false;
m->verbose = true;
return -1;
}

Expand Down Expand Up @@ -710,7 +710,7 @@ static int reopen_mailbox(struct Mailbox *m, int *index_hint)
}

mailbox_changed(m, NT_MAILBOX_UPDATE);
m->quiet = false;
m->verbose = true;

return (m->changed || msg_mod) ? MUTT_REOPENED : MUTT_NEW_MAIL;
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint)
new_offset = mutt_mem_calloc(m->msg_count - first, sizeof(struct MUpdate));
old_offset = mutt_mem_calloc(m->msg_count - first, sizeof(struct MUpdate));

if (!m->quiet)
if (m->verbose)
{
char msg[PATH_MAX];
snprintf(msg, sizeof(msg), _("Writing %s..."), mailbox_path(m));
Expand All @@ -1286,7 +1286,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint)

for (i = first, j = 0; i < m->msg_count; i++)
{
if (!m->quiet)
if (m->verbose)
mutt_progress_update(&progress, i, (int) (ftello(adata->fp) / (m->size / 100 + 1)));
/* back up some information which is needed to restore offsets when
* something fails. */
Expand Down Expand Up @@ -1398,7 +1398,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint)
{
/* copy the temp mailbox back into place starting at the first
* change/deleted message */
if (!m->quiet)
if (m->verbose)
mutt_message(_("Committing changes..."));
i = mutt_file_copy_stream(fp, adata->fp);

Expand Down
Loading

0 comments on commit 5508a7a

Please sign in to comment.