NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
DOXYGEN
sort.c File Reference

Assorted sorting methods. More...

#include "config.h"
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "sort.h"
#include "alias.h"
#include "context.h"
#include "globals.h"
#include "mutt_logging.h"
#include "mutt_thread.h"
#include "options.h"
#include "score.h"
#include "nntp/nntp.h"
+ Include dependency graph for sort.c:

Go to the source code of this file.

Functions

int perform_auxsort (int retval, const void *a, const void *b)
 Compare two emails using the auxiliary sort method. More...
 
static int compare_score (const void *a, const void *b)
 Compare two emails using their scores - Implements sort_t. More...
 
static int compare_size (const void *a, const void *b)
 Compare the size of two emails - Implements sort_t. More...
 
static int compare_date_sent (const void *a, const void *b)
 Compare the sent date of two emails - Implements sort_t. More...
 
static int compare_subject (const void *a, const void *b)
 Compare the subject of two emails - Implements sort_t. More...
 
const char * mutt_get_name (const struct Address *a)
 Pick the best name to display from an address. More...
 
static int compare_to (const void *a, const void *b)
 Compare the 'to' fields of two emails - Implements sort_t. More...
 
static int compare_from (const void *a, const void *b)
 Compare the 'from' fields of two emails - Implements sort_t. More...
 
static int compare_date_received (const void *a, const void *b)
 Compare the date received of two emails - Implements sort_t. More...
 
static int compare_order (const void *a, const void *b)
 Restore the 'unsorted' order of emails - Implements sort_t. More...
 
static int compare_spam (const void *a, const void *b)
 Compare the spam values of two emails - Implements sort_t. More...
 
static int compare_label (const void *a, const void *b)
 Compare the labels of two emails - Implements sort_t. More...
 
sort_tmutt_get_sort_func (enum SortType method)
 Get the sort function for a given sort id. More...
 
void mutt_sort_headers (struct Context *ctx, bool init)
 Sort emails by their headers. More...
 

Variables

bool C_ReverseAlias
 Config: Display the alias in the index, rather than the message's sender. More...
 
static sort_tAuxSort = NULL
 

Detailed Description

Assorted sorting methods.

Authors
  • Michael R. Elkins
  • Pietro Cerutti

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 http://www.gnu.org/licenses/.

Definition in file sort.c.

Function Documentation

◆ perform_auxsort()

int perform_auxsort ( int  retval,
const void *  a,
const void *  b 
)

Compare two emails using the auxiliary sort method.

Parameters
retvalResult of normal sort method
aFirst email
bSecond email
Return values
-1a precedes b
0a and b are identical
1b precedes a

Definition at line 65 of file sort.c.

66 {
67  /* If the items compared equal by the main sort
68  * and we're not already doing an 'aux' sort... */
69  if ((retval == 0) && AuxSort && !OptAuxSort)
70  {
71  OptAuxSort = true;
72  retval = AuxSort(a, b);
73  OptAuxSort = false;
74  if (retval != 0)
75  return retval;
76  }
77  /* If the items still match, use their index positions
78  * to maintain a stable sort order */
79  if (retval == 0)
80  retval = (*((struct Email const *const *) a))->index -
81  (*((struct Email const *const *) b))->index;
82  return retval;
83 }
The envelope/body of an email.
Definition: email.h:39
WHERE bool OptAuxSort
(pseudo) using auxiliary sort function
Definition: options.h:33
int index
The absolute (unsorted) message number.
Definition: email.h:87
static sort_t * AuxSort
Definition: sort.c:54
+ Here is the caller graph for this function:

◆ compare_score()

static int compare_score ( const void *  a,
const void *  b 
)
static

Compare two emails using their scores - Implements sort_t.

Definition at line 88 of file sort.c.

89 {
90  struct Email const *const *pa = (struct Email const *const *) a;
91  struct Email const *const *pb = (struct Email const *const *) b;
92  int result = (*pb)->score - (*pa)->score; /* note that this is reverse */
93  result = perform_auxsort(result, a, b);
94  return SORT_CODE(result);
95 }
The envelope/body of an email.
Definition: email.h:39
int score
Message score.
Definition: email.h:90
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_size()

static int compare_size ( const void *  a,
const void *  b 
)
static

Compare the size of two emails - Implements sort_t.

Definition at line 100 of file sort.c.

101 {
102  struct Email const *const *pa = (struct Email const *const *) a;
103  struct Email const *const *pb = (struct Email const *const *) b;
104  int result = (*pa)->content->length - (*pb)->content->length;
105  result = perform_auxsort(result, a, b);
106  return SORT_CODE(result);
107 }
The envelope/body of an email.
Definition: email.h:39
struct Body * content
List of MIME parts.
Definition: email.h:92
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_date_sent()

static int compare_date_sent ( const void *  a,
const void *  b 
)
static

Compare the sent date of two emails - Implements sort_t.

Definition at line 112 of file sort.c.

113 {
114  struct Email const *const *pa = (struct Email const *const *) a;
115  struct Email const *const *pb = (struct Email const *const *) b;
116  int result = (*pa)->date_sent - (*pb)->date_sent;
117  result = perform_auxsort(result, a, b);
118  return SORT_CODE(result);
119 }
The envelope/body of an email.
Definition: email.h:39
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:83
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_subject()

static int compare_subject ( const void *  a,
const void *  b 
)
static

Compare the subject of two emails - Implements sort_t.

Definition at line 124 of file sort.c.

125 {
126  struct Email const *const *pa = (struct Email const *const *) a;
127  struct Email const *const *pb = (struct Email const *const *) b;
128  int rc;
129 
130  if (!(*pa)->env->real_subj)
131  {
132  if (!(*pb)->env->real_subj)
133  rc = compare_date_sent(pa, pb);
134  else
135  rc = -1;
136  }
137  else if (!(*pb)->env->real_subj)
138  rc = 1;
139  else
140  rc = mutt_str_strcasecmp((*pa)->env->real_subj, (*pb)->env->real_subj);
141  rc = perform_auxsort(rc, a, b);
142  return SORT_CODE(rc);
143 }
The envelope/body of an email.
Definition: email.h:39
static int compare_date_sent(const void *a, const void *b)
Compare the sent date of two emails - Implements sort_t.
Definition: sort.c:112
#define SORT_CODE(x)
Definition: sort.h:38
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_get_name()

const char* mutt_get_name ( const struct Address a)

Pick the best name to display from an address.

Parameters
aAddress to use
Return values
ptrDisplay name

This function uses:

  1. Alias for email address
  2. Personal name
  3. Email address

Definition at line 155 of file sort.c.

156 {
157  struct Address *ali = NULL;
158 
159  if (a)
160  {
161  if (C_ReverseAlias && (ali = mutt_alias_reverse_lookup(a)) && ali->personal)
162  return ali->personal;
163  else if (a->personal)
164  return a->personal;
165  else if (a->mailbox)
166  return mutt_addr_for_display(a);
167  }
168  /* don't return NULL to avoid segfault when printing/comparing */
169  return "";
170 }
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
const char * mutt_addr_for_display(const struct Address *a)
Convert an Address for display purposes.
Definition: address.c:976
struct Address * mutt_alias_reverse_lookup(const struct Address *a)
Does the user have an alias for the given address.
Definition: alias.c:542
bool C_ReverseAlias
Config: Display the alias in the index, rather than the message&#39;s sender.
Definition: sort.c:51
char * personal
Real name of address.
Definition: address.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_to()

static int compare_to ( const void *  a,
const void *  b 
)
static

Compare the 'to' fields of two emails - Implements sort_t.

Definition at line 175 of file sort.c.

176 {
177  struct Email const *const *ppa = (struct Email const *const *) a;
178  struct Email const *const *ppb = (struct Email const *const *) b;
179  char fa[128];
180 
181  mutt_str_strfcpy(fa, mutt_get_name(TAILQ_FIRST(&(*ppa)->env->to)), sizeof(fa));
182  const char *fb = mutt_get_name(TAILQ_FIRST(&(*ppb)->env->to));
183  int result = mutt_str_strncasecmp(fa, fb, sizeof(fa));
184  result = perform_auxsort(result, a, b);
185  return SORT_CODE(result);
186 }
The envelope/body of an email.
Definition: email.h:39
#define TAILQ_FIRST(head)
Definition: queue.h:717
int mutt_str_strncasecmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
Definition: string.c:656
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:155
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_from()

static int compare_from ( const void *  a,
const void *  b 
)
static

Compare the 'from' fields of two emails - Implements sort_t.

Definition at line 191 of file sort.c.

192 {
193  struct Email const *const *ppa = (struct Email const *const *) a;
194  struct Email const *const *ppb = (struct Email const *const *) b;
195  char fa[128];
196 
197  mutt_str_strfcpy(fa, mutt_get_name(TAILQ_FIRST(&(*ppa)->env->from)), sizeof(fa));
198  const char *fb = mutt_get_name(TAILQ_FIRST(&(*ppb)->env->from));
199  int result = mutt_str_strncasecmp(fa, fb, sizeof(fa));
200  result = perform_auxsort(result, a, b);
201  return SORT_CODE(result);
202 }
The envelope/body of an email.
Definition: email.h:39
#define TAILQ_FIRST(head)
Definition: queue.h:717
int mutt_str_strncasecmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
Definition: string.c:656
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:155
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_date_received()

static int compare_date_received ( const void *  a,
const void *  b 
)
static

Compare the date received of two emails - Implements sort_t.

Definition at line 207 of file sort.c.

208 {
209  struct Email const *const *pa = (struct Email const *const *) a;
210  struct Email const *const *pb = (struct Email const *const *) b;
211  int result = (*pa)->received - (*pb)->received;
212  result = perform_auxsort(result, a, b);
213  return SORT_CODE(result);
214 }
The envelope/body of an email.
Definition: email.h:39
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_order()

static int compare_order ( const void *  a,
const void *  b 
)
static

Restore the 'unsorted' order of emails - Implements sort_t.

Definition at line 219 of file sort.c.

220 {
221  struct Email const *const *ea = (struct Email const *const *) a;
222  struct Email const *const *eb = (struct Email const *const *) b;
223 
224  /* no need to auxsort because you will never have equality here */
225  return SORT_CODE((*ea)->index - (*eb)->index);
226 }
The envelope/body of an email.
Definition: email.h:39
#define SORT_CODE(x)
Definition: sort.h:38
+ Here is the caller graph for this function:

◆ compare_spam()

static int compare_spam ( const void *  a,
const void *  b 
)
static

Compare the spam values of two emails - Implements sort_t.

Definition at line 231 of file sort.c.

232 {
233  struct Email const *const *ppa = (struct Email const *const *) a;
234  struct Email const *const *ppb = (struct Email const *const *) b;
235  char *aptr = NULL, *bptr = NULL;
236  int ahas, bhas;
237  int result = 0;
238  double difference;
239 
240  /* Firstly, require spam attributes for both msgs */
241  /* to compare. Determine which msgs have one. */
242  ahas = (*ppa)->env && !mutt_buffer_is_empty(&(*ppa)->env->spam);
243  bhas = (*ppb)->env && !mutt_buffer_is_empty(&(*ppb)->env->spam);
244 
245  /* If one msg has spam attr but other does not, sort the one with first. */
246  if (ahas && !bhas)
247  return SORT_CODE(1);
248  if (!ahas && bhas)
249  return SORT_CODE(-1);
250 
251  /* Else, if neither has a spam attr, presume equality. Fall back on aux. */
252  if (!ahas && !bhas)
253  {
254  result = perform_auxsort(result, a, b);
255  return SORT_CODE(result);
256  }
257 
258  /* Both have spam attrs. */
259 
260  /* preliminary numeric examination */
261  difference =
262  (strtod((*ppa)->env->spam.data, &aptr) - strtod((*ppb)->env->spam.data, &bptr));
263 
264  /* map double into comparison (-1, 0, or 1) */
265  result = ((difference < 0.0) ? -1 : (difference > 0.0) ? 1 : 0);
266 
267  /* If either aptr or bptr is equal to data, there is no numeric */
268  /* value for that spam attribute. In this case, compare lexically. */
269  if ((aptr == (*ppa)->env->spam.data) || (bptr == (*ppb)->env->spam.data))
270  return SORT_CODE(strcmp(aptr, bptr));
271 
272  /* Otherwise, we have numeric value for both attrs. If these values */
273  /* are equal, then we first fall back upon string comparison, then */
274  /* upon auxiliary sort. */
275  if (result == 0)
276  {
277  result = strcmp(aptr, bptr);
278  result = perform_auxsort(result, a, b);
279  }
280 
281  return SORT_CODE(result);
282 }
The envelope/body of an email.
Definition: email.h:39
struct Envelope * env
Envelope information.
Definition: email.h:91
#define SORT_CODE(x)
Definition: sort.h:38
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_label()

static int compare_label ( const void *  a,
const void *  b 
)
static

Compare the labels of two emails - Implements sort_t.

Definition at line 287 of file sort.c.

288 {
289  struct Email const *const *ppa = (struct Email const *const *) a;
290  struct Email const *const *ppb = (struct Email const *const *) b;
291  int ahas, bhas, result = 0;
292 
293  /* As with compare_spam, not all messages will have the x-label
294  * property. Blank X-Labels are treated as null in the index
295  * display, so we'll consider them as null for sort, too. */
296  ahas = (*ppa)->env && (*ppa)->env->x_label && *((*ppa)->env->x_label);
297  bhas = (*ppb)->env && (*ppb)->env->x_label && *((*ppb)->env->x_label);
298 
299  /* First we bias toward a message with a label, if the other does not. */
300  if (ahas && !bhas)
301  return SORT_CODE(-1);
302  if (!ahas && bhas)
303  return SORT_CODE(1);
304 
305  /* If neither has a label, use aux sort. */
306  if (!ahas && !bhas)
307  {
308  result = perform_auxsort(result, a, b);
309  return SORT_CODE(result);
310  }
311 
312  /* If both have a label, we just do a lexical compare. */
313  result = mutt_str_strcasecmp((*ppa)->env->x_label, (*ppb)->env->x_label);
314  return SORT_CODE(result);
315 }
The envelope/body of an email.
Definition: email.h:39
struct Envelope * env
Envelope information.
Definition: email.h:91
#define SORT_CODE(x)
Definition: sort.h:38
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
int perform_auxsort(int retval, const void *a, const void *b)
Compare two emails using the auxiliary sort method.
Definition: sort.c:65
char * x_label
X-Label.
Definition: envelope.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_get_sort_func()

sort_t* mutt_get_sort_func ( enum SortType  method)

Get the sort function for a given sort id.

Parameters
methodSort type, see SortType
Return values
ptrsort function - Implements sort_t

Definition at line 322 of file sort.c.

323 {
324  switch (method)
325  {
326  case SORT_DATE:
327  return compare_date_sent;
328  case SORT_FROM:
329  return compare_from;
330  case SORT_LABEL:
331  return compare_label;
332  case SORT_ORDER:
333 #ifdef USE_NNTP
334  if (Context && (Context->mailbox->magic == MUTT_NNTP))
335  return nntp_compare_order;
336  else
337 #endif
338  return compare_order;
339  case SORT_RECEIVED:
340  return compare_date_received;
341  case SORT_SCORE:
342  return compare_score;
343  case SORT_SIZE:
344  return compare_size;
345  case SORT_SPAM:
346  return compare_spam;
347  case SORT_SUBJECT:
348  return compare_subject;
349  case SORT_TO:
350  return compare_to;
351  default:
352  return NULL;
353  }
354  /* not reached */
355 }
The "current" mailbox.
Definition: context.h:36
Sort by the date the email was sent.
Definition: sort.h:50
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: mailbox.h:51
static int compare_label(const void *a, const void *b)
Compare the labels of two emails - Implements sort_t.
Definition: sort.c:287
static int compare_date_sent(const void *a, const void *b)
Compare the sent date of two emails - Implements sort_t.
Definition: sort.c:112
static int compare_order(const void *a, const void *b)
Restore the &#39;unsorted&#39; order of emails - Implements sort_t.
Definition: sort.c:219
Sort by the email&#39;s subject.
Definition: sort.h:53
struct Mailbox * mailbox
Definition: context.h:50
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
Sort by the email&#39;s spam score.
Definition: sort.h:64
int nntp_compare_order(const void *a, const void *b)
Sort to mailbox order - Implements sort_t.
Definition: nntp.c:2363
Sort by the email&#39;s To field.
Definition: sort.h:58
static int compare_date_received(const void *a, const void *b)
Compare the date received of two emails - Implements sort_t.
Definition: sort.c:207
Sort by the emails label.
Definition: sort.h:69
static int compare_spam(const void *a, const void *b)
Compare the spam values of two emails - Implements sort_t.
Definition: sort.c:231
Sort by the email&#39;s From field.
Definition: sort.h:54
Sort by the size of the email.
Definition: sort.h:51
static int compare_size(const void *a, const void *b)
Compare the size of two emails - Implements sort_t.
Definition: sort.c:100
static int compare_to(const void *a, const void *b)
Compare the &#39;to&#39; fields of two emails - Implements sort_t.
Definition: sort.c:175
static int compare_subject(const void *a, const void *b)
Compare the subject of two emails - Implements sort_t.
Definition: sort.c:124
Sort by when the message were delivered locally.
Definition: sort.h:57
static int compare_score(const void *a, const void *b)
Compare two emails using their scores - Implements sort_t.
Definition: sort.c:88
Sort by the order the messages appear in the mailbox.
Definition: sort.h:55
Sort by the email&#39;s score.
Definition: sort.h:59
static int compare_from(const void *a, const void *b)
Compare the &#39;from&#39; fields of two emails - Implements sort_t.
Definition: sort.c:191
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_sort_headers()

void mutt_sort_headers ( struct Context ctx,
bool  init 
)

Sort emails by their headers.

Parameters
ctxMailbox
initIf true, rebuild the thread

Definition at line 362 of file sort.c.

363 {
364  struct Email *e = NULL;
365  struct MuttThread *thread = NULL, *top = NULL;
366  sort_t *sortfunc = NULL;
367 
368  OptNeedResort = false;
369 
370  if (!ctx)
371  return;
372 
373  if (ctx->mailbox->msg_count == 0)
374  {
375  /* this function gets called by mutt_sync_mailbox(), which may have just
376  * deleted all the messages. the virtual message numbers are not updated
377  * in that routine, so we must make sure to zero the vcount member. */
378  ctx->mailbox->vcount = 0;
379  ctx->vsize = 0;
380  mutt_clear_threads(ctx);
381  return; /* nothing to do! */
382  }
383 
384  if (!ctx->mailbox->quiet)
385  mutt_message(_("Sorting mailbox..."));
386 
387  if (OptNeedRescore && C_Score)
388  {
389  for (int i = 0; i < ctx->mailbox->msg_count; i++)
390  mutt_score_message(ctx->mailbox, ctx->mailbox->emails[i], true);
391  }
392  OptNeedRescore = false;
393 
394  if (OptResortInit)
395  {
396  OptResortInit = false;
397  init = true;
398  }
399 
400  if (init && ctx->tree)
401  mutt_clear_threads(ctx);
402 
403  if ((C_Sort & SORT_MASK) == SORT_THREADS)
404  {
405  AuxSort = NULL;
406  /* if $sort_aux changed after the mailbox is sorted, then all the
407  * subthreads need to be resorted */
408  if (OptSortSubthreads)
409  {
410  int i = C_Sort;
411  C_Sort = C_SortAux;
412  if (ctx->tree)
413  ctx->tree = mutt_sort_subthreads(ctx->tree, true);
414  C_Sort = i;
415  OptSortSubthreads = false;
416  }
417  mutt_sort_threads(ctx, init);
418  }
419  else if (!(sortfunc = mutt_get_sort_func(C_Sort & SORT_MASK)) ||
420  !(AuxSort = mutt_get_sort_func(C_SortAux & SORT_MASK)))
421  {
422  mutt_error(_("Could not find sorting function [report this bug]"));
423  return;
424  }
425  else
426  qsort((void *) ctx->mailbox->emails, ctx->mailbox->msg_count,
427  sizeof(struct Email *), sortfunc);
428 
429  /* adjust the virtual message numbers */
430  ctx->mailbox->vcount = 0;
431  for (int i = 0; i < ctx->mailbox->msg_count; i++)
432  {
433  struct Email *e_cur = ctx->mailbox->emails[i];
434  if ((e_cur->vnum != -1) || (e_cur->collapsed && (!ctx->pattern || e_cur->limited)))
435  {
436  e_cur->vnum = ctx->mailbox->vcount;
437  ctx->mailbox->v2r[ctx->mailbox->vcount] = i;
438  ctx->mailbox->vcount++;
439  }
440  e_cur->msgno = i;
441  }
442 
443  /* re-collapse threads marked as collapsed */
444  if ((C_Sort & SORT_MASK) == SORT_THREADS)
445  {
446  top = ctx->tree;
447  while ((thread = top))
448  {
449  while (!thread->message)
450  thread = thread->child;
451  e = thread->message;
452 
453  if (e->collapsed)
454  mutt_collapse_thread(ctx, e);
455  top = top->next;
456  }
457  mutt_set_vnum(ctx);
458  }
459 
460  if (!ctx->mailbox->quiet)
462 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
int sort_t(const void *a, const void *b)
typedef sort_t - Prototype for a function to compare two emails
Definition: sort.h:48
int msg_count
Total number of messages.
Definition: mailbox.h:102
The envelope/body of an email.
Definition: email.h:39
void mutt_set_vnum(struct Context *ctx)
Set the virtual index number of all the messages in a mailbox.
Definition: mutt_thread.c:1186
struct MuttThread * tree
Top of thread tree.
Definition: context.h:42
#define mutt_message(...)
Definition: logging.h:83
WHERE bool OptNeedResort
(pseudo) used to force a re-sort
Definition: options.h:41
struct MuttThread * mutt_sort_subthreads(struct MuttThread *thread, bool init)
Sort the children of a thread.
Definition: mutt_thread.c:655
void mutt_score_message(struct Mailbox *m, struct Email *e, bool upd_mbox)
Apply scoring to an email.
Definition: score.c:169
#define _(a)
Definition: message.h:28
WHERE bool OptNeedRescore
(pseudo) set when the &#39;score&#39; command is used
Definition: options.h:40
#define mutt_collapse_thread(ctx, e)
Definition: mutt_thread.h:57
int vcount
The number of virtual messages.
Definition: mailbox.h:113
void mutt_sort_threads(struct Context *ctx, bool init)
Sort email threads.
Definition: mutt_thread.c:833
struct Mailbox * mailbox
Definition: context.h:50
bool limited
Is this message in a limited view?
Definition: email.h:76
WHERE short C_Sort
Config: Sort method for the index.
Definition: sort.h:58
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:109
off_t vsize
Definition: context.h:38
struct MuttThread * child
Child of this Thread.
Definition: thread.h:46
sort_t * mutt_get_sort_func(enum SortType method)
Get the sort function for a given sort id.
Definition: sort.c:322
WHERE short C_SortAux
Config: Secondary sort method for the index.
Definition: sort.h:59
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:75
bool quiet
Inhibit status messages?
Definition: mailbox.h:129
int vnum
Virtual message number.
Definition: email.h:89
WHERE bool OptResortInit
(pseudo) used to force the next resort to be from scratch
Definition: options.h:49
struct Email * message
Email this Thread refers to.
Definition: thread.h:49
void mutt_clear_threads(struct Context *ctx)
Clear the threading of message in a mailbox.
Definition: mutt_thread.c:602
An Email conversation.
Definition: thread.h:34
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:112
#define mutt_error(...)
Definition: logging.h:84
WHERE bool C_Score
Config: Use message scoring.
Definition: globals.h:257
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:52
char * pattern
Limit pattern string.
Definition: context.h:39
Sort by email threads.
Definition: sort.h:56
static sort_t * AuxSort
Definition: sort.c:54
#define SORT_MASK
Mask for the sort id.
Definition: sort.h:85
int msgno
Number displayed to the user.
Definition: email.h:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_ReverseAlias

bool C_ReverseAlias

Config: Display the alias in the index, rather than the message's sender.

Definition at line 51 of file sort.c.

◆ AuxSort

sort_t* AuxSort = NULL
static

Definition at line 54 of file sort.c.