~jonjfineman/cli-mail

013ab2b07e8d0d4170177050c742ab64798c83c0 — Jon Fineman 2 years ago 71b7faa master
misc
1 files changed, 61 insertions(+), 1 deletions(-)

M cli-mail.pl
M cli-mail.pl => cli-mail.pl +61 -1
@@ 27,6 27,7 @@ sub get_headers
    my $cmd = "" ;

    # first get thread ids we are interested in
    # returns list of threads in the form of thread:xxx \n thread:yyy
    $cmd = "notmuch search --output=threads folder:$folder" ;
    my $search_threads = `$cmd` ;



@@ 34,7 35,22 @@ sub get_headers
    # to notmuch search
    $search_threads =~ s$\n$ $g ;

    my $i = 0 ;
    foreach my $msg (split / /, $search_threads)
    {
        $cmd = "notmuch search --output=messages --sort=oldest-first $msg" ;
        my $msg_ret = `$cmd` ;
        if ($i le 30)
        {
            print "$msg\n" ;
            print "$msg_ret\n" ;
        }
        $i++
    }
    # get msg info for each thread id
    # returns list of thread:xxx date [part count] from; subject (flags)
    # ? change this to return msg id and search for msg id instead
    # indent two spaces 2nd array element through n if exist
    $cmd = "notmuch search $search_threads" ;
    my $folder_view_msg = `$cmd` ;
    # remove thread id from output


@@ 47,6 63,21 @@ sub get_headers



sub get_message_ids_for_thread
{
    my $search_thread = shift(@_) ;
    my $cmd = "" ;

    # get ids for thread id
    $cmd = "notmuch search --output=messages --sort=oldest-first $search_thread" ;
    my $ids_in_thread = `$cmd` ;
    #my @ids = split /\n/, $ids_in_thread ;

    return ( $ids_in_thread ) ;
}



sub show_msg
{
    my $msg_thread_id = shift(@_) ;


@@ 213,6 244,7 @@ my $msg_no = -1 ;
my @threads = ( ) ;
my @headers = ( ) ;
my $pager = "less" ;
my $expand_threads = 1 ;

my $input = "" ;
my $action = "" ;


@@ 483,7 515,7 @@ while($input = <>)
            }

            print "a for all\n" ;
            print "> " ;
            print ">> " ;
            my $answer = <STDIN> ;
            chomp $answer ;
            $msg_part = $answer ;


@@ 615,6 647,34 @@ while($input = <>)
    }

    #
    # show message ids in msg #
    #
    elsif ($action eq "show-ids")
    {
        if ( $#args >= 1 )
        {
            $msg_no = $args[1] ;
        }
        elsif ($msg_no == -1)
        {
            print "select msg no\n" ;
            print("> ") ;
            next ;
        }

        if ( $msg_no > $#threads )
        {
            print "msg out of range\n" ;
        }
        else
        {
            my $thread_ids = get_message_ids_for_thread ( $threads[$msg_no] ) ;
            #change_msg_status ( $threads[$msg_no], "-unread" ) ;
            print "$thread_ids\n" ;
        }
    }

    #
    # reply all msg #
    #
    elsif ($action eq "r")