NeoMutt  2025-12-11-276-g10b23b
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 826 of file compress.c.

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

◆ 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 2386 of file imap.c.

2387{
2388 struct ImapMboxData *mdata = imap_mdata_get(m);
2389 if (!mdata)
2390 return -1;
2391
2392 char *new_tag = NULL;
2393 char *checker = NULL;
2394
2395 /* Check for \* flags capability */
2396 if (!imap_has_flag(&mdata->flags, NULL))
2397 {
2398 mutt_error(_("IMAP server doesn't support custom flags"));
2399 return -1;
2400 }
2401
2402 buf_reset(buf);
2403 if (tags)
2404 buf_strcpy(buf, tags);
2405
2406 if (mw_get_field("Tags: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
2407 return -1;
2408
2409 /* each keyword must be atom defined by rfc822 as:
2410 *
2411 * atom = 1*<any CHAR except specials, SPACE and CTLs>
2412 * CHAR = ( 0.-127. )
2413 * specials = "(" / ")" / "<" / ">" / "@"
2414 * / "," / ";" / ":" / "\" / <">
2415 * / "." / "[" / "]"
2416 * SPACE = ( 32. )
2417 * CTLS = ( 0.-31., 127.)
2418 *
2419 * And must be separated by one space.
2420 */
2421
2422 new_tag = buf->data;
2423 checker = buf->data;
2424 SKIPWS(checker);
2425 while (*checker != '\0')
2426 {
2427 if ((*checker < 32) || (*checker >= 127) || // We allow space because it's the separator
2428 (*checker == 40) || // (
2429 (*checker == 41) || // )
2430 (*checker == 60) || // <
2431 (*checker == 62) || // >
2432 (*checker == 64) || // @
2433 (*checker == 44) || // ,
2434 (*checker == 59) || // ;
2435 (*checker == 58) || // :
2436 (*checker == 92) || // backslash
2437 (*checker == 34) || // "
2438 (*checker == 46) || // .
2439 (*checker == 91) || // [
2440 (*checker == 93)) // ]
2441 {
2442 mutt_error(_("Invalid IMAP flags"));
2443 return 0;
2444 }
2445
2446 /* Skip duplicate space */
2447 while ((checker[0] == ' ') && (checker[1] == ' '))
2448 checker++;
2449
2450 /* copy char to new_tag and go the next one */
2451 *new_tag++ = *checker++;
2452 }
2453 *new_tag = '\0';
2454 new_tag = buf->data; /* rewind */
2456
2457 return !mutt_str_equal(tags, buf_string(buf));
2458}
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
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition wdata.h:42
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:271
#define mutt_error(...)
Definition logging2.h:94
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
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:1054
#define _(a)
Definition message.h:28
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
Definition string.c:567
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
#define SKIPWS(ch)
Definition string2.h:52
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:131
+ 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 2418 of file notmuch.c.

2419{
2420 buf_reset(buf);
2421 if (mw_get_field("Add/remove labels: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2422 &CompleteNmTagOps, NULL) != 0)
2423 {
2424 return -1;
2425 }
2426 return 1;
2427}
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
Definition complete.c:254
+ Here is the call graph for this function: