NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
subjectrx.h File Reference

Subject Regex handling. More...

#include <stdbool.h>
#include <stdint.h>
#include "core/lib.h"
+ Include dependency graph for subjectrx.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  NotifySubjRx { NT_SUBJRX_ADD = 1 , NT_SUBJRX_DELETE , NT_SUBJRX_DELETE_ALL }
 Subject Regex notification types. More...
 

Functions

void subjrx_init (void)
 Create new Subject Regex List.
 
void subjrx_cleanup (void)
 Free the Subject Regex List.
 
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() -.
 
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.
 

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.h.

Enumeration Type Documentation

◆ NotifySubjRx

Subject Regex notification types.

Observers of NT_SUBJRX will not be passed any Event data.

Note
Notifications are sent after the event.
Enumerator
NT_SUBJRX_ADD 

Subject Regex has been added.

NT_SUBJRX_DELETE 

Subject Regex has been deleted.

NT_SUBJRX_DELETE_ALL 

All Subject Regexes have been deleted.

Definition at line 41 of file subjectrx.h.

42{
43 NT_SUBJRX_ADD = 1,
46};
@ NT_SUBJRX_DELETE
Subject Regex has been deleted.
Definition: subjectrx.h:44
@ NT_SUBJRX_ADD
Subject Regex has been added.
Definition: subjectrx.h:43
@ NT_SUBJRX_DELETE_ALL
All Subject Regexes have been deleted.
Definition: subjectrx.h:45

Function Documentation

◆ 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
static struct Notify * SubjRxNotify
Notifications: NotifySubjRx.
Definition: subjectrx.c:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 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_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: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: