files to be attached are listed at the end of composed message as paths prefixed by "Attachment:" --- vim/notmuch.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vim/notmuch.vim b/vim/notmuch.vim index e95db4d..d999aef 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -92,9 +92,16 @@ function! s:compose_send() ruby << EOF # Generate proper mail to send - text = VIM::evaluate('lines').join("\n") - fname = VIM::evaluate('fname') + text = VIM::evaluate('lines') + attached_filenames = text.reverse.take_while { |line| line.start_with?("Attachment:") } + text = text.reverse.drop_while { |line| line.start_with?("Attachment:") } . reverse + text = text.join("\n") transport = Mail.new(text) + attached_filenames.each do |afname| + transport.add_file(afname[11..-1].strip) + end + + fname = VIM::evaluate('fname') transport.message_id = generate_message_id transport.charset = 'utf-8' File.write(fname, transport.to_s) -- 1.9.3 (Apple Git-50)