NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
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 "mutt.h"
#include "subjectrx.h"
#include "init.h"
#include "mutt_commands.h"
+ Include dependency graph for subjectrx.c:

Go to the source code of this file.

Functions

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

Variables

static struct ReplaceList SubjectRegexList = STAILQ_HEAD_INITIALIZER(SubjectRegexList)
 
static struct NotifySubjRxNotify = NULL
 

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_free()

void subjrx_free ( void  )

Free the Subject Regex List.

Definition at line 46 of file subjectrx.c.

47 {
50 }
static struct ReplaceList SubjectRegexList
Definition: subjectrx.c:40
static struct Notify * SubjRxNotify
Definition: subjectrx.c:41
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:448
+ 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 }
static struct Notify * SubjRxNotify
Definition: subjectrx.c:41
Container for Accounts, Notifications.
Definition: neomutt.h:36
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:60
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
+ 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 }
static struct ReplaceList SubjectRegexList
Definition: subjectrx.c:40
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:68
char * mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, const char *str)
Apply replacements to a buffer.
Definition: regex.c:353
char * subject
Email&#39;s subject.
Definition: envelope.h:66
#define STAILQ_EMPTY(head)
Definition: queue.h:348
+ 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 147 of file subjectrx.c.

148 {
149  if (!m)
150  return;
151 
152  for (int i = 0; i < m->msg_count; i++)
153  {
154  struct Email *e = m->emails[i];
155  if (!e || !e->env)
156  continue;
157  FREE(&e->env->disp_subj);
158  }
159 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:68
struct Envelope * env
Envelope information.
Definition: email.h:90
#define FREE(x)
Definition: memory.h:40
+ Here is the caller graph for this function:

Variable Documentation

◆ SubjectRegexList

struct ReplaceList SubjectRegexList = STAILQ_HEAD_INITIALIZER(SubjectRegexList)
static

Definition at line 40 of file subjectrx.c.

◆ SubjRxNotify

struct Notify* SubjRxNotify = NULL
static

Definition at line 41 of file subjectrx.c.