Support format specifiers in grep mode
Honor --format-* parameters when using the -G operation. In the case of recurring items, the first occurrence is used. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
e9c8197e4e
commit
62f04c3f9a
31
src/args.c
31
src/args.c
@ -395,11 +395,11 @@ int parse_args(int argc, char **argv)
|
|||||||
/* Filters */
|
/* Filters */
|
||||||
struct item_filter filter = { 0, NULL, NULL, -1, -1, -1, -1, 0, 0, 0 };
|
struct item_filter filter = { 0, NULL, NULL, -1, -1, -1, -1, 0, 0, 0 };
|
||||||
/* Format strings */
|
/* Format strings */
|
||||||
const char *fmt_apt = " - %S -> %E\n\t%m\n";
|
const char *fmt_apt = NULL;
|
||||||
const char *fmt_rapt = " - %S -> %E\n\t%m\n";
|
const char *fmt_rapt = NULL;
|
||||||
const char *fmt_ev = " * %m\n";
|
const char *fmt_ev = NULL;
|
||||||
const char *fmt_rev = " * %m\n";
|
const char *fmt_rev = NULL;
|
||||||
const char *fmt_todo = "%p. %m\n";
|
const char *fmt_todo = NULL;
|
||||||
/* Import and export parameters */
|
/* Import and export parameters */
|
||||||
int xfmt = IO_EXPORT_ICAL;
|
int xfmt = IO_EXPORT_ICAL;
|
||||||
int list_imported = 0, export_uid = 0;
|
int list_imported = 0, export_uid = 0;
|
||||||
@ -731,8 +731,17 @@ int parse_args(int argc, char **argv)
|
|||||||
io_save_todo(path_todo);
|
io_save_todo(path_todo);
|
||||||
io_save_apts(path_apts);
|
io_save_apts(path_apts);
|
||||||
} else {
|
} else {
|
||||||
io_dump_todo("%(raw)");
|
/*
|
||||||
io_dump_apts("%(raw)", "%(raw)", "%(raw)", "%(raw)");
|
* Use default values for non-specified format strings.
|
||||||
|
*/
|
||||||
|
fmt_apt = fmt_apt ? fmt_apt : "%(raw)";
|
||||||
|
fmt_rapt = fmt_rapt ? fmt_rapt : "%(raw)";
|
||||||
|
fmt_ev = fmt_ev ? fmt_ev : "%(raw)";
|
||||||
|
fmt_rev = fmt_rev ? fmt_rev : "%(raw)";
|
||||||
|
fmt_todo = fmt_todo ? fmt_todo : "%(raw)";
|
||||||
|
|
||||||
|
io_dump_todo(fmt_todo);
|
||||||
|
io_dump_apts(fmt_apt, fmt_rapt, fmt_ev, fmt_rev);
|
||||||
}
|
}
|
||||||
} else if (query) {
|
} else if (query) {
|
||||||
io_check_file(path_apts);
|
io_check_file(path_apts);
|
||||||
@ -741,6 +750,14 @@ int parse_args(int argc, char **argv)
|
|||||||
vars_init();
|
vars_init();
|
||||||
config_load(); /* To get output date format. */
|
config_load(); /* To get output date format. */
|
||||||
io_load_data(&filter);
|
io_load_data(&filter);
|
||||||
|
|
||||||
|
/* Use default values for non-specified format strings. */
|
||||||
|
fmt_apt = fmt_apt ? fmt_apt : " - %S -> %E\n\t%m\n";
|
||||||
|
fmt_rapt = fmt_rapt ? fmt_rapt : " - %S -> %E\n\t%m\n";
|
||||||
|
fmt_ev = fmt_ev ? fmt_ev : " * %m\n";
|
||||||
|
fmt_rev = fmt_rev ? fmt_rev : " * %m\n";
|
||||||
|
fmt_todo = fmt_todo ? fmt_todo : "%p. %m\n";
|
||||||
|
|
||||||
int add_line = todo_arg(fmt_todo, &limit, &filter);
|
int add_line = todo_arg(fmt_todo, &limit, &filter);
|
||||||
date_arg_from_to(from, to, add_line, fmt_apt, fmt_rapt, fmt_ev,
|
date_arg_from_to(from, to, add_line, fmt_apt, fmt_rapt, fmt_ev,
|
||||||
fmt_rev, &limit);
|
fmt_rev, &limit);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user