Skip to content

Commit

Permalink
alter clang-format defaults
Browse files Browse the repository at this point in the history
Add options:

- PenaltyBreakAssignment: 100
- PenaltyBreakBeforeFirstCallParameter: 100
- BreakStringLiterals: false

These three options reduce the number of lines wrapped at `=` or `(`
at the expense of some slightly longer lines.
  • Loading branch information
flatcap committed Apr 15, 2022
1 parent ae70e4b commit c916fe3
Show file tree
Hide file tree
Showing 168 changed files with 1,489 additions and 2,292 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

PenaltyBreakAssignment: 100
PenaltyBreakBeforeFirstCallParameter: 100
BreakStringLiterals: false

# Allow some slightly over-long lines
PenaltyExcessCharacter: 1

Expand Down
3 changes: 1 addition & 2 deletions alias/alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ static void expand_aliases_r(struct AddressList *al, struct ListHead *expn)
*/
static void recode_buf(char *buf, size_t buflen)
{
const char *const c_config_charset =
cs_subset_string(NeoMutt->sub, "config_charset");
const char *const c_config_charset = cs_subset_string(NeoMutt->sub, "config_charset");
const char *const c_charset = cs_subset_string(NeoMutt->sub, "charset");
if (!c_config_charset || !c_charset)
return;
Expand Down
15 changes: 7 additions & 8 deletions alias/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,13 @@ static int op_sort(struct AliasMenuData *mdata, int op)
bool resort = true;
bool reverse = (op == OP_SORT_REVERSE);

switch (mutt_multi_choice(
reverse ?
/* L10N: The highlighted letters must match the "Sort" options */
_("Rev-Sort (a)lias, a(d)dress or (u)nsorted?") :
/* L10N: The highlighted letters must match the "Rev-Sort" options */
_("Sort (a)lias, a(d)dress or (u)nsorted?"),
/* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
_("adu")))
switch (mutt_multi_choice(reverse ?
/* L10N: The highlighted letters must match the "Sort" options */
_("Rev-Sort (a)lias, a(d)dress or (u)nsorted?") :
/* L10N: The highlighted letters must match the "Rev-Sort" options */
_("Sort (a)lias, a(d)dress or (u)nsorted?"),
/* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
_("adu")))
{
case -1: /* abort */
resort = false;
Expand Down
7 changes: 3 additions & 4 deletions attach/attachments.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ static int count_body_parts(struct Body *body)
shallrecurse = true;
if (mutt_istr_equal(bp->subtype, "alternative"))
{
const bool c_count_alternatives =
cs_subset_bool(NeoMutt->sub, "count_alternatives");
const bool c_count_alternatives = cs_subset_bool(NeoMutt->sub, "count_alternatives");
shallrecurse = c_count_alternatives;
}
}
Expand Down Expand Up @@ -592,8 +591,8 @@ enum CommandResult parse_unattachments(struct Buffer *buf, struct Buffer *s,
*/
void mutt_parse_mime_message(struct Email *e, FILE *fp)
{
const bool right_type =
(e->body->type == TYPE_MESSAGE) || (e->body->type == TYPE_MULTIPART);
const bool right_type = (e->body->type == TYPE_MESSAGE) ||
(e->body->type == TYPE_MULTIPART);
const bool not_parsed = (e->body->parts == NULL);

if (right_type && fp && not_parsed)
Expand Down
6 changes: 2 additions & 4 deletions attach/dlg_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ const char *attach_format_str(char *buf, size_t buflen, size_t col, int cols, ch
break;
case 'd':
{
const char *const c_message_format =
cs_subset_string(NeoMutt->sub, "message_format");
const char *const c_message_format = cs_subset_string(NeoMutt->sub, "message_format");
if (!optional)
{
if (aptr->body->description)
Expand Down Expand Up @@ -387,8 +386,7 @@ static void attach_make_entry(struct Menu *menu, char *buf, size_t buflen, int l
struct AttachPrivateData *priv = menu->mdata;
struct AttachCtx *actx = priv->actx;

const char *const c_attach_format =
cs_subset_string(NeoMutt->sub, "attach_format");
const char *const c_attach_format = cs_subset_string(NeoMutt->sub, "attach_format");
mutt_expando_format(buf, buflen, 0, menu->win->state.cols, NONULL(c_attach_format),
attach_format_str, (intptr_t) (actx->idx[actx->v2r[line]]),
MUTT_FORMAT_ARROWCURSOR);
Expand Down
25 changes: 9 additions & 16 deletions attach/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
#include "recvattach.h"
#include "recvcmd.h"

static const char *Not_available_in_this_menu =
N_("Not available in this menu");
static const char *Function_not_permitted_in_attach_message_mode =
N_("Function not permitted in attach-message mode");
static const char *Not_available_in_this_menu = N_("Not available in this menu");
static const char *Function_not_permitted_in_attach_message_mode = N_(
"Function not permitted in attach-message mode");

/**
* attach_collapse - Close the tree of the current attachment
Expand All @@ -71,8 +70,7 @@ static void attach_collapse(struct AttachCtx *actx, struct Menu *menu)
const int index = menu_get_index(menu);
rindex = actx->v2r[index] + 1;

const bool c_digest_collapse =
cs_subset_bool(NeoMutt->sub, "digest_collapse");
const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel))
{
if (c_digest_collapse && (actx->idx[rindex]->body->type == TYPE_MULTIPART) &&
Expand Down Expand Up @@ -218,14 +216,12 @@ static int op_attachment_delete(struct AttachPrivateData *priv, int op)

if ((WithCrypto != 0) && (priv->actx->email->security & SEC_ENCRYPT))
{
mutt_message(_("Deletion of attachments from encrypted messages is "
"unsupported"));
mutt_message(_("Deletion of attachments from encrypted messages is unsupported"));
return FR_ERROR;
}
if ((WithCrypto != 0) && (priv->actx->email->security & (SEC_SIGN | SEC_PARTSIGN)))
{
mutt_message(_("Deletion of attachments from signed messages may "
"invalidate the signature"));
mutt_message(_("Deletion of attachments from signed messages may invalidate the signature"));
}
if (!priv->menu->tag_prefix)
{
Expand Down Expand Up @@ -260,8 +256,7 @@ static int op_attachment_delete(struct AttachPrivateData *priv, int op)
}
else
{
mutt_message(
_("Only deletion of multipart attachments is supported"));
mutt_message(_("Only deletion of multipart attachments is supported"));
}
}
}
Expand Down Expand Up @@ -567,13 +562,11 @@ static int op_followup(struct AttachPrivateData *priv, int op)
if (check_attach())
return FR_ERROR;

const enum QuadOption c_followup_to_poster =
cs_subset_quad(NeoMutt->sub, "followup_to_poster");
const enum QuadOption c_followup_to_poster = cs_subset_quad(NeoMutt->sub, "followup_to_poster");
struct AttachPtr *cur_att = current_attachment(priv->actx, priv->menu);
if (!cur_att->body->email->env->followup_to ||
!mutt_istr_equal(cur_att->body->email->env->followup_to, "poster") ||
(query_quadoption(c_followup_to_poster,
_("Reply by mail as poster prefers?")) != MUTT_YES))
(query_quadoption(c_followup_to_poster, _("Reply by mail as poster prefers?")) != MUTT_YES))
{
mutt_attach_reply(cur_att->fp, priv->mailbox, priv->actx->email, priv->actx,
priv->menu->tag_prefix ? NULL : cur_att->body, SEND_NEWS | SEND_REPLY);
Expand Down
9 changes: 3 additions & 6 deletions attach/mutt_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode,
if (use_mailcap)
{
entry = mailcap_entry_new();
enum MailcapLookup mailcap_opt =
(mode == MUTT_VA_PAGER) ? MUTT_MC_AUTOVIEW : MUTT_MC_NO_FLAGS;
enum MailcapLookup mailcap_opt = (mode == MUTT_VA_PAGER) ? MUTT_MC_AUTOVIEW : MUTT_MC_NO_FLAGS;
if (!mailcap_lookup(a, type, sizeof(type), entry, mailcap_opt))
{
if ((mode == MUTT_VA_REGULAR) || (mode == MUTT_VA_PAGER))
Expand Down Expand Up @@ -1199,10 +1198,8 @@ int mutt_print_attachment(FILE *fp, struct Body *a)
goto out;
}

const char *const c_print_command =
cs_subset_string(NeoMutt->sub, "print_command");
if (mutt_istr_equal("text/plain", type) ||
mutt_istr_equal("application/postscript", type))
const char *const c_print_command = cs_subset_string(NeoMutt->sub, "print_command");
if (mutt_istr_equal("text/plain", type) || mutt_istr_equal("application/postscript", type))
{
rc = (mutt_pipe_attachment(fp, a, NONULL(c_print_command), NULL));
goto out;
Expand Down
26 changes: 10 additions & 16 deletions attach/recvattach.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ static void prepend_savedir(struct Buffer *buf)
return;

struct Buffer *tmp = mutt_buffer_pool_get();
const char *const c_attach_save_dir =
cs_subset_path(NeoMutt->sub, "attach_save_dir");
const char *const c_attach_save_dir = cs_subset_path(NeoMutt->sub, "attach_save_dir");
if (c_attach_save_dir)
{
mutt_buffer_addstr(tmp, c_attach_save_dir);
Expand Down Expand Up @@ -424,8 +423,7 @@ void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag,

const bool c_attach_split = cs_subset_bool(NeoMutt->sub, "attach_split");
const char *const c_attach_sep = cs_subset_string(NeoMutt->sub, "attach_sep");
const bool c_attach_save_without_prompting =
cs_subset_bool(NeoMutt->sub, "attach_save_without_prompting");
const bool c_attach_save_without_prompting = cs_subset_bool(NeoMutt->sub, "attach_save_without_prompting");

for (int i = 0; !tag || (i < actx->idxlen); i++)
{
Expand Down Expand Up @@ -828,8 +826,7 @@ static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag,
{
if (!state->fp_out)
{
mutt_error(
"BUG in print_attachment_list(). Please report this. ");
mutt_error("BUG in print_attachment_list(). Please report this. ");
return;
}

Expand Down Expand Up @@ -891,8 +888,7 @@ void mutt_print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, stru
if (!can_print(actx, top, tag))
return;
mutt_endwin();
const char *const c_print_command =
cs_subset_string(NeoMutt->sub, "print_command");
const char *const c_print_command = cs_subset_string(NeoMutt->sub, "print_command");
pid_t pid = filter_create(NONULL(c_print_command), &state.fp_out, NULL, NULL);
print_attachment_list(actx, fp, tag, top, &state);
mutt_file_fclose(&state.fp_out);
Expand All @@ -918,8 +914,7 @@ void recvattach_edit_content_type(struct AttachCtx *actx, struct Menu *menu, str
* made to a decrypted cur_att->body, so warn the user. */
if (cur_att->decrypted)
{
mutt_message(
_("Structural changes to decrypted attachments are not supported"));
mutt_message(_("Structural changes to decrypted attachments are not supported"));
mutt_sleep(1);
}
/* Editing the content type can rewrite the body structure. */
Expand Down Expand Up @@ -1175,17 +1170,16 @@ void mutt_attach_init(struct AttachCtx *actx)
* the outer container is of type 'multipart/digest' */
bool digest = mutt_istr_equal(actx->email->body->subtype, "digest");

const bool c_digest_collapse =
cs_subset_bool(NeoMutt->sub, "digest_collapse");
const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
for (int i = 0; i < actx->idxlen; i++)
{
actx->idx[i]->body->tagged = false;

/* OR an inner container is of type 'multipart/digest' */
actx->idx[i]->collapsed =
(c_digest_collapse &&
(digest || ((actx->idx[i]->body->type == TYPE_MULTIPART) &&
mutt_istr_equal(actx->idx[i]->body->subtype, "digest"))));
actx->idx[i]->collapsed = (c_digest_collapse &&
(digest ||
((actx->idx[i]->body->type == TYPE_MULTIPART) &&
mutt_istr_equal(actx->idx[i]->body->subtype, "digest"))));
}
}

Expand Down
12 changes: 4 additions & 8 deletions autocrypt/autocrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ static int autocrypt_dir_init(bool can_create)
int rc = 0;
struct stat st = { 0 };

const char *const c_autocrypt_dir =
cs_subset_path(NeoMutt->sub, "autocrypt_dir");
const char *const c_autocrypt_dir = cs_subset_path(NeoMutt->sub, "autocrypt_dir");
if (stat(c_autocrypt_dir, &st) == 0)
return 0;

Expand Down Expand Up @@ -101,8 +100,7 @@ int mutt_autocrypt_init(bool can_create)
return 0;

const bool c_autocrypt = cs_subset_bool(NeoMutt->sub, "autocrypt");
const char *const c_autocrypt_dir =
cs_subset_path(NeoMutt->sub, "autocrypt_dir");
const char *const c_autocrypt_dir = cs_subset_path(NeoMutt->sub, "autocrypt_dir");
if (!c_autocrypt || !c_autocrypt_dir)
return -1;

Expand Down Expand Up @@ -289,8 +287,7 @@ int mutt_autocrypt_process_autocrypt_header(struct Email *e, struct Envelope *en
return 0;

/* 1.1 spec also says to skip multipart/report emails */
if ((e->body->type == TYPE_MULTIPART) &&
mutt_istr_equal(e->body->subtype, "report"))
if ((e->body->type == TYPE_MULTIPART) && mutt_istr_equal(e->body->subtype, "report"))
{
return 0;
}
Expand Down Expand Up @@ -933,8 +930,7 @@ void mutt_autocrypt_scan_mailboxes(void)
through one or more mailboxes for Autocrypt: headers. Those headers are
then captured in the database as peer records and used for encryption.
If this is answered yes, they will be prompted for a mailbox. */
enum QuadOption scan =
mutt_yesorno(_("Scan a mailbox for autocrypt headers?"), MUTT_YES);
enum QuadOption scan = mutt_yesorno(_("Scan a mailbox for autocrypt headers?"), MUTT_YES);
while (scan == MUTT_YES)
{
struct Mailbox *m_cur = get_current_mailbox();
Expand Down
3 changes: 1 addition & 2 deletions autocrypt/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ int mutt_autocrypt_db_init(bool can_create)
return 0;

const bool c_autocrypt = cs_subset_bool(NeoMutt->sub, "autocrypt");
const char *const c_autocrypt_dir =
cs_subset_path(NeoMutt->sub, "autocrypt_dir");
const char *const c_autocrypt_dir = cs_subset_path(NeoMutt->sub, "autocrypt_dir");
if (!c_autocrypt || !c_autocrypt_dir)
return -1;

Expand Down
10 changes: 4 additions & 6 deletions autocrypt/dlg_autocrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ static void autocrypt_make_entry(struct Menu *menu, char *buf, size_t buflen, in
{
struct AccountEntry *entry = &((struct AccountEntry *) menu->mdata)[num];

const char *const c_autocrypt_acct_format =
cs_subset_string(NeoMutt->sub, "autocrypt_acct_format");
const char *const c_autocrypt_acct_format = cs_subset_string(NeoMutt->sub, "autocrypt_acct_format");
mutt_expando_format(buf, buflen, 0, menu->win->state.cols,
NONULL(c_autocrypt_acct_format), autocrypt_format_str,
(intptr_t) entry, MUTT_FORMAT_ARROWCURSOR);
Expand Down Expand Up @@ -234,8 +233,7 @@ static bool populate_menu(struct Menu *menu)
if (mutt_autocrypt_db_account_get_all(&accounts, &num_accounts) < 0)
return false;

struct AccountEntry *entries =
mutt_mem_calloc(num_accounts, sizeof(struct AccountEntry));
struct AccountEntry *entries = mutt_mem_calloc(num_accounts, sizeof(struct AccountEntry));
menu->mdata = entries;
menu->mdata_free = autocrypt_menu_free;
menu->max = num_accounts;
Expand Down Expand Up @@ -351,8 +349,8 @@ void dlg_select_autocrypt_account(void)
if (mutt_autocrypt_init(false))
return;

struct MuttWindow *dlg =
simple_dialog_new(MENU_AUTOCRYPT_ACCT, WT_DLG_AUTOCRYPT, AutocryptAcctHelp);
struct MuttWindow *dlg = simple_dialog_new(MENU_AUTOCRYPT_ACCT,
WT_DLG_AUTOCRYPT, AutocryptAcctHelp);

struct Menu *menu = dlg->wdata;
menu->make_entry = autocrypt_make_entry;
Expand Down
3 changes: 1 addition & 2 deletions autocrypt/gpgme.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
*/
static int create_gpgme_context(gpgme_ctx_t *ctx)
{
const char *const c_autocrypt_dir =
cs_subset_path(NeoMutt->sub, "autocrypt_dir");
const char *const c_autocrypt_dir = cs_subset_path(NeoMutt->sub, "autocrypt_dir");
gpgme_error_t err = gpgme_new(ctx);
if (!err)
err = gpgme_ctx_set_engine_info(*ctx, GPGME_PROTOCOL_OpenPGP, NULL, c_autocrypt_dir);
Expand Down
3 changes: 1 addition & 2 deletions bcache/bcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ static int bcache_path(struct ConnAccount *account, const char *mailbox, struct
char host[256];
struct Url url = { 0 };

const char *const c_message_cachedir =
cs_subset_path(NeoMutt->sub, "message_cachedir");
const char *const c_message_cachedir = cs_subset_path(NeoMutt->sub, "message_cachedir");
if (!account || !c_message_cachedir || !bcache)
return -1;

Expand Down
Loading

0 comments on commit c916fe3

Please sign in to comment.