diff options
author | Kevin McCarthy <kevin@8t8.us> | 2021-04-24 15:10:22 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2021-04-25 14:49:55 -0700 |
commit | 2333015fd0e5096572fc9336fd802f868d3a4cdf (patch) | |
tree | 3945fb1efed5cbd760e21d7b1712b41813edfd22 /browser.c | |
parent | f898446896156c7e14f7de3775b0f70c1eecb35d (diff) |
Change browser sort "unsorted" to preserve the original order.
Record entry numbers as they are added to the list, so re-sorting by
"unsorted" can return to the original order.
This is most useful for the mailboxes case, where "unsorted" should
mean the order listed in the muttrc.
Diffstat (limited to 'browser.c')
-rw-r--r-- | browser.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -84,6 +84,16 @@ static void destroy_state (struct browser_state *state) /* This is set by browser_sort() */ static int sort_reverse_flag = 0; +static int browser_compare_order (const void *a, const void *b) +{ + struct folder_file *pa = (struct folder_file *) a; + struct folder_file *pb = (struct folder_file *) b; + + int r = pa->number - pb->number; + + return (sort_reverse_flag ? -r : r); +} + static int browser_compare_subject (const void *a, const void *b) { struct folder_file *pa = (struct folder_file *) a; @@ -144,7 +154,8 @@ static void browser_sort (struct browser_state *state) switch (sort_variable & SORT_MASK) { case SORT_ORDER: - return; + f = browser_compare_order; + break; case SORT_DATE: f = browser_compare_date; break; @@ -200,7 +211,6 @@ static int select_sort (struct browser_state *state, int reverse) case 6: /* do(n)'t sort */ new_sort = SORT_ORDER; - resort = 0; break; case -1: /* abort */ @@ -473,6 +483,9 @@ static void add_folder (MUTTMENU *m, struct browser_state *state, (state->entry)[state->entrylen].display_name = safe_strdup (display_name); (state->entry)[state->entrylen].full_path = safe_strdup (full_path); + + (state->entry)[state->entrylen].number = state->entrylen; + #ifdef USE_IMAP (state->entry)[state->entrylen].imap = 0; #endif |