NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
subjectrx.c File Reference

Subject Regex handling. More...

#include "config.h"
#include <stddef.h>
#include <stdint.h>
#include "mutt/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "subjectrx.h"
#include "parse/lib.h"
#include "mview.h"
+ Include dependency graph for subjectrx.c:

Go to the source code of this file.

Functions

void subjrx_cleanup (void)
 Free the Subject Regex List.
 
void subjrx_init (void)
 Create new Subject Regex List.
 
static enum CommandResult parse_unreplace_list (struct Buffer *buf, struct Buffer *s, struct ReplaceList *list, struct Buffer *err)
 Remove a string replacement rule - Implements Command::parse() -.
 
static enum CommandResult parse_replace_list (struct Buffer *buf, struct Buffer *s, struct ReplaceList *list, struct Buffer *err)
 Parse a string replacement rule - Implements Command::parse() -.
 
bool subjrx_apply_mods (struct Envelope *env)
 Apply regex modifications to the subject.
 
void subjrx_clear_mods (struct MailboxView *mv)
 Clear out all modified email subjects.
 
enum CommandResult parse_subjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subjectrx' command - Implements Command::parse() -.
 
enum CommandResult parse_unsubjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubjectrx' command - Implements Command::parse() -.
 

Variables

static struct ReplaceList SubjectRegexList = STAILQ_HEAD_INITIALIZER(SubjectRegexList)
 List of subjectrx rules for modifying the Subject:
 
static struct NotifySubjRxNotify = NULL
 Notifications: NotifySubjRx.
 

Detailed Description

Subject Regex handling.

Authors
  • Richard Russon

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

Function Documentation

◆ subjrx_cleanup()

void subjrx_cleanup ( void  )

Free the Subject Regex List.

Definition at line 46 of file subjectrx.c.

47{
50}
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:75
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:450
static struct Notify * SubjRxNotify
Notifications: NotifySubjRx.
Definition: subjectrx.c:41
static struct ReplaceList SubjectRegexList
List of subjectrx rules for modifying the Subject:
Definition: subjectrx.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjrx_init()

void subjrx_init ( void  )

Create new Subject Regex List.

Definition at line 55 of file subjectrx.c.

56{
57 if (SubjRxNotify)
58 return;
59
62}
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:95
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct Notify * notify
Notifications handler.
Definition: neomutt.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjrx_apply_mods()

bool subjrx_apply_mods ( struct Envelope env)

Apply regex modifications to the subject.

Parameters
envEnvelope of Email
Return values
trueSubject modified

Definition at line 133 of file subjectrx.c.

134{
135 if (!env || !env->subject || (*env->subject == '\0'))
136 return false;
137
138 if (env->disp_subj)
139 return true;
140
142 return false;
143
145 return true;
146}
char * mutt_replacelist_apply(struct ReplaceList *rl, const char *str)
Apply replacements to a buffer.
Definition: regex.c:369
#define STAILQ_EMPTY(head)
Definition: queue.h:348
char *const subject
Email's subject.
Definition: envelope.h:70
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjrx_clear_mods()

void subjrx_clear_mods ( struct MailboxView mv)

Clear out all modified email subjects.

Parameters
mvMailbox view

Definition at line 152 of file subjectrx.c.

153{
154 if (!mv || !mv->mailbox)
155 return;
156
157 struct Mailbox *m = mv->mailbox;
158
159 for (int i = 0; i < m->msg_count; i++)
160 {
161 struct Email *e = m->emails[i];
162 if (!e || !e->env)
163 continue;
164 FREE(&e->env->disp_subj);
165 }
166}
#define FREE(x)
Definition: memory.h:55
The envelope/body of an email.
Definition: email.h:39
struct Envelope * env
Envelope information.
Definition: email.h:68
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:51
A mailbox.
Definition: mailbox.h:79
int msg_count
Total number of messages.
Definition: mailbox.h:88
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
+ Here is the caller graph for this function:

Variable Documentation

◆ SubjectRegexList

struct ReplaceList SubjectRegexList = STAILQ_HEAD_INITIALIZER(SubjectRegexList)
static

List of subjectrx rules for modifying the Subject:

Definition at line 40 of file subjectrx.c.

◆ SubjRxNotify

struct Notify* SubjRxNotify = NULL
static

Notifications: NotifySubjRx.

Definition at line 41 of file subjectrx.c.