From: Pierre Habouzit Date: Wed, 15 Aug 2007 09:33:13 +0000 (+0200) Subject: Always resort, redraw, ... whatever when we change settings. X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=6c248aa3490f9c948da1bcfe49bdf8d7ba25e372 Always resort, redraw, ... whatever when we change settings. It's almost instantaneous, don't complicate the code for that. Signed-off-by: Pierre Habouzit --- diff --git a/init.c b/init.c index 04f45e8..7106e97 100644 --- a/init.c +++ b/init.c @@ -941,18 +941,12 @@ static void mutt_restore_default (const char* name __attribute__ ((unused)), p_delete(&init); } - if (ptr->flags & R_INDEX) - set_option (OPTFORCEREDRAWINDEX); - if (ptr->flags & R_PAGER) - set_option (OPTFORCEREDRAWPAGER); - if (ptr->flags & R_RESORT_SUB) - set_option (OPTSORTSUBTHREADS); - if (ptr->flags & R_RESORT) - set_option (OPTNEEDRESORT); - if (ptr->flags & R_RESORT_INIT) - set_option (OPTRESORTINIT); - if (ptr->flags & R_TREE) - set_option (OPTREDRAWTREE); + set_option (OPTFORCEREDRAWINDEX); + set_option (OPTFORCEREDRAWPAGER); + set_option (OPTSORTSUBTHREADS); + set_option (OPTNEEDRESORT); + set_option (OPTRESORTINIT); + set_option (OPTREDRAWTREE); } static int check_num (const char* option, unsigned long p, @@ -1009,15 +1003,6 @@ static const struct mapping_t* get_sortmap (struct option_t* option) { return (map); } -#define CHECK_PAGER \ - if ((CurrentMenu == MENU_PAGER) && \ - (!option || (option->flags & R_RESORT))) \ - { \ - snprintf (err->data, err->dsize, \ - _("Not available in this menu.")); \ - return (-1); \ - } - static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, BUFFER * err) { @@ -1082,7 +1067,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, set_option (OPTREDRAWTREE); return (0); } else { - CHECK_PAGER; mutt_restore_default (NULL, option, 1); } } @@ -1112,7 +1096,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, return 0; } - CHECK_PAGER; if (unset) unset_option (option->data); else if (inv) @@ -1130,7 +1113,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, /* XXX maybe we need to get unset into handlers? */ if (DTYPE (option->type) == DT_STR || DTYPE (option->type) == DT_PATH) { if (unset) { - CHECK_PAGER; p_delete((void **)(void *)&option->data); break; } @@ -1142,7 +1124,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, break; } - CHECK_PAGER; s->dptr++; mutt_extract_token (tmp, s, 0); if (!FuncTable[DTYPE (option->type)].opt_fromstr @@ -1157,7 +1138,6 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, } if (*s->dptr == '=') { - CHECK_PAGER; s->dptr++; mutt_extract_token (tmp, s, 0); if (ascii_strcasecmp ("yes", tmp->data) == 0) @@ -1191,18 +1171,12 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, break; } - if (option->flags & R_INDEX) - set_option (OPTFORCEREDRAWINDEX); - if (option->flags & R_PAGER) - set_option (OPTFORCEREDRAWPAGER); - if (option->flags & R_RESORT_SUB) - set_option (OPTSORTSUBTHREADS); - if (option->flags & R_RESORT) - set_option (OPTNEEDRESORT); - if (option->flags & R_RESORT_INIT) - set_option (OPTRESORTINIT); - if (option->flags & R_TREE) - set_option (OPTREDRAWTREE); + set_option (OPTFORCEREDRAWINDEX); + set_option (OPTFORCEREDRAWPAGER); + set_option (OPTSORTSUBTHREADS); + set_option (OPTNEEDRESORT); + set_option (OPTRESORTINIT); + set_option (OPTREDRAWTREE); } return (r); } diff --git a/init.h b/init.h index 1bbea8f..2ccc464 100644 --- a/init.h +++ b/init.h @@ -39,23 +39,9 @@ #define M_SET_UNSET (1<<1) /* default is to unset all vars */ #define M_SET_RESET (1<<2) /* default is to reset all vars to default */ -/* forced redraw/resort types */ -#define R_NONE 0 -#define R_INDEX (1<<0) -#define R_PAGER (1<<1) -#define R_BOTH (R_INDEX|R_PAGER) - -/* TODO:MC: will go in the the thread module */ -#define R_RESORT (1<<2) /* resort the mailbox */ -#define R_RESORT_SUB (1<<3) /* resort subthreads */ -#define R_RESORT_INIT (1<<4) /* resort from scratch */ -#define R_TREE (1<<5) /* redraw the thread tree */ -#define R_RESORT_BOTH (R_RESORT|R_RESORT_SUB) - struct option_t { const char *option; short type; - short flags; unsigned long data; const char *init; }; @@ -68,7 +54,7 @@ struct option_t { struct option_t MuttVars[] = { /*++*/ - {"abort_noattach", DT_QUAD, R_NONE, OPT_ATTACH, "no" }, + {"abort_noattach", DT_QUAD, OPT_ATTACH, "no" }, /* ** .pp ** This variable specifies whether to abort sending if no attachment @@ -86,7 +72,7 @@ struct option_t MuttVars[] = { ** .pp ** See also the $$attach_remind_regexp variable. */ - {"abort_nosubject", DT_QUAD, R_NONE, OPT_SUBJECT, "ask-yes" }, + {"abort_nosubject", DT_QUAD, OPT_SUBJECT, "ask-yes" }, /* ** .pp ** If set to \fIyes\fP, when composing messages and no subject is given @@ -94,7 +80,7 @@ struct option_t MuttVars[] = { ** \fIno\fP, composing messages with no subject given at the subject ** prompt will never be aborted. */ - {"abort_unmodified", DT_QUAD, R_NONE, OPT_ABORT, "yes" }, + {"abort_unmodified", DT_QUAD, OPT_ABORT, "yes" }, /* ** .pp ** If set to \fIyes\fP, composition will automatically abort after @@ -102,25 +88,25 @@ struct option_t MuttVars[] = { ** check only happens after the \fIfirst\fP edit of the file). When set ** to \fIno\fP, composition will never be aborted. */ - {"allow_8bit", DT_BOOL, R_NONE, OPTALLOW8BIT, "yes" }, + {"allow_8bit", DT_BOOL, OPTALLOW8BIT, "yes" }, /* ** .pp ** Controls whether 8-bit data is converted to 7-bit using either ** \fTquoted-printable\fP or \fTbase64\fP encoding when sending mail. */ - {"askbcc", DT_BOOL, R_NONE, OPTASKBCC, "no" }, + {"askbcc", DT_BOOL, OPTASKBCC, "no" }, /* ** .pp ** If \fIset\fP, Madmutt will prompt you for blind-carbon-copy (Bcc) recipients ** before editing an outgoing message. */ - {"askcc", DT_BOOL, R_NONE, OPTASKCC, "no" }, + {"askcc", DT_BOOL, OPTASKCC, "no" }, /* ** .pp ** If \fIset\fP, Madmutt will prompt you for carbon-copy (Cc) recipients before ** editing the body of an outgoing message. */ - {"attach_format", DT_STR, R_NONE, UL &AttachFormat, "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "}, + {"attach_format", DT_STR, UL &AttachFormat, "%u%D%I %t%4n %T%.40d%> [%.7m/%.10M, %.6e%?C?, %C?, %s] "}, /* ** .pp ** This variable describes the format of the ``attachment'' menu. The @@ -147,7 +133,7 @@ struct option_t MuttVars[] = { ** .dt %|X .dd pad to the end of the line with character "X" ** .de */ - {"attach_remind_regexp", DT_RX, R_NONE, UL &AttachRemindRegexp, "attach"}, + {"attach_remind_regexp", DT_RX, UL &AttachRemindRegexp, "attach"}, /* ** .pp ** If this variable is non-empty, madmutt will scan a message's contents @@ -157,13 +143,13 @@ struct option_t MuttVars[] = { ** This variable and $$abort_noattach are intended to remind the user ** to attach files if the message's text references them. */ - {"attach_sep", DT_STR, R_NONE, UL &AttachSep, "\n"}, + {"attach_sep", DT_STR, UL &AttachSep, "\n"}, /* ** .pp ** The separator to add between attachments when operating (saving, ** printing, piping, etc) on a list of tagged attachments. */ - {"attach_split", DT_BOOL, R_NONE, OPTATTACHSPLIT, "yes" }, + {"attach_split", DT_BOOL, OPTATTACHSPLIT, "yes" }, /* ** .pp ** If this variable is \fIunset\fP, when operating (saving, printing, piping, @@ -172,14 +158,14 @@ struct option_t MuttVars[] = { ** ``$$attach_sep'' separator is added after each attachment. When \fIset\fP, ** Madmutt will operate on the attachments one by one. */ - {"attribution", DT_STR, R_NONE, UL &Attribution, "On %d, %n wrote:"}, + {"attribution", DT_STR, UL &Attribution, "On %d, %n wrote:"}, /* ** .pp ** This is the string that will precede a message which has been included ** in a reply. For a full listing of defined \fTprintf(3)\fP-like sequences see ** the section on ``$$index_format''. */ - {"autoedit", DT_BOOL, R_NONE, OPTAUTOEDIT, "no" }, + {"autoedit", DT_BOOL, OPTAUTOEDIT, "no" }, /* ** .pp ** When \fIset\fP along with ``$$edit_headers'', Madmutt will skip the initial @@ -189,7 +175,7 @@ struct option_t MuttVars[] = { ** .pp ** Also see ``$$fast_reply''. */ - {"auto_tag", DT_BOOL, R_NONE, OPTAUTOTAG, "no" }, + {"auto_tag", DT_BOOL, OPTAUTOTAG, "no" }, /* ** .pp ** When \fIset\fP, functions in the \fIindex\fP menu which affect a message @@ -197,7 +183,7 @@ struct option_t MuttVars[] = { ** unset, you must first use the ``tag-prefix'' function (default: "\fT;\fP") to ** make the next function apply to all tagged messages. */ - {"bounce", DT_QUAD, R_NONE, OPT_BOUNCE, "ask-yes" }, + {"bounce", DT_QUAD, OPT_BOUNCE, "ask-yes" }, /* ** .pp ** Controls whether you will be asked to confirm bouncing messages. @@ -205,14 +191,14 @@ struct option_t MuttVars[] = { ** message. Setting this variable to \fIno\fP is not generally useful, ** and thus not recommended, because you are unable to bounce messages. */ - {"bounce_delivered", DT_BOOL, R_NONE, OPTBOUNCEDELIVERED, "yes" }, + {"bounce_delivered", DT_BOOL, OPTBOUNCEDELIVERED, "yes" }, /* ** .pp ** When this variable is \fIset\fP, Madmutt will include ** \fTDelivered-To:\fP header fields when bouncing messages. ** Postfix users may wish to \fIunset\fP this variable. */ - {"check_new", DT_BOOL, R_NONE, OPTCHECKNEW, "yes" }, + {"check_new", DT_BOOL, OPTCHECKNEW, "yes" }, /* ** .pp ** \fBNote:\fP this option only affects \fImaildir\fP and \fIMH\fP style @@ -224,19 +210,19 @@ struct option_t MuttVars[] = { ** checking each file to see if it has already been looked at. If it's ** \fIunset\fP, no check for new mail is performed while the mailbox is open. */ - {"collapse_unread", DT_BOOL, R_NONE, OPTCOLLAPSEUNREAD, "yes" }, + {"collapse_unread", DT_BOOL, OPTCOLLAPSEUNREAD, "yes" }, /* ** .pp ** When \fIunset\fP, Madmutt will not collapse a thread if it contains any ** unread messages. */ - {"uncollapse_jump", DT_BOOL, R_NONE, OPTUNCOLLAPSEJUMP, "no" }, + {"uncollapse_jump", DT_BOOL, OPTUNCOLLAPSEJUMP, "no" }, /* ** .pp ** When \fIset\fP, Madmutt will jump to the next unread message, if any, ** when the current thread is \fIun\fPcollapsed. */ - {"compose_format", DT_STR, R_BOTH, UL &ComposeFormat, "-- Madmutt: Compose [Approx. msg size: %l Atts: %a]%>-"}, + {"compose_format", DT_STR, UL &ComposeFormat, "-- Madmutt: Compose [Approx. msg size: %l Atts: %a]%>-"}, /* ** .pp ** Controls the format of the status line displayed in the ``compose'' @@ -253,45 +239,45 @@ struct option_t MuttVars[] = { ** See the text describing the ``$$status_format'' option for more ** information on how to set ``$$compose_format''. */ - {"config_charset", DT_STR, R_NONE, UL &ConfigCharset, "" }, + {"config_charset", DT_STR, UL &ConfigCharset, "" }, /* ** .pp ** When defined, Madmutt will recode commands in rc files from this ** encoding. */ - {"confirmappend", DT_BOOL, R_NONE, OPTCONFIRMAPPEND, "yes" }, + {"confirmappend", DT_BOOL, OPTCONFIRMAPPEND, "yes" }, /* ** .pp ** When \fIset\fP, Madmutt will prompt for confirmation when appending messages to ** an existing mailbox. */ - {"confirmcreate", DT_BOOL, R_NONE, OPTCONFIRMCREATE, "yes" }, + {"confirmcreate", DT_BOOL, OPTCONFIRMCREATE, "yes" }, /* ** .pp ** When \fIset\fP, Madmutt will prompt for confirmation when saving messages to a ** mailbox which does not yet exist before creating it. */ - {"connect_timeout", DT_NUM, R_NONE, UL &ConnectTimeout, "30" }, + {"connect_timeout", DT_NUM, UL &ConnectTimeout, "30" }, /* ** .pp ** Causes Madmutt to timeout a network connection (for IMAP or POP) after this ** many seconds if the connection is not able to be established. A negative ** value causes Madmutt to wait indefinitely for the connection to succeed. */ - {"content_type", DT_STR, R_NONE, UL &ContentType, "text/plain"}, + {"content_type", DT_STR, UL &ContentType, "text/plain"}, /* ** .pp ** Sets the default \fTContent-Type:\fP header field for the body ** of newly composed messages. */ - {"copy", DT_QUAD, R_NONE, OPT_COPY, "yes" }, + {"copy", DT_QUAD, OPT_COPY, "yes" }, /* ** .pp ** This variable controls whether or not copies of your outgoing messages ** will be saved for later references. Also see ``$$record'', ** and ``$fcc-hook''. */ - {"date_format", DT_STR, R_BOTH, UL &DateFmt, "!%a, %b %d, %Y at %I:%M:%S%p %Z"}, + {"date_format", DT_STR, UL &DateFmt, "!%a, %b %d, %Y at %I:%M:%S%p %Z"}, /* ** .pp ** This variable controls the format of the date printed by the ``\fT%d\fP'' @@ -305,7 +291,7 @@ struct option_t MuttVars[] = { ** rest of the string are expanded in the \fIC\fP locale (that is in US ** English). */ - {"default_hook", DT_STR, R_NONE, UL &DefaultHook, "~f %s !~P | (~P ~C %s)"}, + {"default_hook", DT_STR, UL &DefaultHook, "~f %s !~P | (~P ~C %s)"}, /* ** .pp ** This variable controls how send-hooks, message-hooks, save-hooks, @@ -319,7 +305,7 @@ struct option_t MuttVars[] = { ** ``alternates'') and is to or cc'ed to a user matching the given ** regular expression. */ - {"delete", DT_QUAD, R_NONE, OPT_DELETE, "ask-yes" }, + {"delete", DT_QUAD, OPT_DELETE, "ask-yes" }, /* ** .pp ** Controls whether or not messages are really deleted when closing or @@ -327,7 +313,7 @@ struct option_t MuttVars[] = { ** deleting will automatically be purged without prompting. If set to ** \fIno\fP, messages marked for deletion will be kept in the mailbox. */ - {"delete_space", DT_BOOL, R_NONE, OPTDELSP, "no" }, + {"delete_space", DT_BOOL, OPTDELSP, "no" }, /* ** .pp ** When sending messages with \fTformat=flowed\fP by \fIsetting\fP the @@ -340,27 +326,27 @@ struct option_t MuttVars[] = { ** \fBNote:\fP this variable only has an effect on \fIoutgoing\fP messages ** (if $$text_flowed is \fIset\fP) but not on incomming. */ - {"delete_untag", DT_BOOL, R_NONE, OPTDELETEUNTAG, "yes" }, + {"delete_untag", DT_BOOL, OPTDELETEUNTAG, "yes" }, /* ** .pp ** If this option is \fIset\fP, Madmutt will untag messages when marking them ** for deletion. This applies when you either explicitly delete a message, ** or when you save it to another folder. */ - {"digest_collapse", DT_BOOL, R_NONE, OPTDIGESTCOLLAPSE, "yes" }, + {"digest_collapse", DT_BOOL, OPTDIGESTCOLLAPSE, "yes" }, /* ** .pp ** If this option is \fIset\fP, Madmutt's received-attachments menu will not show the subparts of ** individual messages in a multipart/digest. To see these subparts, press 'v' on that menu. */ - {"display_filter", DT_PATH, R_PAGER, UL &DisplayFilter, ""}, + {"display_filter", DT_PATH, UL &DisplayFilter, ""}, /* ** .pp ** When \fIset\fP, specifies a command used to filter messages. When a message ** is viewed it is passed as standard input to $$display_filter, and the ** filtered message is read from the standard output. */ - {"duplicate_threads", DT_BOOL, R_RESORT|R_RESORT_INIT|R_INDEX, OPTDUPTHREADS, "yes" }, + {"duplicate_threads", DT_BOOL, OPTDUPTHREADS, "yes" }, /* ** .pp ** This variable controls whether Madmutt, when sorting by threads, threads @@ -368,7 +354,7 @@ struct option_t MuttVars[] = { ** If it is \fIset\fP, it will indicate that it thinks they are duplicates ** of each other with an equals sign in the thread diagram. */ - {"edit_headers", DT_BOOL, R_NONE, OPTEDITHDRS, "no" }, + {"edit_headers", DT_BOOL, OPTEDITHDRS, "no" }, /* ** .pp ** This option allows you to edit the header of your outgoing messages @@ -379,9 +365,9 @@ struct option_t MuttVars[] = { ** $$editor_headers option. */ #ifdef USE_NNTP - {"editor_headers", DT_STR, R_NONE, UL &EditorHeaders, "From: To: Cc: Bcc: Subject: Reply-To: Newsgroups: Followup-To: X-Comment-To:" }, + {"editor_headers", DT_STR, UL &EditorHeaders, "From: To: Cc: Bcc: Subject: Reply-To: Newsgroups: Followup-To: X-Comment-To:" }, #else - {"editor_headers", DT_STR, R_NONE, UL &EditorHeaders, "From: To: Cc: Bcc: Subject: Reply-To:" }, + {"editor_headers", DT_STR, UL &EditorHeaders, "From: To: Cc: Bcc: Subject: Reply-To:" }, #endif /* ** .pp @@ -393,7 +379,7 @@ struct option_t MuttVars[] = { ** Note: if $$edit_headers had to be turned on by force because ** $$strict_mailto is \fIunset\fP, this option has no effect. */ - {"encode_from", DT_BOOL, R_NONE, OPTENCODEFROM, "no" }, + {"encode_from", DT_BOOL, OPTENCODEFROM, "no" }, /* ** .pp ** When \fIset\fP, Madmutt will \fTquoted-printable\fP encode messages when @@ -408,7 +394,7 @@ struct option_t MuttVars[] = { ** you must take care of space-stuffing