Commit 4f12cc0c 4f12cc0c9924afccb721ef418efe6e83c95c0cd1 by Sergey Poznyakoff

Further improvements in `mail'.

* NEWS: Update.
* mail/mail.h (MOPTF_UNSET): New constant.
* mail/mailvar.c (MAILVAR_TYPEMASK): New define.
(struct mailvar_symbol): Remove `type'. Add `handler'.
The latter supplies special handling for certain variables.
(mailvar_tab): Update accordingly.
Implement "debug" variable.
(mailvar_set): Enforce correct variable type in variable-strict mode.
Handle MOPTF_UNSET flag.
Remove kludgy special handling for some attributes, use sym->handler
instead.
(set_decode_fallback, set_replyregex)
(set_screen, set_mailbox_debug_level, set_debug): New functions.
(describe_symbol): Handle alternative symbol types.
* mail/set.c: Use MOPTF_UNSET when unsetting the variable.
* mail/source.c: Set correct locus. This allows to display
locations along with error messages.
1 parent 0a7e5933
......@@ -47,7 +47,14 @@ In addition, the form
mail --file=mymbox
is also allowed.
** error locations
Diagnostic messages issued while processing `source' command
include file locations, in compliance with the GNU standards. This
also includes diagnostics issued during processing of the
system or user configuration file.
** envelope command
The env[elope] command displays the SMTP envelopes of the messages
......
......@@ -344,6 +344,7 @@ extern void mailvar_variable_format (FILE *fp,
#define MOPTF_OVERWRITE 0x001
#define MOPTF_QUIET 0x002
#define MOPTF_UNSET 0x004
extern int mailvar_set (const char *name, void *value,
enum mailvar_type type, int flags);
extern int util_isdeleted (size_t msgno);
......
......@@ -48,7 +48,8 @@ mail_set (int argc, char **argv)
if (!strncmp ("no", argv[i], 2) && !value)
{
mailvar_set (&argv[i][2], NULL, mailvar_type_boolean, flags);
mailvar_set (&argv[i][2], NULL, mailvar_type_boolean,
flags | MOPTF_UNSET);
}
else if (value)
{
......
......@@ -18,21 +18,25 @@
#include "mail.h"
static char *
source_readline (void *closure, int cont MU_ARG_UNUSED)
{
FILE *fp = closure;
size_t s = 0;
char *buf = NULL;
mu_debug_t debug;
struct mu_debug_locus locus;
if (getline (&buf, &s, fp) >= 0)
{
int len = strlen (buf);
if (buf[len-1] == '\n')
buf[len-1] = '\0';
mu_rtrim_class (buf, MU_CTYPE_SPACE);
mu_diag_get_debug (&debug);
mu_debug_get_locus (debug, &locus);
mu_debug_set_locus (debug, locus.file, locus.line + 1);
return buf;
}
return NULL;
}
......@@ -45,11 +49,12 @@ mail_source (int argc, char **argv)
{
FILE *fp;
int save_term;
mu_debug_t debug;
if (argc != 2)
{
/* TRANSLATORS: 'source' is a command name. Do not translate it! */
util_error (_("source requires an argument"));
util_error (_("source requires a single argument"));
return 1;
}
......@@ -63,8 +68,11 @@ mail_source (int argc, char **argv)
save_term = interactive;
interactive = 0;
mail_mainloop(source_readline, fp, 0);
mu_diag_get_debug (&debug);
mu_debug_set_locus (debug, argv[1], 0);
mail_mainloop (source_readline, fp, 0);
interactive = save_term;
mu_debug_set_locus (debug, NULL, 0);
fclose (fp);
return 0;
}
......