NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
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. More...
 
void subjrx_free (void)
 Free the Subject Regex List. More...
 
enum CommandResult parse_subjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subjectrx' command - Implements Command::parse() -. More...
 
enum CommandResult parse_unsubjectrx_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubjectrx' command - Implements Command::parse() -. More...
 
bool subjrx_apply_mods (struct Envelope *env)
 Apply regex modifications to the subject. More...
 
void subjrx_clear_mods (struct Mailbox *m)
 Clear out all modified email subjects. More...
 

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 40 of file subjectrx.h.

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

Function Documentation

◆ subjrx_init()

void subjrx_init ( void  )

Create new Subject Regex List.

Definition at line 54 of file subjectrx.c.

55{
56 if (SubjRxNotify)
57 return;
58
61}
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:60
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
static struct Notify * SubjRxNotify
Definition: subjectrx.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subjrx_free()

void subjrx_free ( void  )

Free the Subject Regex List.

Definition at line 45 of file subjectrx.c.

46{
49}
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:73
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition: regex.c:467
static struct ReplaceList SubjectRegexList
Definition: subjectrx.c:39
+ 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 128 of file subjectrx.c.

129{
130 if (!env || !env->subject || (*env->subject == '\0'))
131 return false;
132
133 if (env->disp_subj)
134 return true;
135
137 return false;
138
140 return true;
141}
char * mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, const char *str)
Apply replacements to a buffer.
Definition: regex.c:368
#define STAILQ_EMPTY(head)
Definition: queue.h:348
char * 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 Mailbox m)

Clear out all modified email subjects.

Definition at line 146 of file subjectrx.c.

147{
148 if (!m)
149 return;
150
151 for (int i = 0; i < m->msg_count; i++)
152 {
153 struct Email *e = m->emails[i];
154 if (!e || !e->env)
155 continue;
156 FREE(&e->env->disp_subj);
157 }
158}
#define FREE(x)
Definition: memory.h:43
The envelope/body of an email.
Definition: email.h:37
struct Envelope * env
Envelope information.
Definition: email.h:66
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: