Create/manipulate threading in emails. More...
#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "mutt_thread.h"
#include "globals.h"
#include "mview.h"
#include "mx.h"
#include "protos.h"
Go to the source code of this file.
Functions | |
enum UseThreads | mutt_thread_style (void) |
Which threading style is active? | |
const char * | get_use_threads_str (enum UseThreads value) |
Convert UseThreads enum to string. | |
int | sort_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err) |
Validate the "sort" config variable - Implements ConfigDef::validator() -. | |
static bool | is_visible (struct Email *e) |
Is the message visible? | |
static bool | need_display_subject (struct Email *e) |
Determines whether to display a message's subject. | |
static void | linearize_tree (struct ThreadsContext *tctx) |
Flatten an email thread. | |
static void | calculate_visibility (struct MuttThread *tree, int *max_depth) |
Are tree nodes visible. | |
struct ThreadsContext * | mutt_thread_ctx_init (struct MailboxView *mv) |
Initialize a threading context. | |
void | mutt_thread_ctx_free (struct ThreadsContext **ptr) |
Finalize a threading context. | |
void | mutt_draw_tree (struct ThreadsContext *tctx) |
Draw a tree of threaded emails. | |
static void | make_subject_list (struct ListHead *subjects, struct MuttThread *cur, time_t *dateptr) |
Create a sorted list of all subjects in a thread. | |
static struct MuttThread * | find_subject (struct Mailbox *m, struct MuttThread *cur) |
Find the best possible match for a parent based on subject. | |
static struct HashTable * | make_subj_hash (struct Mailbox *m) |
Create a Hash Table for the email subjects. | |
static void | pseudo_threads (struct ThreadsContext *tctx) |
Thread messages by subject. | |
void | mutt_clear_threads (struct ThreadsContext *tctx) |
Clear the threading of message in a mailbox. | |
static int | compare_threads (const void *a, const void *b, void *sdata) |
Helper to sort email threads - Implements sort_t -. | |
static void | mutt_sort_subthreads (struct ThreadsContext *tctx, bool init) |
Sort the children of a thread. | |
static void | check_subjects (struct MailboxView *mv, bool init) |
Find out which emails' subjects differ from their parent's. | |
static void | thread_hash_destructor (int type, void *obj, intptr_t data) |
Free our hash table data - Implements hash_hdata_free_t -. | |
void | mutt_sort_threads (struct ThreadsContext *tctx, bool init) |
Sort email threads. | |
int | mutt_aside_thread (struct Email *e, bool forwards, bool subthreads) |
Find the next/previous (sub)thread. | |
int | mutt_parent_message (struct Email *e, bool find_root) |
Find the parent of a message. | |
off_t | mutt_set_vnum (struct Mailbox *m) |
Set the virtual index number of all the messages in a mailbox. | |
int | mutt_traverse_thread (struct Email *e_cur, MuttThreadFlags flag) |
Recurse through an email thread, matching messages. | |
int | mutt_messages_in_thread (struct Mailbox *m, struct Email *e, enum MessageInThread mit) |
Count the messages in a thread. | |
struct HashTable * | mutt_make_id_hash (struct Mailbox *m) |
Create a Hash Table for message-ids. | |
static bool | link_threads (struct Email *parent, struct Email *child, struct Mailbox *m) |
Forcibly link messages together. | |
bool | mutt_link_threads (struct Email *parent, struct EmailArray *children, struct Mailbox *m) |
Forcibly link threads together. | |
void | mutt_thread_collapse_collapsed (struct ThreadsContext *tctx) |
Re-collapse threads marked as collapsed. | |
void | mutt_thread_collapse (struct ThreadsContext *tctx, bool collapse) |
Toggle collapse. | |
bool | mutt_thread_can_collapse (struct Email *e) |
Check whether a thread can be collapsed. | |
Variables | |
static const struct Mapping | UseThreadsMethods [] |
Choices for '$use_threads' for the index. | |
const struct EnumDef | UseThreadsTypeDef |
Data for the $use_threads enumeration. | |
Create/manipulate threading in emails.
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 mutt_thread.c.
enum UseThreads mutt_thread_style | ( | void | ) |
Which threading style is active?
UT_FLAT | No threading in use |
UT_THREADS | Normal threads (root above subthread) |
UT_REVERSE | Reverse threads (subthread above root) |
Definition at line 81 of file mutt_thread.c.
const char * get_use_threads_str | ( | enum UseThreads | value | ) |
Convert UseThreads enum to string.
value | Value to convert |
ptr | String form of value |
Definition at line 99 of file mutt_thread.c.
|
static |
Is the message visible?
e |
true | The message is not hidden in some way |
Definition at line 123 of file mutt_thread.c.
|
static |
Determines whether to display a message's subject.
e |
true | The subject should be displayed |
Definition at line 133 of file mutt_thread.c.
|
static |
Flatten an email thread.
tctx | Threading context |
Definition at line 182 of file mutt_thread.c.
|
static |
Are tree nodes visible.
tree | Threads tree |
max_depth | Maximum depth to check |
this calculates whether a node is the root of a subtree that has visible nodes, whether a node itself is visible, whether, if invisible, it has depth anyway, and whether any of its later siblings are roots of visible subtrees. while it's at it, it frees the old thread display, so we can skip parts of the tree in mutt_draw_tree() if we've decided here that we don't care about them any more.
Definition at line 235 of file mutt_thread.c.
struct ThreadsContext * mutt_thread_ctx_init | ( | struct MailboxView * | mv | ) |
Initialize a threading context.
mv | Mailbox view |
ptr | Threading context |
Definition at line 356 of file mutt_thread.c.
void mutt_thread_ctx_free | ( | struct ThreadsContext ** | ptr | ) |
Finalize a threading context.
ptr | Threading context to free |
Definition at line 367 of file mutt_thread.c.
void mutt_draw_tree | ( | struct ThreadsContext * | tctx | ) |
Draw a tree of threaded emails.
tctx | Threading context |
Since the graphics characters have a value >255, I have to resort to using escape sequences to pass the information to print_enriched_string(). These are the macros MUTT_TREE_* defined in mutt.h.
ncurses should automatically use the default ASCII characters instead of graphics chars on terminals which don't support them (see the man page for curs_addch).
Definition at line 393 of file mutt_thread.c.
|
static |
Create a sorted list of all subjects in a thread.
[out] | subjects | String List of subjects |
[in] | cur | Email Thread |
[out] | dateptr | Earliest date found in thread |
Since we may be trying to attach as a pseudo-thread a MuttThread that has no message, we have to make a list of all the subjects of its most immediate existing descendants.
Definition at line 523 of file mutt_thread.c.
|
static |
Find the best possible match for a parent based on subject.
ptr | Best match for a parent |
If there are multiple matches, the one which was sent the latest, but before the current message, is used.
Definition at line 579 of file mutt_thread.c.
Create a Hash Table for the email subjects.
m | Mailbox |
ptr | Newly allocated Hash Table |
Definition at line 623 of file mutt_thread.c.
|
static |
Thread messages by subject.
tctx | Threading context |
Thread by subject things that didn't get threaded by message-id
Definition at line 648 of file mutt_thread.c.
void mutt_clear_threads | ( | struct ThreadsContext * | tctx | ) |
Clear the threading of message in a mailbox.
tctx | Threading context |
Definition at line 719 of file mutt_thread.c.
|
static |
Sort the children of a thread.
tctx | Threading context |
init | If true, rebuild the thread |
Definition at line 777 of file mutt_thread.c.
|
static |
Find out which emails' subjects differ from their parent's.
mv | Mailbox View |
init | If true, rebuild the thread |
Definition at line 980 of file mutt_thread.c.
void mutt_sort_threads | ( | struct ThreadsContext * | tctx, |
bool | init | ||
) |
Sort email threads.
tctx | Threading context |
init | If true, rebuild the thread |
Definition at line 1032 of file mutt_thread.c.
int mutt_aside_thread | ( | struct Email * | e, |
bool | forwards, | ||
bool | subthreads | ||
) |
Find the next/previous (sub)thread.
e | Search from this Email |
forwards | Direction to search: 'true' forwards, 'false' backwards |
subthreads | Search subthreads: 'true' subthread, 'false' not |
num | Index into the virtual email table |
-1 | Error |
Definition at line 1288 of file mutt_thread.c.
int mutt_parent_message | ( | struct Email * | e, |
bool | find_root | ||
) |
Find the parent of a message.
e | Current Email |
find_root | If true, find the root message |
>=0 | Virtual index number of parent/root message |
-1 | Error |
Definition at line 1355 of file mutt_thread.c.
off_t mutt_set_vnum | ( | struct Mailbox * | m | ) |
Set the virtual index number of all the messages in a mailbox.
m | Mailbox |
num | Size in bytes of all messages shown |
Definition at line 1405 of file mutt_thread.c.
int mutt_traverse_thread | ( | struct Email * | e_cur, |
MuttThreadFlags | flag | ||
) |
Recurse through an email thread, matching messages.
e_cur | Current Email |
flag | Flag to set, see MuttThreadFlags |
num | Number of matches |
Definition at line 1439 of file mutt_thread.c.
int mutt_messages_in_thread | ( | struct Mailbox * | m, |
struct Email * | e, | ||
enum MessageInThread | mit | ||
) |
Count the messages in a thread.
m | Mailbox |
e | |
mit | Flag, e.g. MIT_NUM_MESSAGES |
num | Number of message / Our position |
Definition at line 1658 of file mutt_thread.c.
Create a Hash Table for message-ids.
m | Mailbox |
ptr | Newly allocated Hash Table |
Definition at line 1703 of file mutt_thread.c.
Forcibly link messages together.
true | On success |
Definition at line 1727 of file mutt_thread.c.
Forcibly link threads together.
true | On success |
Definition at line 1748 of file mutt_thread.c.
void mutt_thread_collapse_collapsed | ( | struct ThreadsContext * | tctx | ) |
Re-collapse threads marked as collapsed.
tctx | Threading context |
Definition at line 1769 of file mutt_thread.c.
void mutt_thread_collapse | ( | struct ThreadsContext * | tctx, |
bool | collapse | ||
) |
Toggle collapse.
tctx | Threading context |
collapse | Collapse / uncollapse |
Definition at line 1790 of file mutt_thread.c.
bool mutt_thread_can_collapse | ( | struct Email * | e | ) |
Check whether a thread can be collapsed.
e | Head of the thread |
true | Can be collapsed |
false | Cannot be collapsed |
Definition at line 1818 of file mutt_thread.c.
|
static |
Choices for '$use_threads' for the index.
Definition at line 52 of file mutt_thread.c.
const struct EnumDef UseThreadsTypeDef |
Data for the $use_threads enumeration.
Definition at line 66 of file mutt_thread.c.