NeoMutt  2025-12-11-911-gd8d604
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 829 of file compress.c.

830{
831 if (!m->compress_info)
832 return 0;
833
834 struct CompressInfo *ci = m->compress_info;
835
836 const struct MxOps *ops = ci->child_ops;
837 if (!ops || !ops->tags_edit)
838 return 0;
839
840 return ops->tags_edit(m, tags, buf);
841}
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:123
Definition mxapi.h:98
int(* tags_edit)(struct Mailbox *m, const char *tags, struct Buffer *buf)
Definition mxapi.h:313

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

2525{
2526 struct ImapMboxData *mdata = imap_mdata_get(m);
2527 if (!mdata)
2528 return -1;
2529
2530 char *new_tag = NULL;
2531 char *checker = NULL;
2532
2533 /* Check for \* flags capability */
2534 if (!imap_has_flag(&mdata->flags, NULL))
2535 {
2536 mutt_error(_("IMAP server doesn't support custom flags"));
2537 return -1;
2538 }
2539
2540 buf_reset(buf);
2541 if (tags)
2542 buf_strcpy(buf, tags);
2543
2544 if (mw_get_field("Tags: ", buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0)
2545 return -1;
2546
2547 /* each keyword must be atom defined by rfc822 as:
2548 *
2549 * atom = 1*<any CHAR except specials, SPACE and CTLs>
2550 * CHAR = ( 0.-127. )
2551 * specials = "(" / ")" / "<" / ">" / "@"
2552 * / "," / ";" / ":" / "\" / <">
2553 * / "." / "[" / "]"
2554 * SPACE = ( 32. )
2555 * CTLS = ( 0.-31., 127.)
2556 *
2557 * And must be separated by one space.
2558 */
2559
2560 new_tag = buf->data;
2561 checker = buf->data;
2562 SKIPWS(checker);
2563 while (*checker != '\0')
2564 {
2565 if ((*checker < 32) || (*checker >= 127) || // We allow space because it's the separator
2566 (*checker == 40) || // (
2567 (*checker == 41) || // )
2568 (*checker == 60) || // <
2569 (*checker == 62) || // >
2570 (*checker == 64) || // @
2571 (*checker == 44) || // ,
2572 (*checker == 59) || // ;
2573 (*checker == 58) || // :
2574 (*checker == 92) || // backslash
2575 (*checker == 34) || // "
2576 (*checker == 46) || // .
2577 (*checker == 91) || // [
2578 (*checker == 93)) // ]
2579 {
2580 mutt_error(_("Invalid IMAP flags"));
2581 return 0;
2582 }
2583
2584 /* Skip duplicate space */
2585 while ((checker[0] == ' ') && (checker[1] == ' '))
2586 checker++;
2587
2588 /* copy char to new_tag and go the next one */
2589 *new_tag++ = *checker++;
2590 }
2591 *new_tag = '\0';
2592 new_tag = buf->data; /* rewind */
2594
2595 return !mutt_str_equal(tags, buf_string(buf));
2596}
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
@ MUTT_COMP_NONE
No flags are set.
Definition wdata.h:46
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:502
#define mutt_error(...)
Definition logging2.h:94
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:61
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:570
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
#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:134
+ 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 2478 of file notmuch.c.

2479{
2480 buf_reset(buf);
2481 if (mw_get_field("Add/remove labels: ", buf, MUTT_COMP_NONE, HC_OTHER,
2482 &CompleteNmTagOps, NULL) != 0)
2483 {
2484 return -1;
2485 }
2486 return 1;
2487}
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
Definition complete.c:254
+ Here is the call graph for this function: