From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [RFC PATCH 1/3] cli: notmuch-show changes to support pick
Date: Sun, 12 Feb 2012 10:36:03 +0000 [thread overview]
Message-ID: <1329042965-3871-1-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <87d39k1gvi.fsf@qmul.ac.uk>
---
notmuch-client.h | 9 +++++-
notmuch-show.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 88 insertions(+), 11 deletions(-)
diff --git a/notmuch-client.h b/notmuch-client.h
index 60828aa..b4dc7bf 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -97,10 +97,17 @@ typedef struct notmuch_show_format {
const char *message_set_end;
} notmuch_show_format_t;
+enum {
+ NOTMUCH_SHOW_THREAD_MATCH,
+ NOTMUCH_SHOW_THREAD_ENTIRE,
+ NOTMUCH_SHOW_THREAD_NONE
+};
+
typedef struct notmuch_show_params {
- notmuch_bool_t entire_thread;
+ int entire_thread;
notmuch_bool_t raw;
int part;
+ int headers_only;
#ifdef GMIME_ATLEAST_26
GMimeCryptoContext* cryptoctx;
#else
diff --git a/notmuch-show.c b/notmuch-show.c
index c8fbd79..725d47d 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -876,7 +876,7 @@ show_message (void *ctx,
fputs (format->body_start, stdout);
}
- if (format->part_content)
+ if (format->part_content && !params->headers_only)
show_message_body (message, format, params);
if (params->part <= 0) {
@@ -923,11 +923,16 @@ show_messages (void *ctx,
fputs (format->message_set_sep, stdout);
}
- show_messages (ctx,
- format,
- notmuch_message_get_replies (message),
- next_indent,
- params);
+ if (params->entire_thread != NOTMUCH_SHOW_THREAD_NONE)
+ show_messages (ctx,
+ format,
+ notmuch_message_get_replies (message),
+ next_indent,
+ params);
+ else {
+ fputs (format->message_set_start, stdout);
+ fputs (format->message_set_end, stdout);
+ }
notmuch_message_destroy (message);
@@ -937,6 +942,50 @@ show_messages (void *ctx,
fputs (format->message_set_end, stdout);
}
+static int
+do_show_messages (void *ctx,
+ notmuch_query_t *query,
+ const notmuch_show_format_t *format,
+ notmuch_show_params_t *params)
+{
+ notmuch_messages_t *messages;
+ notmuch_message_t *message;
+ int first_set = 1;
+
+ fputs (format->message_set_start, stdout);
+ messages = notmuch_query_search_messages (query);
+
+ for (;
+ notmuch_messages_valid (messages);
+ notmuch_messages_move_to_next (messages))
+ {
+ if (!first_set)
+ fputs (format->message_set_sep, stdout);
+ first_set = 0;
+
+ fputs (format->message_set_start, stdout);
+ fputs (format->message_set_start, stdout);
+
+ message = notmuch_messages_get (messages);
+ notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1);
+ show_message (ctx, format, message, 0, params);
+
+ fputs (format->message_set_sep, stdout);
+
+ fputs (format->message_set_start, stdout);
+ fputs (format->message_set_end, stdout);
+
+
+ notmuch_message_destroy (message);
+
+ fputs (format->message_set_end, stdout);
+ fputs (format->message_set_end, stdout);
+ }
+
+ fputs (format->message_set_end, stdout);
+ return 0;
+}
+
/* Formatted output of single message */
static int
do_show_single (void *ctx,
@@ -1064,11 +1113,13 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
notmuch_database_t *notmuch;
notmuch_query_t *query;
char *query_string;
- int opt_index, ret;
+ int opt_index, ret, entire_thread;
+ notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST;
const notmuch_show_format_t *format = &format_text;
notmuch_show_params_t params = { .part = -1 };
int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
notmuch_bool_t verify = FALSE;
+ notmuch_bool_t headers_only = FALSE;
notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -1077,10 +1128,19 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
{ "mbox", NOTMUCH_FORMAT_MBOX },
{ "raw", NOTMUCH_FORMAT_RAW },
{ 0, 0 } } },
+ { NOTMUCH_OPT_KEYWORD, &sort, "sort", 's',
+ (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
+ { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+ { 0, 0 } } },
{ NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 },
- { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },
+ { NOTMUCH_OPT_KEYWORD, &entire_thread, "thread", 't',
+ (notmuch_keyword_t []){ { "match", NOTMUCH_SHOW_THREAD_MATCH, },
+ { "entire", NOTMUCH_SHOW_THREAD_ENTIRE },
+ { "none", NOTMUCH_SHOW_THREAD_NONE },
+ { 0, 0 } } },
{ NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
+ { NOTMUCH_OPT_BOOLEAN, &headers_only, "headers-only", 'h', 0 },
{ 0, 0, 0, 0, 0 }
};
@@ -1090,6 +1150,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
return 1;
}
+ params.entire_thread = entire_thread;
+ params.headers_only = headers_only;
+
if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
/* if part was requested and format was not specified, use format=raw */
if (params.part >= 0)
@@ -1101,7 +1164,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
switch (format_sel) {
case NOTMUCH_FORMAT_JSON:
format = &format_json;
- params.entire_thread = TRUE;
+ if (!params.entire_thread) params.entire_thread = NOTMUCH_SHOW_THREAD_ENTIRE;
+ // params.entire_thread = 1;
+
break;
case NOTMUCH_FORMAT_TEXT:
format = &format_text;
@@ -1168,10 +1233,15 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
return 1;
}
+ notmuch_query_set_sort (query, sort);
+
if (params.part >= 0)
ret = do_show_single (ctx, query, format, ¶ms);
else
- ret = do_show (ctx, query, format, ¶ms);
+ if (params.entire_thread == NOTMUCH_SHOW_THREAD_NONE)
+ ret = do_show_messages (ctx, query, format, ¶ms);
+ else
+ ret = do_show (ctx, query, format, ¶ms);
notmuch_query_destroy (query);
notmuch_database_close (notmuch);
--
1.7.2.3
next prev parent reply other threads:[~2012-02-12 10:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-12 10:32 RFC notmuch-pick: an emacs threaded message view with split-pane Mark Walters
2012-02-12 10:36 ` Mark Walters [this message]
2012-02-12 10:36 ` [RFC PATCH 2/3] emacs: changes to other files to support notmuch-pick Mark Walters
2012-02-12 10:36 ` [RFC PATCH 3/3] emacs: add notmuch-pick itself Mark Walters
[not found] ` <87ehu0cf16.fsf@schoepe.localhost>
2012-02-12 14:31 ` RFC notmuch-pick: an emacs threaded message view with split-pane Daniel Schoepe
2012-02-12 14:47 ` [PATCH 0/1] emacs: Make highlight-faces for pick configurable Daniel Schoepe
2012-02-12 14:47 ` [PATCH] " Daniel Schoepe
2012-02-12 15:50 ` Mark Walters
2012-02-12 20:46 ` RFC notmuch-pick: an emacs threaded message view with split-pane Jameson Graef Rollins
2012-02-12 20:59 ` Daniel Schoepe
2012-02-12 21:43 ` Mark Walters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329042965-3871-1-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).