mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
CLI/reply: support --duplicate argument
We want the reply used to match that shown e.g. in the emacs interface. As a first step provide that functionality on the command line. Schema does not need updating as the duplicate key was already present (with a constant value of 1).
This commit is contained in:
parent
5ea5a5557d
commit
24decfc1dd
4 changed files with 47 additions and 3 deletions
|
@ -38,6 +38,12 @@ Supported options for **reply** include
|
||||||
|
|
||||||
.. program:: reply
|
.. program:: reply
|
||||||
|
|
||||||
|
.. option:: --duplicate=N
|
||||||
|
|
||||||
|
Reply to duplicate number N. The numbering starts from 1, and
|
||||||
|
matches the order used by :option:`show --duplicate` and
|
||||||
|
:option:`search --output=files <search --output>`.
|
||||||
|
|
||||||
.. option:: --format=(default|json|sexp|headers-only)
|
.. option:: --format=(default|json|sexp|headers-only)
|
||||||
|
|
||||||
default
|
default
|
||||||
|
|
|
@ -555,7 +555,7 @@ message at DEPTH in the current thread."
|
||||||
(if (> file-count 1)
|
(if (> file-count 1)
|
||||||
(let ((txt (format "%d/%d\n" duplicate file-count)))
|
(let ((txt (format "%d/%d\n" duplicate file-count)))
|
||||||
(concat
|
(concat
|
||||||
(notmuch-show-spaces-n (- (window-width) (+ (current-column) (length txt))))
|
(notmuch-show-spaces-n (max 0 (- (window-width) (+ (current-column) (length txt)))))
|
||||||
txt))
|
txt))
|
||||||
"\n"))
|
"\n"))
|
||||||
(overlay-put (make-overlay start (point))
|
(overlay-put (make-overlay start (point))
|
||||||
|
|
|
@ -663,7 +663,7 @@ do_reply (notmuch_database_t *notmuch,
|
||||||
notmuch_messages_move_to_next (messages)) {
|
notmuch_messages_move_to_next (messages)) {
|
||||||
message = notmuch_messages_get (messages);
|
message = notmuch_messages_get (messages);
|
||||||
|
|
||||||
if (mime_node_open (notmuch, message, -1, ¶ms->crypto, &node))
|
if (mime_node_open (notmuch, message, params->duplicate, ¶ms->crypto, &node))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
reply = create_reply_message (notmuch, message,
|
reply = create_reply_message (notmuch, message,
|
||||||
|
@ -683,7 +683,7 @@ do_reply (notmuch_database_t *notmuch,
|
||||||
|
|
||||||
/* Start the original */
|
/* Start the original */
|
||||||
sp->map_key (sp, "original");
|
sp->map_key (sp, "original");
|
||||||
format_part_sprinter (notmuch, sp, node, -1, true, false);
|
format_part_sprinter (notmuch, sp, node, params->duplicate, true, false);
|
||||||
|
|
||||||
/* End */
|
/* End */
|
||||||
sp->end (sp);
|
sp->end (sp);
|
||||||
|
@ -715,6 +715,7 @@ notmuch_reply_command (notmuch_database_t *notmuch, int argc, char *argv[])
|
||||||
int opt_index;
|
int opt_index;
|
||||||
notmuch_show_params_t params = {
|
notmuch_show_params_t params = {
|
||||||
.part = -1,
|
.part = -1,
|
||||||
|
.duplicate = 0,
|
||||||
.crypto = { .decrypt = NOTMUCH_DECRYPT_AUTO },
|
.crypto = { .decrypt = NOTMUCH_DECRYPT_AUTO },
|
||||||
};
|
};
|
||||||
int format = FORMAT_DEFAULT;
|
int format = FORMAT_DEFAULT;
|
||||||
|
@ -739,6 +740,7 @@ notmuch_reply_command (notmuch_database_t *notmuch, int argc, char *argv[])
|
||||||
{ "auto", NOTMUCH_DECRYPT_AUTO },
|
{ "auto", NOTMUCH_DECRYPT_AUTO },
|
||||||
{ "true", NOTMUCH_DECRYPT_NOSTASH },
|
{ "true", NOTMUCH_DECRYPT_NOSTASH },
|
||||||
{ 0, 0 } } },
|
{ 0, 0 } } },
|
||||||
|
{ .opt_int = ¶ms.duplicate, .name = "duplicate" },
|
||||||
{ .opt_inherit = notmuch_shared_options },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
|
@ -353,4 +353,40 @@ On Thu, 16 Jun 2016 22:14:41 -0400, Alice <alice@example.org> wrote:
|
||||||
> Note the Cc: and cc: headers.
|
> Note the Cc: and cc: headers.
|
||||||
OK"
|
OK"
|
||||||
|
|
||||||
|
add_email_corpus duplicate
|
||||||
|
|
||||||
|
ID1=debian/2.6.1.dfsg-4-1-g87ea161@87ea161e851dfb1ea324af00e4ecfccc18875e15
|
||||||
|
|
||||||
|
test_begin_subtest "format json, --duplicate=2, duplicate key"
|
||||||
|
output=$(notmuch reply --format=json --duplicate=2 id:${ID1})
|
||||||
|
test_json_nodes <<<"$output" "dup:['original']['duplicate']=2"
|
||||||
|
|
||||||
|
test_begin_subtest "format json, subject, --duplicate=1"
|
||||||
|
output=$(notmuch reply --format=json --duplicate=1 id:${ID1})
|
||||||
|
file=$(notmuch search --output=files id:${ID1} | head -n 1)
|
||||||
|
subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
|
||||||
|
test_json_nodes <<<"$output" "subject:['reply-headers']['Subject']=\"Re: $subject\""
|
||||||
|
|
||||||
|
test_begin_subtest "format json, subject, --duplicate=2"
|
||||||
|
output=$(notmuch reply --format=json --duplicate=2 id:${ID1})
|
||||||
|
file=$(notmuch search --output=files id:${ID1} | tail -n 1)
|
||||||
|
subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
|
||||||
|
test_json_nodes <<<"$output" "subject:['reply-headers']['Subject']=\"Re: $subject\""
|
||||||
|
|
||||||
|
ID2=87r2geywh9.fsf@tethera.net
|
||||||
|
for dup in {1..2}; do
|
||||||
|
test_begin_subtest "format json, body, --duplicate=${dup}"
|
||||||
|
output=$(notmuch reply --format=json --duplicate=${dup} id:${ID2} | \
|
||||||
|
$NOTMUCH_PYTHON -B "$NOTMUCH_SRCDIR"/test/json_check_nodes.py "body:['original']['body'][0]['content']" | \
|
||||||
|
grep '^# body')
|
||||||
|
test_expect_equal "$output" "# body ${dup}"
|
||||||
|
done
|
||||||
|
|
||||||
|
ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
|
||||||
|
for dup in {1..5}; do
|
||||||
|
test_begin_subtest "format json, --duplicate=${dup}, 'duplicate' key"
|
||||||
|
output=$(notmuch reply --format=json --duplicate=${dup} id:${ID3})
|
||||||
|
test_json_nodes <<<"$output" "dup:['original']['duplicate']=${dup}"
|
||||||
|
done
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue