Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 43 / 4477ba801eaf6648099afa4e183fffda557c8a
1 Return-Path: <sojkam1@fel.cvut.cz>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 9B5CA431FBC\r
6         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 16:26:35 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 9SX-5F5S4ZHz for <notmuch@notmuchmail.org>;\r
16         Tue,  4 Nov 2014 16:26:30 -0800 (PST)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id 55D73431FBD\r
19         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 16:26:19 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id C07AC5CD1A6\r
22         for <notmuch@notmuchmail.org>; Wed,  5 Nov 2014 01:26:18 +0100 (CET)\r
23 X-Virus-Scanned: IMAP STYX AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,\r
26         port 10044) with ESMTP id emGxHg4_7kP5 for <notmuch@notmuchmail.org>;\r
27         Wed,  5 Nov 2014 01:26:14 +0100 (CET)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id EEC805CD1AB\r
30         for <notmuch@notmuchmail.org>; Wed,  5 Nov 2014 01:26:13 +0100 (CET)\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
32         (envelope-from <sojkam1@fel.cvut.cz>)\r
33         id 1XloQI-0005D8-UZ; Wed, 05 Nov 2014 01:26:06 +0100\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v3 07/10] cli: search: Convert --output to keyword argument\r
37 Date: Wed,  5 Nov 2014 01:25:56 +0100\r
38 Message-Id: <1415147159-19946-8-git-send-email-sojkam1@fel.cvut.cz>\r
39 X-Mailer: git-send-email 2.1.1\r
40 In-Reply-To: <1415147159-19946-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 References: <1415147159-19946-1-git-send-email-sojkam1@fel.cvut.cz>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Wed, 05 Nov 2014 00:26:36 -0000\r
55 \r
56 Now, when address related outputs are in a separate command, it makes\r
57 no sense to combine multiple --output options in search command line.\r
58 Using switch statement to handle different outputs is more readable\r
59 than a series of if statements.\r
60 ---\r
61  doc/man1/notmuch-search.rst |  3 ---\r
62  notmuch-search.c            | 25 +++++++++++++------------\r
63  2 files changed, 13 insertions(+), 15 deletions(-)\r
64 \r
65 diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst\r
66 index 65df288..0cc2911 100644\r
67 --- a/doc/man1/notmuch-search.rst\r
68 +++ b/doc/man1/notmuch-search.rst\r
69 @@ -78,9 +78,6 @@ Supported options for **search** include\r
70              by null characters (--format=text0), as a JSON array\r
71              (--format=json), or as an S-Expression list (--format=sexp).\r
72  \r
73 -       This option can be given multiple times to combine different\r
74 -       outputs.\r
75 -\r
76      ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)\r
77          This option can be used to present results in either\r
78          chronological order (**oldest-first**) or reverse chronological\r
79 diff --git a/notmuch-search.c b/notmuch-search.c\r
80 index 69938d6..e084d25 100644\r
81 --- a/notmuch-search.c\r
82 +++ b/notmuch-search.c\r
83 @@ -587,7 +587,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
84      int opt_index, ret;\r
85  \r
86      notmuch_opt_desc_t options[] = {\r
87 -       { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
88 +       { NOTMUCH_OPT_KEYWORD, &ctx->output, "output", 'o',\r
89           (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
90                                   { "threads", OUTPUT_THREADS },\r
91                                   { "messages", OUTPUT_MESSAGES },\r
92 @@ -607,13 +607,11 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
93         { 0, 0, 0, 0, 0 }\r
94      };\r
95  \r
96 +    ctx->output = OUTPUT_SUMMARY;\r
97      opt_index = parse_arguments (argc, argv, options, 1);\r
98      if (opt_index < 0)\r
99         return EXIT_FAILURE;\r
100  \r
101 -    if (! ctx->output)\r
102 -       ctx->output = OUTPUT_SUMMARY;\r
103 -\r
104      if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES &&\r
105         ctx->dupe != -1) {\r
106          fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n");\r
107 @@ -624,17 +622,20 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
108                                  argc - opt_index, argv + opt_index))\r
109         return EXIT_FAILURE;\r
110  \r
111 -    if (ctx->output == OUTPUT_SUMMARY ||\r
112 -       ctx->output == OUTPUT_THREADS)\r
113 +    switch (ctx->output) {\r
114 +    case OUTPUT_SUMMARY:\r
115 +    case OUTPUT_THREADS:\r
116         ret = do_search_threads (ctx);\r
117 -    else if (ctx->output == OUTPUT_MESSAGES ||\r
118 -            ctx->output == OUTPUT_FILES)\r
119 +       break;\r
120 +    case OUTPUT_MESSAGES:\r
121 +    case OUTPUT_FILES:\r
122         ret = do_search_messages (ctx);\r
123 -    else if (ctx->output == OUTPUT_TAGS)\r
124 +       break;\r
125 +    case OUTPUT_TAGS:\r
126         ret = do_search_tags (ctx);\r
127 -    else {\r
128 -       fprintf (stderr, "Error: the combination of outputs is not supported.\n");\r
129 -       ret = 1;\r
130 +       break;\r
131 +    default:\r
132 +       INTERNAL_ERROR ("Unexpected output");\r
133      }\r
134  \r
135      _notmuch_search_cleanup (ctx);\r
136 -- \r
137 2.1.1\r
138 \r