NeoMutt  2025-12-11-58-g09398d
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 834 of file compress.c.

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

2226{
2227 struct ImapMboxData *mdata = imap_mdata_get(m);
2228 if (!mdata)
2229 return -1;
2230
2231 char *new_tag = NULL;
2232 char *checker = NULL;
2233
2234 /* Check for \* flags capability */
2235 if (!imap_has_flag(&mdata->flags, NULL))
2236 {
2237 mutt_error(_("IMAP server doesn't support custom flags"));
2238 return -1;
2239 }
2240
2241 buf_reset(buf);
2242 if (tags)
2243 buf_strcpy(buf, tags);
2244
2245 if (mw_get_field("Tags: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
2246 return -1;
2247
2248 /* each keyword must be atom defined by rfc822 as:
2249 *
2250 * atom = 1*<any CHAR except specials, SPACE and CTLs>
2251 * CHAR = ( 0.-127. )
2252 * specials = "(" / ")" / "<" / ">" / "@"
2253 * / "," / ";" / ":" / "\" / <">
2254 * / "." / "[" / "]"
2255 * SPACE = ( 32. )
2256 * CTLS = ( 0.-31., 127.)
2257 *
2258 * And must be separated by one space.
2259 */
2260
2261 new_tag = buf->data;
2262 checker = buf->data;
2263 SKIPWS(checker);
2264 while (*checker != '\0')
2265 {
2266 if ((*checker < 32) || (*checker >= 127) || // We allow space because it's the separator
2267 (*checker == 40) || // (
2268 (*checker == 41) || // )
2269 (*checker == 60) || // <
2270 (*checker == 62) || // >
2271 (*checker == 64) || // @
2272 (*checker == 44) || // ,
2273 (*checker == 59) || // ;
2274 (*checker == 58) || // :
2275 (*checker == 92) || // backslash
2276 (*checker == 34) || // "
2277 (*checker == 46) || // .
2278 (*checker == 91) || // [
2279 (*checker == 93)) // ]
2280 {
2281 mutt_error(_("Invalid IMAP flags"));
2282 return 0;
2283 }
2284
2285 /* Skip duplicate space */
2286 while ((checker[0] == ' ') && (checker[1] == ' '))
2287 checker++;
2288
2289 /* copy char to new_tag and go the next one */
2290 *new_tag++ = *checker++;
2291 }
2292 *new_tag = '\0';
2293 new_tag = buf->data; /* rewind */
2295
2296 return !mutt_str_equal(tags, buf_string(buf));
2297}
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:894
#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: