]> git.deb.at Git - pkg/abook.git/commitdiff
mutt-query (3/3): register the --mutt-query-format per-item filter and use it
authorRaphaël Droz <raphael.droz+floss@gmail.com>
Tue, 30 Aug 2011 13:42:09 +0000 (15:42 +0200)
committerRaphaël Droz <raphael.droz+floss@gmail.com>
Wed, 24 Oct 2012 16:23:52 +0000 (18:23 +0200)
abook.c
filter.c

diff --git a/abook.c b/abook.c
index 4ef136c1f44082359a7516fd1f24ae5444de2aa5..e9f8841dccee9c3eb23be9a2e882e3be2fdcb99f 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -50,6 +50,8 @@ static void           add_email(int);
 char *datafile = NULL;
 static char *rcfile = NULL;
 
+struct abook_output_item_filter selected_item_filter;
+
 bool alternative_datafile = FALSE;
 bool alternative_rcfile = FALSE;
 
@@ -303,6 +305,7 @@ parse_command_line(int argc, char **argv)
                *infile = "-",
                *outfile = "-";
        int c;
+       selected_item_filter = select_output_item_filter("muttq");
 
        for(;;) {
                int option_index = 0;
@@ -368,7 +371,8 @@ parse_command_line(int argc, char **argv)
                                set_convert_var(informat);
                                break;
                        case OPT_OUTFORMAT:
-                               set_convert_var(outformat);
+                               outformat = optarg;
+                               selected_item_filter = select_output_item_filter(outformat);
                                break;
                        case OPT_INFILE:
                                set_convert_var(infile);
@@ -384,6 +388,8 @@ parse_command_line(int argc, char **argv)
                }
        }
 
+       if(! selected_item_filter.func)
+               selected_item_filter = select_output_item_filter("muttq");
        if(optind < argc) {
                fprintf(stderr, _("%s: unrecognized arguments on command line\n"),
                                argv[0]);
@@ -462,7 +468,7 @@ mutt_query(char *str)
                }
                putchar('\n');
                while(i >= 0) {
-                       muttq_print_item(stdout, i);
+                       e_write_item(stdout, i, selected_item_filter.func);
                        i = find_item(str, i + 1, search_fields);
                }
        }
index 96fa9c207e5b6d58788c8cda616a7f309c7f73f4..2735331d1d5a110d09d79cdf61bf020606158795 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -103,6 +103,7 @@ struct abook_output_filter e_filters[] = {
 };
 
 struct abook_output_item_filter u_filters[] = {
+       { "muttq", N_("mutt alias"), muttq_print_item },
        { "\0", NULL }
 };