NeoMutt  2025-12-11-769-g906513
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando_index.c File Reference

String processing routines to generate the mail index. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "private.h"
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "gui/lib.h"
#include "expando_index.h"
#include "attach/lib.h"
#include "color/lib.h"
#include "expando/lib.h"
#include "hooks/lib.h"
#include "ncrypt/lib.h"
#include "muttlib.h"
#include "mx.h"
#include "subjectrx.h"
#include "notmuch/lib.h"
+ Include dependency graph for expando_index.c:

Go to the source code of this file.

Enumerations

enum  FieldType {
  DISP_TO , DISP_CC , DISP_BCC , DISP_FROM ,
  DISP_PLAIN , DISP_MAX
}
 Header types. More...
 
enum  IndexDateChoice { SENT_SENDER , SENT_LOCAL , RECV_LOCAL }
 Which email date to display in the Index. More...
 

Functions

static void mailbox_mailbox_name (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Mailbox Name - Implements get_string_t -.
 
static const char * make_from_prefix (enum FieldType disp)
 Create a prefix for an author field.
 
static void make_from (struct Envelope *env, char *buf, size_t buflen, bool do_lists, MuttFormatFlags flags)
 Generate a From: field (with optional prefix)
 
static void make_from_addr (struct Envelope *env, char *buf, size_t buflen, bool do_lists)
 Create a 'from' address for a reply email.
 
static bool user_in_addr (struct AddressList *al)
 Do any of the addresses refer to the user?
 
static enum ToChars user_is_recipient (struct Email *e)
 Is the user a recipient of the message.
 
static bool thread_is_new (struct Email *e)
 Does the email thread contain any new emails?
 
static bool thread_is_old (struct Email *e)
 Does the email thread contain any unread emails?
 
static void index_email_date (const struct ExpandoNode *node, const struct Email *e, enum IndexDateChoice which, MuttFormatFlags flags, struct Buffer *buf, const char *format)
 Index: Sent/Received Local/Sender date and time.
 
static long email_attachment_count (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of MIME attachments - Implements get_number_t -.
 
static void email_body_characters (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Number of raw bytes - Implements get_string_t -.
 
static void email_combined_flags (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Status flags - Implements get_string_t -.
 
static void email_crypto_flags (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message crypto flags - Implements get_string_t -.
 
static void email_date_format (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent date and time - Implements get_string_t -.
 
static void email_date_format_local (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent local date and time - Implements get_string_t -.
 
static long email_date_format_local_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Local Date and time - Implements get_number_t -.
 
static long email_date_format_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Senders Date and time - Implements get_number_t -.
 
static void email_date_strf (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent date and time - Implements get_string_t -.
 
static long email_date_strf_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Sender's date and time - Implements get_number_t -.
 
static void email_date_strf_local (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent local date and time - Implements get_string_t -.
 
static long email_date_strf_local_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Local date and time - Implements get_number_t -.
 
static void email_flag_chars (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Status flag - Implements get_string_t -.
 
static void email_from_list (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: List address - Implements get_string_t -.
 
static void email_index_hook (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: index-format-hook - Implements get_string_t -.
 
static long email_lines (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of lines - Implements get_number_t -.
 
static void email_list_or_save_folder (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: List Name or Save folder - Implements get_string_t -.
 
static void email_message_flags (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message tag flags - Implements get_string_t -.
 
static long email_number (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Index number - Implements get_number_t -.
 
static long email_score (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Message score - Implements get_number_t -.
 
static void email_size (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Number of bytes - Implements get_string_t -.
 
static long email_size_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of bytes - Implements get_number_t -.
 
static void email_status_flags (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message status flags - Implements get_string_t -.
 
static void email_strf_recv_local (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Received local date and time - Implements get_string_t -.
 
static long email_strf_recv_local_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Local received date and time - Implements get_number_t -.
 
static void email_tags (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message tags - Implements get_string_t -.
 
static void email_tags_transformed (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Individual tag - Implements get_string_t -.
 
static long email_thread_count (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of messages thread - Implements get_number_t -.
 
static void email_thread_hidden_count (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Number of hidden messages - Implements get_string_t -.
 
static long email_thread_hidden_count_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of hidden messages - Implements get_number_t -.
 
static long email_thread_number (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Thread index number - Implements get_number_t -.
 
static void email_thread_tags (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Tags - Implements get_string_t -.
 
static void email_to_chars (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: $to_chars flag - Implements get_string_t -.
 
static void envelope_cc_all (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Cc recipients - Implements get_string_t -.
 
static void envelope_first_name (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: First name - Implements get_string_t -.
 
static void envelope_from (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Author Address - Implements get_string_t -.
 
static void envelope_from_full (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sender - Implements get_string_t -.
 
static void envelope_initials (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Initials of author - Implements get_string_t -.
 
static void envelope_list_address (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Mailing List - Implements get_string_t -.
 
static void envelope_list_empty (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Mailing list - Implements get_string_t -.
 
static void envelope_message_id (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message-ID - Implements get_string_t -.
 
static void envelope_name (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Author's real name - Implements get_string_t -.
 
static void envelope_newsgroup (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Newsgroup name - Implements get_string_t -.
 
static void envelope_organization (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Organization - Implements get_string_t -.
 
static void envelope_reply_to (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Reply-to address - Implements get_string_t -.
 
static void envelope_sender (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Author name - Implements get_string_t -.
 
static void envelope_sender_plain (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Plain author name - Implements get_string_t -.
 
static void envelope_spam (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Spam attributes - Implements get_string_t -.
 
static void envelope_subject (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Subject - Implements get_string_t -.
 
static void envelope_thread_tree (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Thread tree - Implements get_string_t -.
 
static void envelope_thread_x_label (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: X-Label (if different) - Implements get_string_t -.
 
static void envelope_to (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: To field - Implements get_string_t -.
 
static void envelope_to_all (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: To recipients - Implements get_string_t -.
 
static void envelope_username (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: User name - Implements get_string_t -.
 
static void envelope_x_comment_to (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: X-Comment-To - Implements get_string_t -.
 
static void envelope_x_label (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: X-Label - Implements get_string_t -.
 
static long mailbox_message_count (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Total number of message - Implements get_number_t -.
 
static void mailbox_percentage (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Progress indicator - Implements get_string_t -.
 

Variables

const struct ExpandoRenderCallback IndexRenderCallbacks []
 Callbacks for Index Expandos.
 

Detailed Description

String processing routines to generate the mail index.

Authors
  • Michael R. Elkins
  • Ian Zimmerman
  • Richard Russon
  • Stefan Assmann
  • Victor Fernandes
  • Pietro Cerutti
  • Ashish Panigrahi
  • Tóth János
  • наб
  • Dennis Schön

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 expando_index.c.

Enumeration Type Documentation

◆ FieldType

enum FieldType

Header types.

Strings for printing headers

Enumerator
DISP_TO 

To: string.

DISP_CC 

Cc: string.

DISP_BCC 

Bcc: string.

DISP_FROM 

From: string.

DISP_PLAIN 

Empty string.

DISP_MAX 

Definition at line 72 of file expando_index.c.

73{
74 DISP_TO,
75 DISP_CC,
76 DISP_BCC,
77 DISP_FROM,
80};
@ DISP_PLAIN
Empty string.
@ DISP_TO
To: string.
@ DISP_CC
Cc: string.
@ DISP_BCC
Bcc: string.
@ DISP_MAX
@ DISP_FROM
From: string.

◆ IndexDateChoice

Which email date to display in the Index.

Enumerator
SENT_SENDER 

Date sent in the sender's timezone.

SENT_LOCAL 

Date sent in the local timezone.

RECV_LOCAL 

Date received in the local timezone.

Definition at line 85 of file expando_index.c.

86{
90};
@ SENT_LOCAL
Date sent in the local timezone.
@ RECV_LOCAL
Date received in the local timezone.
@ SENT_SENDER
Date sent in the sender's timezone.

Function Documentation

◆ make_from_prefix()

static const char * make_from_prefix ( enum FieldType disp)
static

Create a prefix for an author field.

Parameters
dispType of field
Return values
ptrPrefix string (do not free it)

If $from_chars is set, pick an appropriate character from it. If not, use the default prefix: "To", "Cc", etc

Definition at line 100 of file expando_index.c.

101{
102 /* need 2 bytes at the end, one for the space, another for NUL */
103 static char padded[8];
104 static const char *long_prefixes[DISP_MAX] = {
105 [DISP_TO] = "To ", [DISP_CC] = "Cc ", [DISP_BCC] = "Bcc ",
106 [DISP_FROM] = "", [DISP_PLAIN] = "",
107 };
108
109 const struct MbTable *c_from_chars = cs_subset_mbtable(NeoMutt->sub, "from_chars");
110
111 if (!c_from_chars || !c_from_chars->chars || (c_from_chars->len == 0))
112 return long_prefixes[disp];
113
114 const char *pchar = mbtable_get_nth_wchar(c_from_chars, disp);
115 if (mutt_str_len(pchar) == 0)
116 return "";
117
118 snprintf(padded, sizeof(padded), "%s ", pchar);
119 return padded;
120}
struct MbTable * cs_subset_mbtable(const struct ConfigSubset *sub, const char *name)
Get a Multibyte table config item by name.
Definition helpers.c:119
const char * mbtable_get_nth_wchar(const struct MbTable *table, int index)
Extract one char from a multi-byte table.
Definition mbtable.c:340
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:503
Multibyte character table.
Definition mbtable.h:36
int len
Number of characters.
Definition mbtable.h:38
char ** chars
The array of multibyte character strings.
Definition mbtable.h:39
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_from()

static void make_from ( struct Envelope * env,
char * buf,
size_t buflen,
bool do_lists,
MuttFormatFlags flags )
static

Generate a From: field (with optional prefix)

Parameters
envEnvelope of the email
bufBuffer to store the result
buflenSize of the buffer
do_listsShould we check for mailing lists?
flagsFormat flags, see MuttFormatFlags

Generate the F or L field in $index_format. This is the author, or recipient of the email.

The field can optionally be prefixed by a character from $from_chars. If $from_chars is not set, the prefix will be, "To", "Cc", etc

Definition at line 136 of file expando_index.c.

138{
139 if (!env || !buf)
140 return;
141
142 bool me;
143 enum FieldType disp;
144 struct AddressList *name = NULL;
145
147
148 if (do_lists || me)
149 {
150 if (check_for_mailing_list(&env->to, make_from_prefix(DISP_TO), buf, buflen))
151 return;
152 if (check_for_mailing_list(&env->cc, make_from_prefix(DISP_CC), buf, buflen))
153 return;
154 }
155
156 if (me && !TAILQ_EMPTY(&env->to))
157 {
158 disp = (flags & MUTT_FORMAT_PLAIN) ? DISP_PLAIN : DISP_TO;
159 name = &env->to;
160 }
161 else if (me && !TAILQ_EMPTY(&env->cc))
162 {
163 disp = DISP_CC;
164 name = &env->cc;
165 }
166 else if (me && !TAILQ_EMPTY(&env->bcc))
167 {
168 disp = DISP_BCC;
169 name = &env->bcc;
170 }
171 else if (!TAILQ_EMPTY(&env->from))
172 {
173 disp = DISP_FROM;
174 name = &env->from;
175 }
176 else
177 {
178 *buf = '\0';
179 return;
180 }
181
182 snprintf(buf, buflen, "%s%s", make_from_prefix(disp), mutt_get_name(TAILQ_FIRST(name)));
183}
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition alias.c:600
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition sort.c:138
static const char * make_from_prefix(enum FieldType disp)
Create a prefix for an author field.
FieldType
Header types.
bool check_for_mailing_list(struct AddressList *al, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Definition maillist.c:86
#define TAILQ_FIRST(head)
Definition queue.h:780
#define TAILQ_EMPTY(head)
Definition queue.h:778
#define MUTT_FORMAT_PLAIN
Do not prepend DISP_TO, DISP_CC ...
Definition render.h:39
struct AddressList to
Email's 'To' list.
Definition envelope.h:60
struct AddressList cc
Email's 'Cc' list.
Definition envelope.h:61
struct AddressList bcc
Email's 'Bcc' list.
Definition envelope.h:62
struct AddressList from
Email's 'From' list.
Definition envelope.h:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_from_addr()

static void make_from_addr ( struct Envelope * env,
char * buf,
size_t buflen,
bool do_lists )
static

Create a 'from' address for a reply email.

Parameters
envEnvelope of current email
bufBuffer for the result
buflenLength of buffer
do_listsIf true, check for mailing lists

Definition at line 192 of file expando_index.c.

193{
194 if (!env || !buf)
195 return;
196
197 bool me = mutt_addr_is_user(TAILQ_FIRST(&env->from));
198
199 if (do_lists || me)
200 {
201 if (check_for_mailing_list_addr(&env->to, buf, buflen))
202 return;
203 if (check_for_mailing_list_addr(&env->cc, buf, buflen))
204 return;
205 }
206
207 if (me && !TAILQ_EMPTY(&env->to))
208 snprintf(buf, buflen, "%s", buf_string(TAILQ_FIRST(&env->to)->mailbox));
209 else if (me && !TAILQ_EMPTY(&env->cc))
210 snprintf(buf, buflen, "%s", buf_string(TAILQ_FIRST(&env->cc)->mailbox));
211 else if (!TAILQ_EMPTY(&env->from))
212 mutt_str_copy(buf, buf_string(TAILQ_FIRST(&env->from)->mailbox), buflen);
213 else
214 *buf = '\0';
215}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
bool check_for_mailing_list_addr(struct AddressList *al, char *buf, int buflen)
Check an address list for a mailing list.
Definition maillist.c:110
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition string.c:586
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ user_in_addr()

static bool user_in_addr ( struct AddressList * al)
static

Do any of the addresses refer to the user?

Parameters
alAddressList
Return values
trueAny of the addresses match one of the user's addresses

Definition at line 222 of file expando_index.c.

223{
224 struct Address *a = NULL;
225 TAILQ_FOREACH(a, al, entries)
226 if (mutt_addr_is_user(a))
227 return true;
228 return false;
229}
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
An email address.
Definition address.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ user_is_recipient()

static enum ToChars user_is_recipient ( struct Email * e)
static

Is the user a recipient of the message.

Parameters
eEmail to test
Return values
enumCharacter index into the $to_chars config variable

Definition at line 236 of file expando_index.c.

237{
238 if (!e || !e->env)
240
241 struct Envelope *env = e->env;
242
243 if (!e->recip_valid)
244 {
245 e->recip_valid = true;
246
248 {
250 }
251 else if (user_in_addr(&env->to))
252 {
253 if (TAILQ_NEXT(TAILQ_FIRST(&env->to), entries) || !TAILQ_EMPTY(&env->cc))
254 e->recipient = FLAG_CHAR_TO_TO; /* non-unique recipient */
255 else
256 e->recipient = FLAG_CHAR_TO_UNIQUE; /* unique recipient */
257 }
258 else if (user_in_addr(&env->cc))
259 {
261 }
262 else if (check_for_mailing_list(&env->to, NULL, NULL, 0))
263 {
265 }
266 else if (check_for_mailing_list(&env->cc, NULL, NULL, 0))
267 {
269 }
270 else if (user_in_addr(&env->reply_to))
271 {
273 }
274 else
275 {
277 }
278 }
279
280 return e->recipient;
281}
static bool user_in_addr(struct AddressList *al)
Do any of the addresses refer to the user?
@ FLAG_CHAR_TO_ORIGINATOR
Character denoting that the user is originator.
@ FLAG_CHAR_TO_UNIQUE
Character denoting that the user is unique recipient.
@ FLAG_CHAR_TO_NOT_IN_THE_LIST
Character denoting that the user is not in list.
@ FLAG_CHAR_TO_TO
Character denoting that the user is in the TO list.
@ FLAG_CHAR_TO_CC
Character denoting that the user is in the CC list.
@ FLAG_CHAR_TO_REPLY_TO
Character denoting that the user is in the Reply-To list.
@ FLAG_CHAR_TO_SUBSCRIBED_LIST
Character denoting that the message is sent to a subscribed mailing list.
#define TAILQ_NEXT(elm, field)
Definition queue.h:889
bool recip_valid
Is_recipient is valid.
Definition email.h:104
struct Envelope * env
Envelope information.
Definition email.h:68
short recipient
User_is_recipient()'s return value, cached.
Definition email.h:116
The header of an Email.
Definition envelope.h:57
struct AddressList reply_to
Email's 'reply-to'.
Definition envelope.h:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ thread_is_new()

static bool thread_is_new ( struct Email * e)
static

Does the email thread contain any new emails?

Parameters
eEmail
Return values
trueThread contains new mail

Definition at line 288 of file expando_index.c.

289{
290 return e->collapsed && (e->num_hidden > 1) && (mutt_thread_contains_unread(e) == 1);
291}
#define mutt_thread_contains_unread(e)
Definition thread.h:108
bool collapsed
Is this message part of a collapsed thread?
Definition email.h:120
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition email.h:123
+ Here is the caller graph for this function:

◆ thread_is_old()

static bool thread_is_old ( struct Email * e)
static

Does the email thread contain any unread emails?

Parameters
eEmail
Return values
trueThread contains unread mail

Definition at line 298 of file expando_index.c.

299{
300 return e->collapsed && (e->num_hidden > 1) && (mutt_thread_contains_unread(e) == 2);
301}
+ Here is the caller graph for this function:

◆ index_email_date()

static void index_email_date ( const struct ExpandoNode * node,
const struct Email * e,
enum IndexDateChoice which,
MuttFormatFlags flags,
struct Buffer * buf,
const char * format )
static

Index: Sent/Received Local/Sender date and time.

Parameters
nodeExpandoNode containing the callback
eEmail
whichWhich date to use
flagsFlags, see MuttFormatFlags
bufBuffer for the result
formatFormat string

Definition at line 312 of file expando_index.c.

315{
316 char *fmt = mutt_str_dup(format);
317 if (!fmt)
318 return;
319
320 struct tm tm = { 0 };
321 switch (which)
322 {
323 case SENT_SENDER:
324 {
325#ifdef HAVE_STRUCT_TM_TM_GMTOFF
326 int offset = (e->zhours * 3600 + e->zminutes * 60) * (e->zoccident ? -1 : 1);
327 const time_t now = e->date_sent + offset;
328 tm = mutt_date_gmtime(now);
329 tm.tm_gmtoff = offset;
330 break;
331#else
333#endif
334 }
335 case SENT_LOCAL:
336 {
338 break;
339 }
340 case RECV_LOCAL:
341 {
343 break;
344 }
345 }
346
347 const bool use_c_locale = (*fmt == '!');
348
349 if (which != RECV_LOCAL)
350 {
351 // The sender's time zone might only be available as a numerical offset, so "%Z" behaves like "%z".
352 for (char *bigz = fmt; (bigz = strstr(bigz, "%Z")); bigz += 2)
353 {
354 bigz[1] = 'z';
355 }
356 }
357
358 char out[128] = { 0 };
359 if (use_c_locale)
360 {
361 strftime_l(out, sizeof(out), fmt + 1, &tm, NeoMutt->time_c_locale);
362 }
363 else
364 {
365 strftime(out, sizeof(out), fmt, &tm);
366 }
367
368 FREE(&fmt);
369
370 if (flags & MUTT_FORMAT_INDEX)
372 buf_strcpy(buf, out);
373}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
@ MT_COLOR_INDEX_DATE
Index: date field.
Definition color.h:89
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition date.c:907
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
Definition date.c:928
#define FALLTHROUGH
Definition lib.h:117
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
void node_expando_set_color(const struct ExpandoNode *node, int cid)
Set the colour for an Expando.
#define MUTT_FORMAT_INDEX
This is a main index entry.
Definition render.h:38
unsigned int zminutes
Minutes away from UTC.
Definition email.h:57
bool zoccident
True, if west of UTC, False if east.
Definition email.h:58
unsigned int zhours
Hours away from UTC.
Definition email.h:56
time_t date_sent
Time when the message was sent (UTC)
Definition email.h:60
time_t received
Time when the message was placed in the mailbox.
Definition email.h:61
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition neomutt.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ IndexRenderCallbacks

const struct ExpandoRenderCallback IndexRenderCallbacks[]

Callbacks for Index Expandos.

See also
IndexFormatDef, ExpandoDataEmail, ExpandoDataEnvelope, ExpandoDataGlobal, ExpandoDataMailbox

Definition at line 1689 of file expando_index.c.

1689 {
1690 // clang-format off
1702 { ED_EMAIL, ED_EMA_LINES, NULL, email_lines },
1706 { ED_EMAIL, ED_EMA_SCORE, NULL, email_score },
1710 { ED_EMAIL, ED_EMA_TAGS, email_tags, NULL },
1735 { ED_ENVELOPE, ED_ENV_TO, envelope_to, NULL },
1743 { -1, -1, NULL, NULL },
1744 // clang-format on
1745};
@ ED_MBX_MESSAGE_COUNT
Mailbox.msg_count.
Definition mailbox.h:158
@ ED_MBX_PERCENTAGE
EmailFormatInfo.pager_progress.
Definition mailbox.h:159
@ ED_MBX_MAILBOX_NAME
Mailbox, mailbox_path()
Definition mailbox.h:157
@ ED_ENVELOPE
Envelope ED_ENV_ ExpandoDataEnvelope.
Definition domain.h:42
@ ED_EMAIL
Email ED_EMA_ ExpandoDataEmail.
Definition domain.h:41
@ ED_MAILBOX
Mailbox ED_MBX_ ExpandoDataMailbox.
Definition domain.h:47
@ ED_EMA_DATE_STRF_LOCAL
Email.date_sent.
Definition email.h:143
@ ED_EMA_ATTACHMENT_COUNT
Email, mutt_count_body_parts()
Definition email.h:136
@ ED_EMA_DATE_FORMAT_LOCAL
Email.date_sent.
Definition email.h:141
@ ED_EMA_TAGS_TRANSFORMED
Email.tags, driver_tags_get_transformed()
Definition email.h:156
@ ED_EMA_THREAD_HIDDEN_COUNT
Email.collapsed, Email.num_hidden, ...
Definition email.h:158
@ ED_EMA_DATE_FORMAT
Email.date_sent.
Definition email.h:140
@ ED_EMA_THREAD_TAGS
Email.tags.
Definition email.h:160
@ ED_EMA_TAGS
Email.tags.
Definition email.h:155
@ ED_EMA_SIZE
Body.length.
Definition email.h:152
@ ED_EMA_FLAG_CHARS
Email.deleted, Email.attach_del, ...
Definition email.h:144
@ ED_EMA_THREAD_NUMBER
Email, mutt_messages_in_thread()
Definition email.h:159
@ ED_EMA_TO_CHARS
Email, User_is_recipient()
Definition email.h:161
@ ED_EMA_BODY_CHARACTERS
Body.length.
Definition email.h:137
@ ED_EMA_COMBINED_FLAGS
Email.read, Email.old, thread_is_new(), ...
Definition email.h:138
@ ED_EMA_THREAD_COUNT
Email, mutt_messages_in_thread()
Definition email.h:157
@ ED_EMA_STATUS_FLAGS
Email.deleted, Email.attach_del, ...
Definition email.h:153
@ ED_EMA_NUMBER
Email.msgno.
Definition email.h:150
@ ED_EMA_DATE_STRF
Email.date_sent, Email.zhours, Email.zminutes, Email.zoccident.
Definition email.h:142
@ ED_EMA_FROM_LIST
Envelope.to, Envelope.cc.
Definition email.h:145
@ ED_EMA_SCORE
Email.score.
Definition email.h:151
@ ED_EMA_CRYPTO_FLAGS
Email.security, SecurityFlags.
Definition email.h:139
@ ED_EMA_STRF_RECV_LOCAL
Email.received.
Definition email.h:154
@ ED_EMA_LIST_OR_SAVE_FOLDER
Envelope.to, Envelope.cc, check_for_mailing_list()
Definition email.h:148
@ ED_EMA_INDEX_HOOK
Mailbox, Email, mutt_idxfmt_hook()
Definition email.h:146
@ ED_EMA_LINES
Email.lines.
Definition email.h:147
@ ED_EMA_MESSAGE_FLAGS
Email.tagged, Email.flagged.
Definition email.h:149
@ ED_ENV_SUBJECT
Envelope.subject, Envelope.disp_subj.
Definition envelope.h:116
@ ED_ENV_NEWSGROUP
Envelope.newsgroups.
Definition envelope.h:109
@ ED_ENV_INITIALS
Envelope.from (first)
Definition envelope.h:104
@ ED_ENV_FROM_FULL
Envelope.from (all)
Definition envelope.h:103
@ ED_ENV_X_COMMENT_TO
Envelope.x_comment_to.
Definition envelope.h:123
@ ED_ENV_FROM
Envelope.from (first)
Definition envelope.h:102
@ ED_ENV_LIST_ADDRESS
Envelope.to, Envelope.cc.
Definition envelope.h:105
@ ED_ENV_SPAM
Envelope.spam.
Definition envelope.h:115
@ ED_ENV_SENDER
Envelope, make_from()
Definition envelope.h:113
@ ED_ENV_TO_ALL
Envelope.to (all)
Definition envelope.h:120
@ ED_ENV_X_LABEL
Envelope.x_label.
Definition envelope.h:124
@ ED_ENV_NAME
Envelope.from (first)
Definition envelope.h:108
@ ED_ENV_CC_ALL
Envelope.cc.
Definition envelope.h:100
@ ED_ENV_ORGANIZATION
Envelope.organization.
Definition envelope.h:110
@ ED_ENV_REPLY_TO
Envelope.reply_to.
Definition envelope.h:112
@ ED_ENV_LIST_EMPTY
Envelope.to, Envelope.cc.
Definition envelope.h:106
@ ED_ENV_THREAD_X_LABEL
Envelope.x_label.
Definition envelope.h:118
@ ED_ENV_MESSAGE_ID
Envelope.message_id.
Definition envelope.h:107
@ ED_ENV_SENDER_PLAIN
Envelope, make_from()
Definition envelope.h:114
@ ED_ENV_USERNAME
Envelope.from.
Definition envelope.h:121
@ ED_ENV_THREAD_TREE
Email.tree.
Definition envelope.h:117
@ ED_ENV_TO
Envelope.to, Envelope.cc (first)
Definition envelope.h:119
@ ED_ENV_FIRST_NAME
Envelope.from, Envelope.to, Envelope.cc.
Definition envelope.h:101
static long email_date_strf_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Sender's date and time - Implements get_number_t -.
static long email_lines(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Number of lines - Implements get_number_t -.
static long mailbox_message_count(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Total number of message - Implements get_number_t -.
static long email_attachment_count(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Number of MIME attachments - Implements get_number_t -.
static long email_size_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Number of bytes - Implements get_number_t -.
static long email_date_strf_local_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Local date and time - Implements get_number_t -.
static long email_strf_recv_local_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Local received date and time - Implements get_number_t -.
static long email_number(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Index number - Implements get_number_t -.
static long email_thread_hidden_count_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Number of hidden messages - Implements get_number_t -.
static long email_date_format_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Senders Date and time - Implements get_number_t -.
static long email_score(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Message score - Implements get_number_t -.
static long email_date_format_local_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Local Date and time - Implements get_number_t -.
static long email_thread_count(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Number of messages thread - Implements get_number_t -.
static long email_thread_number(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Index: Thread index number - Implements get_number_t -.
static void email_tags_transformed(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Individual tag - Implements get_string_t -.
static void email_crypto_flags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Message crypto flags - Implements get_string_t -.
static void envelope_to(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: To field - Implements get_string_t -.
static void email_date_format(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Sent date and time - Implements get_string_t -.
static void email_flag_chars(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Status flag - Implements get_string_t -.
static void envelope_x_comment_to(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: X-Comment-To - Implements get_string_t -.
static void envelope_reply_to(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Reply-to address - Implements get_string_t -.
static void email_thread_tags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Tags - Implements get_string_t -.
static void envelope_sender(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Author name - Implements get_string_t -.
static void envelope_x_label(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: X-Label - Implements get_string_t -.
static void envelope_message_id(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Message-ID - Implements get_string_t -.
static void envelope_from(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Author Address - Implements get_string_t -.
static void envelope_to_all(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: To recipients - Implements get_string_t -.
static void email_message_flags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Message tag flags - Implements get_string_t -.
static void mailbox_mailbox_name(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Mailbox Name - Implements get_string_t -.
static void email_date_strf_local(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Sent local date and time - Implements get_string_t -.
static void envelope_sender_plain(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Plain author name - Implements get_string_t -.
static void envelope_first_name(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: First name - Implements get_string_t -.
static void email_tags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Message tags - Implements get_string_t -.
static void mailbox_percentage(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Progress indicator - Implements get_string_t -.
static void envelope_name(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Author's real name - Implements get_string_t -.
static void envelope_thread_tree(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Thread tree - Implements get_string_t -.
static void envelope_list_address(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Mailing List - Implements get_string_t -.
static void envelope_initials(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Initials of author - Implements get_string_t -.
static void email_from_list(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: List address - Implements get_string_t -.
static void envelope_thread_x_label(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: X-Label (if different) - Implements get_string_t -.
static void envelope_newsgroup(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Newsgroup name - Implements get_string_t -.
static void email_thread_hidden_count(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Number of hidden messages - Implements get_string_t -.
static void email_date_strf(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Sent date and time - Implements get_string_t -.
static void email_date_format_local(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Sent local date and time - Implements get_string_t -.
static void envelope_from_full(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Sender - Implements get_string_t -.
static void email_strf_recv_local(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Received local date and time - Implements get_string_t -.
static void envelope_spam(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Spam attributes - Implements get_string_t -.
static void email_index_hook(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: index-format-hook - Implements get_string_t -.
static void email_combined_flags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Status flags - Implements get_string_t -.
static void email_size(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Number of bytes - Implements get_string_t -.
static void email_body_characters(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Number of raw bytes - Implements get_string_t -.
static void envelope_username(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: User name - Implements get_string_t -.
static void envelope_list_empty(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Mailing list - Implements get_string_t -.
static void email_status_flags(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Message status flags - Implements get_string_t -.
static void envelope_subject(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Subject - Implements get_string_t -.
static void email_to_chars(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: $to_chars flag - Implements get_string_t -.
static void email_list_or_save_folder(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: List Name or Save folder - Implements get_string_t -.
static void envelope_organization(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Organization - Implements get_string_t -.
static void envelope_cc_all(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Index: Cc recipients - Implements get_string_t -.