NeoMutt  2025-12-11-694-ga89709
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 830 of file compress.c.

831{
832 if (!m->compress_info)
833 return 0;
834
835 struct CompressInfo *ci = m->compress_info;
836
837 const struct MxOps *ops = ci->child_ops;
838 if (!ops || !ops->tags_edit)
839 return 0;
840
841 return ops->tags_edit(m, tags, buf);
842}
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 2389 of file imap.c.

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

2463{
2464 buf_reset(buf);
2465 if (mw_get_field("Add/remove labels: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2466 &CompleteNmTagOps, NULL) != 0)
2467 {
2468 return -1;
2469 }
2470 return 1;
2471}
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
Definition complete.c:254
+ Here is the call graph for this function: