X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=contrib%2Fnotmuch-mutt%2Fnotmuch-mutt;h=00c5ef82d50d67d0fcac7c43794dcf6958ac3cb1;hp=d14709df6eb3bccdd054a18f0ffa1cc984167d00;hb=c34effad9a65c2f2c6d4d25c508c201bad7a07f6;hpb=fffb92da8e09bb2fed63dc565e6ab7fa9b44d2f9 diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt index d14709df..00c5ef82 100755 --- a/contrib/notmuch-mutt/notmuch-mutt +++ b/contrib/notmuch-mutt/notmuch-mutt @@ -121,7 +121,8 @@ sub prompt($$) { sub get_message_id() { my $mail = Mail::Internet->new(\*STDIN); - $mail->head->get("message-id") =~ /^<(.*)>$/; # get message-id + my $mid = $mail->head->get("message-id") or return undef; + $mid =~ /^<(.*)>$/; # get message-id value return $1; } @@ -142,6 +143,10 @@ sub thread_action($$@) { my ($results_dir, $remove_dups, @params) = @_; my $mid = get_message_id(); + if (! defined $mid) { + empty_maildir($results_dir); + die "notmuch-mutt: cannot find Message-Id, abort.\n"; + } my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid"); my $tid = `$search_cmd`; # get thread id chomp($tid); @@ -151,6 +156,7 @@ sub thread_action($$@) { sub tag_action(@) { my $mid = get_message_id(); + defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n"; system("notmuch tag " . shell_quote(join(' ', @_)) @@ -264,13 +270,23 @@ the following in your Mutt configuration (usually one of: F<~/.muttrc>, F, or a configuration snippet under F): macro index \ - "unset wait_keynotmuch-mutt -r --prompt search~/.cache/notmuch/mutt/results" \ + "set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ + notmuch-mutt -r --prompt search\ + `echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`\ + set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ "notmuch: search mail" + macro index \ - "unset wait_keynotmuch-mutt -r thread~/.cache/notmuch/mutt/resultsset wait_key" \ + "set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ + notmuch-mutt -r thread\ + `echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`\ + set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ "notmuch: reconstruct thread" + macro index \ - "unset wait_keynotmuch-mutt tag -- -inbox" \ + "set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key\ + notmuch-mutt tag -- -inbox\ + set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key" \ "notmuch: remove message from inbox" The first macro (activated by ) prompts the user for notmuch search terms