X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fnotmuch.vim;fp=vim%2Fnotmuch.vim;h=331e9300842b1ef62f0cc62baacdaf64da7ffe46;hp=0cb94f6c93b542812b0b3942ae77f1ee710c2e5c;hb=cc8c213bbc9572fa96c1b384225b69136a3fd0e4;hpb=468deca60c062b6b3085ff1de41647f41cd6abd1 diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 0cb94f6c..331e9300 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -86,17 +86,22 @@ endfunction function! s:compose_send() let b:compose_done = 1 let fname = expand('%') + let lines = getline(5, '$') - " remove headers - 0,4d - write +ruby << EOF + # Generate proper mail to send + text = VIM::evaluate('lines').join("\n") + fname = VIM::evaluate('fname') + transport = Mail.new(text) + transport.message_id = generate_message_id + transport.charset = 'utf-8' + File.write(fname, transport.to_s) +EOF let cmdtxt = g:notmuch_sendmail . ' -t -f ' . s:reply_from . ' < ' . fname let out = system(cmdtxt) let err = v:shell_error if err - undo - write echohl Error echo 'Eeek! unable to send mail' echo out @@ -572,9 +577,7 @@ ruby << EOF end m.cc = orig[:cc] m.from = $email - m.message_id = generate_message_id m.charset = 'utf-8' - m.content_transfer_encoding = '7bit' end lines = [] @@ -600,7 +603,7 @@ ruby << EOF reply.body = body_lines.join("\n") - lines += reply.to_s.lines.map { |e| e.chomp } + lines += reply.present.lines.map { |e| e.chomp } lines << "" cur = lines.count - 1 @@ -611,18 +614,13 @@ ruby << EOF def open_compose() lines = [] - lines << "Date: #{Time.now().strftime('%a, %-d %b %Y %T %z')}" lines << "From: #{$email}" lines << "To: " cur = lines.count lines << "Cc: " lines << "Bcc: " - lines << "Message-Id: #{generate_message_id}" lines << "Subject: " - lines << "Mime-Version: 1.0" - lines << "Content-Type: text/plain; charset=utf-8" - lines << "Content-Transfer-Encoding: 7bit" lines << "" lines << "" lines << "" @@ -928,6 +926,16 @@ ruby << EOF end text end + + def present + buffer = '' + header.fields.each do |f| + buffer << "%s: %s\r\n" % [f.name, f.to_s] + end + buffer << "\r\n" + buffer << body.to_s + buffer + end end end