NeoMutt  2025-09-05-70-gcfdde0
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
tags_edit()

Prompt and validate new messages tags. More...

+ Collaboration diagram for tags_edit():

Functions

static int comp_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf)
 Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
 
static int imap_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf)
 Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
 
static int nm_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf)
 Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
 

Detailed Description

Prompt and validate new messages tags.

Parameters
mMailbox
tagsExisting tags
bufBuffer to store the tags
Return values
-1Error
0No valid user input
1Buf set
Precondition
m is not NULL
buf is not NULL

Function Documentation

◆ comp_tags_edit()

static int comp_tags_edit ( struct Mailbox * m,
const char * tags,
struct Buffer * buf )
static

Prompt and validate new messages tags - Implements MxOps::tags_edit() -.

Definition at line 824 of file compress.c.

825{
826 if (!m->compress_info)
827 return 0;
828
829 struct CompressInfo *ci = m->compress_info;
830
831 const struct MxOps *ops = ci->child_ops;
832 if (!ops || !ops->tags_edit)
833 return 0;
834
835 return ops->tags_edit(m, tags, buf);
836}
Private data for compress.
Definition lib.h:60
const struct MxOps * child_ops
callbacks of de-compressed file
Definition lib.h:65
void * compress_info
Compressed mbox module private data.
Definition mailbox.h:121
Definition mxapi.h:88
int(* tags_edit)(struct Mailbox *m, const char *tags, struct Buffer *buf)
Definition mxapi.h:303

◆ imap_tags_edit()

static int imap_tags_edit ( struct Mailbox * m,
const char * tags,
struct Buffer * buf )
static

Prompt and validate new messages tags - Implements MxOps::tags_edit() -.

Definition at line 2196 of file imap.c.

2197{
2198 struct ImapMboxData *mdata = imap_mdata_get(m);
2199 if (!mdata)
2200 return -1;
2201
2202 char *new_tag = NULL;
2203 char *checker = NULL;
2204
2205 /* Check for \* flags capability */
2206 if (!imap_has_flag(&mdata->flags, NULL))
2207 {
2208 mutt_error(_("IMAP server doesn't support custom flags"));
2209 return -1;
2210 }
2211
2212 buf_reset(buf);
2213 if (tags)
2214 buf_strcpy(buf, tags);
2215
2216 if (mw_get_field("Tags: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
2217 return -1;
2218
2219 /* each keyword must be atom defined by rfc822 as:
2220 *
2221 * atom = 1*<any CHAR except specials, SPACE and CTLs>
2222 * CHAR = ( 0.-127. )
2223 * specials = "(" / ")" / "<" / ">" / "@"
2224 * / "," / ";" / ":" / "\" / <">
2225 * / "." / "[" / "]"
2226 * SPACE = ( 32. )
2227 * CTLS = ( 0.-31., 127.)
2228 *
2229 * And must be separated by one space.
2230 */
2231
2232 new_tag = buf->data;
2233 checker = buf->data;
2234 SKIPWS(checker);
2235 while (*checker != '\0')
2236 {
2237 if ((*checker < 32) || (*checker >= 127) || // We allow space because it's the separator
2238 (*checker == 40) || // (
2239 (*checker == 41) || // )
2240 (*checker == 60) || // <
2241 (*checker == 62) || // >
2242 (*checker == 64) || // @
2243 (*checker == 44) || // ,
2244 (*checker == 59) || // ;
2245 (*checker == 58) || // :
2246 (*checker == 92) || // backslash
2247 (*checker == 34) || // "
2248 (*checker == 46) || // .
2249 (*checker == 91) || // [
2250 (*checker == 93)) // ]
2251 {
2252 mutt_error(_("Invalid IMAP flags"));
2253 return 0;
2254 }
2255
2256 /* Skip duplicate space */
2257 while ((checker[0] == ' ') && (checker[1] == ' '))
2258 checker++;
2259
2260 /* copy char to new_tag and go the next one */
2261 *new_tag++ = *checker++;
2262 }
2263 *new_tag = '\0';
2264 new_tag = buf->data; /* rewind */
2266
2267 return !mutt_str_equal(tags, buf_string(buf));
2268}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:272
#define mutt_error(...)
Definition logging2.h:93
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:59
struct ImapMboxData * imap_mdata_get(struct Mailbox *m)
Get the Mailbox data for this mailbox.
Definition mdata.c:61
bool imap_has_flag(struct ListHead *flag_list, const char *flag)
Does the flag exist in the list.
Definition imap.c:878
#define _(a)
Definition message.h:28
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
Definition string.c:565
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition mutt.h:56
#define SKIPWS(ch)
Definition string2.h:51
char * data
Pointer to data.
Definition buffer.h:37
IMAP-specific Mailbox data -.
Definition mdata.h:40
void * mdata
Driver specific data.
Definition mailbox.h:132
+ Here is the call graph for this function:

◆ nm_tags_edit()

static int nm_tags_edit ( struct Mailbox * m,
const char * tags,
struct Buffer * buf )
static

Prompt and validate new messages tags - Implements MxOps::tags_edit() -.

Definition at line 2426 of file notmuch.c.

2427{
2428 buf_reset(buf);
2429 if (mw_get_field("Add/remove labels: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2430 &CompleteNmTagOps, NULL) != 0)
2431 {
2432 return -1;
2433 }
2434 return 1;
2435}
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
Definition complete.c:254
+ Here is the call graph for this function: