NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
subjectrx.h File Reference

Parse Subject-regex Commands. More...

#include <stdbool.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  NotifySubjectRx { NT_SUBJECTRX_ADD = 1 , NT_SUBJECTRX_DELETE , NT_SUBJECTRX_DELETE_ALL }
 Subject Regex notification types. More...
 

Functions

void subjectrx_init (struct NeoMutt *n, struct IndexModuleData *md)
 Create new Subject Regex List.
 
void subjectrx_cleanup (struct IndexModuleData *md)
 Free the Subject Regex List.
 
enum CommandResult parse_subjectrx_list (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'subject-regex' command - Implements Command::parse() -.
 
enum CommandResult parse_unsubjectrx_list (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unsubject-regex' command - Implements Command::parse() -.
 
bool subjectrx_apply_mods (struct Envelope *env)
 Apply regex modifications to the subject.
 
void subjectrx_clear_mods (struct MailboxView *mv)
 Clear out all modified email subjects.
 

Detailed Description

Parse Subject-regex Commands.

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

◆ NotifySubjectRx

Subject Regex notification types.

Observers of NT_SUBJECTRX will not be passed any Event data.

Note
Notifications are sent after the event.
Enumerator
NT_SUBJECTRX_ADD 

Subject Regex has been added.

NT_SUBJECTRX_DELETE 

Subject Regex has been deleted.

NT_SUBJECTRX_DELETE_ALL 

All Subject Regexes have been deleted.

Definition at line 43 of file subjectrx.h.

44{
48};
@ NT_SUBJECTRX_DELETE
Subject Regex has been deleted.
Definition subjectrx.h:46
@ NT_SUBJECTRX_DELETE_ALL
All Subject Regexes have been deleted.
Definition subjectrx.h:47
@ NT_SUBJECTRX_ADD
Subject Regex has been added.
Definition subjectrx.h:45

Function Documentation

◆ subjectrx_init()

void subjectrx_init ( struct NeoMutt * n,
struct IndexModuleData * md )

Create new Subject Regex List.

Definition at line 42 of file subjectrx.c.

43{
45
48}
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
#define STAILQ_INIT(head)
Definition queue.h:410
struct Notify * subject_rx_notify
List of subject-regex rules for modifying the Subject:
Definition module_data.h:34
struct ReplaceList subject_rx_list
Definition module_data.h:33
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjectrx_cleanup()

void subjectrx_cleanup ( struct IndexModuleData * md)

Free the Subject Regex List.

Definition at line 53 of file subjectrx.c.

54{
56
58}
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjectrx_apply_mods()

bool subjectrx_apply_mods ( struct Envelope * env)

Apply regex modifications to the subject.

Parameters
envEnvelope of Email
Return values
trueSubject modified

Definition at line 148 of file subjectrx.c.

149{
150 if (!env || !env->subject || (*env->subject == '\0'))
151 return false;
152
153 if (env->disp_subj)
154 return true;
155
157 ASSERT(md);
158
160 return false;
161
163 return true;
164}
@ MODULE_ID_INDEX
ModuleIndex, Index
Definition module_api.h:72
char * mutt_replacelist_apply(struct ReplaceList *rl, const char *str)
Apply replacements to a buffer.
Definition regex.c:369
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:585
#define STAILQ_EMPTY(head)
Definition queue.h:382
#define ASSERT(COND)
Definition signal2.h:59
char *const subject
Email's subject.
Definition envelope.h:70
char * disp_subj
Display subject (modified copy of subject)
Definition envelope.h:72
Index private Module data.
Definition module_data.h:32
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjectrx_clear_mods()

void subjectrx_clear_mods ( struct MailboxView * mv)

Clear out all modified email subjects.

Parameters
mvMailbox view

Definition at line 170 of file subjectrx.c.

171{
172 if (!mv || !mv->mailbox)
173 return;
174
175 struct Mailbox *m = mv->mailbox;
176
177 for (int i = 0; i < m->msg_count; i++)
178 {
179 struct Email *e = m->emails[i];
180 if (!e || !e->env)
181 continue;
182 FREE(&e->env->disp_subj);
183 }
184}
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
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:78
int msg_count
Total number of messages.
Definition mailbox.h:87
struct Email ** emails
Array of Emails.
Definition mailbox.h:95
+ Here is the caller graph for this function: