NeoMutt  2025-12-11-980-ge38c27
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 2526 of file imap.c.

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

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