From b4b6bbe50dd9adbf4ac2738ca9c2ab74d384114a Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Fri, 21 Jul 2017 23:34:18 +0200 Subject: [PATCH] Tidying the code --- hdrline.c | 2 +- header.h | 2 +- imap/imap.c | 8 ++++---- imap/message.c | 3 +-- init.h | 8 ++++---- mutt_notmuch.c | 3 ++- mutt_tags.c | 45 +++++++++++++++++++++++---------------------- mutt_tags.h | 34 ++++++++++++++++++---------------- 8 files changed, 54 insertions(+), 51 deletions(-) diff --git a/hdrline.c b/hdrline.c index 6fcda728d..4d1c9910f 100644 --- a/hdrline.c +++ b/hdrline.c @@ -472,9 +472,9 @@ static char *apply_subject_mods(struct Envelope *env) * | \%F | like %n, unless from self * | \%g | message tags (e.g. notmuch tags/imap flags) * | \%Gx | individual message tag (e.g. notmuch tags/imap flags) - * | \%J | message tags (if present, tree unfolded, and != parent's keywords) * | \%i | message-id * | \%I | initials of author + * | \%J | message tags (if present, tree unfolded, and != parent's keywords) * | \%K | the list to which the letter was sent (if any; otherwise: empty) * | \%l | number of lines in the message * | \%L | like %F, except `lists' are displayed first diff --git a/header.h b/header.h index 27add4da1..914462dd3 100644 --- a/header.h +++ b/header.h @@ -108,7 +108,7 @@ struct Header int refno; /**< message number on server */ #endif - void *tags; /* for driver that support server tagging */ + void *tags; /**< for drivers that support server tagging */ #if defined(USE_POP) || defined(USE_IMAP) || defined(USE_NNTP) || defined(USE_NOTMUCH) void *data; /**< driver-specific data */ void (*free_cb)(struct Header *); /**< driver-specific data free function */ diff --git a/imap/imap.c b/imap/imap.c index 0504afd95..c667dd5e0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1258,12 +1258,12 @@ static int sync_helper(struct ImapData *idata, int right, int flag, const char * return count; } - -/* imap_edit_message_tags: Prompt and validate new messages tags +/** + * imap_edit_message_tags - Prompt and validate new messages tags * * @retval 0: no valid user input * @retval 1: buf set - **/ + */ static int imap_edit_message_tags(struct Context *ctx, const char *tags, char *buf) { char *new = NULL; @@ -1317,7 +1317,7 @@ static int imap_edit_message_tags(struct Context *ctx, const char *tags, char *b *checker == 91 || // [ *checker == 93) // ] { - mutt_error(_("Invalid IMAP keyworks")); + mutt_error(_("Invalid IMAP keywords")); mutt_sleep(2); return 0; } diff --git a/imap/message.c b/imap/message.c index 23778adda..072e64a17 100644 --- a/imap/message.c +++ b/imap/message.c @@ -477,7 +477,7 @@ static void imap_generate_seqset(struct Buffer *b, struct ImapData *idata, } } -/* +/** * imap_read_headers - Read headers from the server * * Changed to read many headers instead of just one. It will return the msn of @@ -722,7 +722,6 @@ int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned i /* make sure we don't get remnants from older larger message headers */ fputs("\n\n", fp); - if (h.data->msn < 1 || h.data->msn > fetch_msn_end) { mutt_debug(1, "imap_read_headers: skipping FETCH response for " diff --git a/init.h b/init.h index 5e2d71f65..d0982bb17 100644 --- a/init.h +++ b/init.h @@ -2183,10 +2183,10 @@ struct Option MuttVars[] = { */ { "hidden_tags", DT_STRING, R_NONE, UL &HiddenTags, UL "unread,draft,flagged,passed,replied,attachment,signed,encrypted" }, /* - ** .pp - ** This variable specifies private notmuch tags which should not be printed - ** on screen. - */ + ** .pp + ** This variable specifies private notmuch/imap tags which should not be printed + ** on screen. + */ { "pager_context", DT_NUMBER, R_NONE, UL &PagerContext, 0 }, /* ** .pp diff --git a/mutt_notmuch.c b/mutt_notmuch.c index 9234eb30a..d17283610 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -837,7 +837,9 @@ err: static int update_header_tags(struct Header *h, notmuch_message_t *msg) { +#ifdef DEBUG struct NmHdrData *data = h->data; +#endif notmuch_tags_t *tags = NULL; char *new_tags = NULL; @@ -1853,7 +1855,6 @@ static int nm_edit_message_tags(struct Context *ctx, const char *tags, char *buf return (mutt_get_field("Add/remove labels: ", buf, sizeof(buf), MUTT_NM_TAG) || !*buf); } - static int nm_commit_message_tags(struct Context *ctx, struct Header *hdr, char *buf) { struct NmCtxData *data = get_ctxdata(ctx); diff --git a/mutt_tags.c b/mutt_tags.c index 8493f85ec..ea90bf9e3 100644 --- a/mutt_tags.c +++ b/mutt_tags.c @@ -1,20 +1,23 @@ -/* - * Copyright (C) 2017 Mehdi Abaakouk +/** + * @file + * Email tags/keywords/labels * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * @authors + * Copyright (C) 2017 Mehdi Abaakouk * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * @copyright + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #include "config.h" @@ -30,7 +33,7 @@ /** * hdr_tags_free_tag_list - free tag - * @param[in] h: pointer to a header struct + * @param[in] h: pointer to a Header struct * * Free tag */ @@ -81,7 +84,7 @@ const char *hdr_tags_get_transformed(struct Header *h) return HEADER_TAGS(h)->tags_transformed; } -/* +/** * hdr_tags_get - Get tags from a header * @param[in] h: pointer to a header struct * @@ -97,8 +100,8 @@ const char *hdr_tags_get(struct Header *h) return HEADER_TAGS(h)->tags; } -/* - * hdr_tags_get - Get tags with hiddens from a header +/** + * hdr_tags_get_with_hidden - Get tags with hiddens from a header * @param[in] h: pointer to a header struct * * @return string tags @@ -146,8 +149,9 @@ void hdr_tags_init(struct Header *h) HEADER_TAGS(h)->tags_with_hidden = NULL; HEADER_TAGS(h)->tag_list = NULL; } + /** - * hdr_tags_replace - Add a tag to header + * hdr_tags_add - Add a tag to header * @param[in] h: pointer to a header struct * @param[in] new_tag: string representing the new tag * @@ -175,7 +179,7 @@ void hdr_tags_add(struct Header *h, char *new_tag) if (HiddenTags) { char *p = strstr(HiddenTags, new_tag); - size_t xsz = p ? strlen(new_tag) : 0; + size_t xsz = p ? mutt_strlen(new_tag) : 0; if (p && ((p == HiddenTags) || (*(p - 1) == ',') || (*(p - 1) == ' ')) && ((*(p + xsz) == '\0') || (*(p + xsz) == ',') || (*(p + xsz) == ' '))) @@ -197,7 +201,6 @@ void hdr_tags_add(struct Header *h, char *new_tag) * @retval 0 If no change are made * @retval 1 If tags are updated * - * * Free current tags structures and replace it by * new tags */ @@ -221,7 +224,6 @@ int hdr_tags_replace(struct Header *h, char *tags) return 1; } - int hdr_tags_editor(struct Context *ctx, const char *tags, char *buf) { if (ctx->mx_ops->edit_msg_tags) @@ -231,7 +233,6 @@ int hdr_tags_editor(struct Context *ctx, const char *tags, char *buf) return -1; } - int hdr_tags_commit(struct Context *ctx, struct Header *h, char *tags) { if (ctx->mx_ops->commit_msg_tags) diff --git a/mutt_tags.h b/mutt_tags.h index 2403d8165..b3b1e16d0 100644 --- a/mutt_tags.h +++ b/mutt_tags.h @@ -1,20 +1,23 @@ -/* - * Copyright (C) 2017 Mehdi Abaakouk +/** + * @file + * Email tags/keywords/labels * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * @authors + * Copyright (C) 2017 Mehdi Abaakouk * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * @copyright + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef _MUTT_TAG_H @@ -24,12 +27,12 @@ #include "context.h" /** - * hdr_tag - Mail Header Tags + * struct HeaderTag - Mail Header Tags * * Keep a linked list of header tags and their transformed values. * Textual tags can be transformed to symbols to save space. * - * @sa hdr_tags#tag_list + * @sa HeaderTags#tag_list */ struct HeaderTag { @@ -42,7 +45,6 @@ struct HeaderTag * struct HeaderTags - tags data attached to an email * * This stores all tags data associated with an email. - * */ struct HeaderTags { -- 2.40.0