NeoMutt  2024-03-23-23-gec7045
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:475
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:41
struct Notify * notify
Notifications handler.
Definition: neomutt.h:42
+ 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 129 of file subjectrx.c.

130{
131 if (!env || !env->subject || (*env->subject == '\0'))
132 return false;
133
134 if (env->disp_subj)
135 return true;
136
138 return false;
139
141 return true;
142}
char * mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, const char *str)
Apply replacements to a buffer.
Definition: regex.c:374
#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 148 of file subjectrx.c.

149{
150 if (!mv || !mv->mailbox)
151 return;
152
153 struct Mailbox *m = mv->mailbox;
154
155 for (int i = 0; i < m->msg_count; i++)
156 {
157 struct Email *e = m->emails[i];
158 if (!e || !e->env)
159 continue;
160 FREE(&e->env->disp_subj);
161 }
162}
#define FREE(x)
Definition: memory.h:45
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.