Create/manipulate threading in emails. More...
#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt_thread.h"
#include "mx.h"
#include "protos.h"
#include "sort.h"
Go to the source code of this file.
Data Structures | |
struct | ThreadsContext |
The "current" threading state. More... | |
Functions | |
static bool | is_visible (struct Email *e) |
Is the message visible? More... | |
static bool | need_display_subject (struct Email *e) |
Determines whether to display a message's subject. More... | |
static void | linearize_tree (struct ThreadsContext *tctx) |
Flatten an email thread. More... | |
static void | calculate_visibility (struct MuttThread *tree, int *max_depth) |
Are tree nodes visible. More... | |
struct ThreadsContext * | mutt_thread_ctx_init (struct Mailbox *m) |
Initialize a threading context. More... | |
void | mutt_thread_ctx_free (struct ThreadsContext **tctx) |
Finalize a threading context. More... | |
void | mutt_draw_tree (struct ThreadsContext *tctx) |
Draw a tree of threaded emails. More... | |
static void | make_subject_list (struct ListHead *subjects, struct MuttThread *cur, time_t *dateptr) |
Create a sorted list of all subjects in a thread. More... | |
static struct MuttThread * | find_subject (struct Mailbox *m, struct MuttThread *cur) |
Find the best possible match for a parent based on subject. More... | |
static struct HashTable * | make_subj_hash (struct Mailbox *m) |
Create a Hash Table for the email subjects. More... | |
static void | pseudo_threads (struct ThreadsContext *tctx) |
Thread messages by subject. More... | |
void | mutt_clear_threads (struct ThreadsContext *tctx) |
Clear the threading of message in a mailbox. More... | |
static int | compare_threads (const void *a, const void *b) |
Sorting function for email threads. More... | |
void | mutt_sort_subthreads (struct ThreadsContext *tctx, bool init) |
Sort the children of a thread. More... | |
static void | check_subjects (struct Mailbox *m, bool init) |
Find out which emails' subjects differ from their parent's. More... | |
void | mutt_sort_threads (struct ThreadsContext *tctx, bool init) |
Sort email threads. More... | |
int | mutt_aside_thread (struct Email *e, bool forwards, bool subthreads) |
Find the next/previous (sub)thread. More... | |
int | mutt_parent_message (struct Email *e, bool find_root) |
Find the parent of a message. More... | |
off_t | mutt_set_vnum (struct Mailbox *m) |
Set the virtual index number of all the messages in a mailbox. More... | |
int | mutt_traverse_thread (struct Email *e_cur, MuttThreadFlags flag) |
Recurse through an email thread, matching messages. More... | |
int | mutt_messages_in_thread (struct Mailbox *m, struct Email *e, int flag) |
Count the messages in a thread. More... | |
struct HashTable * | mutt_make_id_hash (struct Mailbox *m) |
Create a Hash Table for message-ids. More... | |
static bool | link_threads (struct Email *parent, struct Email *child, struct Mailbox *m) |
Forcibly link messages together. More... | |
bool | mutt_link_threads (struct Email *parent, struct EmailList *children, struct Mailbox *m) |
Forcibly link threads together. More... | |
void | mutt_thread_collapse_collapsed (struct ThreadsContext *tctx) |
re-collapse threads marked as collapsed More... | |
void | mutt_thread_collapse (struct ThreadsContext *tctx, bool collapse) |
toggle collapse More... | |
bool | mutt_thread_can_collapse (struct Email *e) |
Check whether a thread can be collapsed. More... | |
Variables | |
bool | C_CollapseFlagged |
Config: Prevent the collapse of threads with flagged emails. More... | |
bool | C_CollapseUnread |
Config: Prevent the collapse of threads with unread emails. More... | |
bool | C_DuplicateThreads |
Config: Highlight messages with duplicated message IDs. More... | |
bool | C_HideLimited |
Config: Don't indicate hidden messages, in the thread tree. More... | |
bool | C_HideMissing |
Config: Don't indicate missing messages, in the thread tree. More... | |
bool | C_HideThreadSubject |
Config: Hide subjects that are similar to that of the parent message. More... | |
bool | C_HideTopLimited |
Config: Don't indicate hidden top message, in the thread tree. More... | |
bool | C_HideTopMissing |
Config: Don't indicate missing top message, in the thread tree. More... | |
bool | C_NarrowTree |
Config: Draw a narrower thread tree in the index. More... | |
bool | C_SortRe |
Config: Sort method for the sidebar. More... | |
bool | C_StrictThreads |
Config: Thread messages using 'In-Reply-To' and 'References' headers. More... | |
bool | C_ThreadReceived |
Config: Sort threaded messages by their received date. More... | |
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.
|
static |
Is the message visible?
e |
true | If the message is not hidden in some way |
Definition at line 73 of file mutt_thread.c.
|
static |
Determines whether to display a message's subject.
e |
true | If the subject should be displayed |
Definition at line 83 of file mutt_thread.c.
|
static |
Flatten an email thread.
tctx | Threading context |
Definition at line 131 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 179 of file mutt_thread.c.
struct ThreadsContext* mutt_thread_ctx_init | ( | struct Mailbox * | m | ) |
Initialize a threading context.
m | Current mailbox |
tctx | Threading context |
Definition at line 288 of file mutt_thread.c.
void mutt_thread_ctx_free | ( | struct ThreadsContext ** | tctx | ) |
Finalize a threading context.
tctx | Threading context to finalize |
Definition at line 301 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 320 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 444 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 498 of file mutt_thread.c.
Create a Hash Table for the email subjects.
m | Mailbox |
ptr | Newly allocated Hash Table |
Definition at line 541 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 566 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 637 of file mutt_thread.c.
|
static |
Sorting function for email threads.
a | First thread to compare |
b | Second thread to compare |
-1 | a precedes b |
0 | a and b are identical |
1 | b precedes a |
Definition at line 664 of file mutt_thread.c.
void mutt_sort_subthreads | ( | struct ThreadsContext * | tctx, |
bool | init | ||
) |
Sort the children of a thread.
tctx | Threading context |
init | If true, rebuild the thread |
Definition at line 687 of file mutt_thread.c.
|
static |
Find out which emails' subjects differ from their parent's.
m | Mailbox |
init | If true, rebuild the thread |
Definition at line 829 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 870 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 |
Definition at line 1119 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 1182 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 |
mum | Size in bytes of all messages shown |
Definition at line 1232 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 1266 of file mutt_thread.c.
Count the messages in a thread.
num | Number of message / Our position |
If flag is 0, we want to know how many messages are in the thread. If flag is 1, we want to know our position in the thread.
Definition at line 1479 of file mutt_thread.c.
Create a Hash Table for message-ids.
m | Mailbox |
ptr | Newly allocated Hash Table |
Definition at line 1521 of file mutt_thread.c.
Forcibly link messages together.
true | On success |
Definition at line 1545 of file mutt_thread.c.
Forcibly link threads together.
true | On success |
Definition at line 1566 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 1586 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 1607 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 1635 of file mutt_thread.c.
bool C_CollapseFlagged |
Config: Prevent the collapse of threads with flagged emails.
Definition at line 45 of file mutt_thread.c.
bool C_CollapseUnread |
Config: Prevent the collapse of threads with unread emails.
Definition at line 46 of file mutt_thread.c.
bool C_DuplicateThreads |
Config: Highlight messages with duplicated message IDs.
Definition at line 47 of file mutt_thread.c.
bool C_HideLimited |
Config: Don't indicate hidden messages, in the thread tree.
Definition at line 48 of file mutt_thread.c.
bool C_HideMissing |
Config: Don't indicate missing messages, in the thread tree.
Definition at line 49 of file mutt_thread.c.
bool C_HideThreadSubject |
Config: Hide subjects that are similar to that of the parent message.
Definition at line 50 of file mutt_thread.c.
bool C_HideTopLimited |
Config: Don't indicate hidden top message, in the thread tree.
Definition at line 51 of file mutt_thread.c.
bool C_HideTopMissing |
Config: Don't indicate missing top message, in the thread tree.
Definition at line 52 of file mutt_thread.c.
bool C_NarrowTree |
Config: Draw a narrower thread tree in the index.
Definition at line 53 of file mutt_thread.c.
bool C_SortRe |
Config: Sort method for the sidebar.
Definition at line 54 of file mutt_thread.c.
bool C_StrictThreads |
Config: Thread messages using 'In-Reply-To' and 'References' headers.
Definition at line 55 of file mutt_thread.c.
bool C_ThreadReceived |
Config: Sort threaded messages by their received date.
Definition at line 56 of file mutt_thread.c.