Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 94FE6429E40 for ; Sat, 10 Jan 2015 04:03:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 2.438 X-Spam-Level: ** X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MQj2DtBuq5Xt for ; Sat, 10 Jan 2015 04:03:38 -0800 (PST) Received: from smtp.webfaction.com (mail6.webfaction.com [74.55.86.74]) by olra.theworths.org (Postfix) with ESMTP id D6197429E4B for ; Sat, 10 Jan 2015 04:03:37 -0800 (PST) Received: from localhost (87-231-242-54.rev.numericable.fr [87.231.242.54]) by smtp.webfaction.com (Postfix) with ESMTP id D66B22078836; Sat, 10 Jan 2015 12:03:35 +0000 (UTC) From: Bartosz To: notmuch@notmuchmail.org Subject: [PATCH 4/4] VIM: adding attachments Date: Sat, 10 Jan 2015 13:03:04 +0100 Message-Id: <1420891384-992-5-git-send-email-telenczuk@unic.cnrs-gif.fr> X-Mailer: git-send-email 1.9.3 (Apple Git-50) In-Reply-To: <1420891384-992-1-git-send-email-telenczuk@unic.cnrs-gif.fr> References: <1420891384-992-1-git-send-email-telenczuk@unic.cnrs-gif.fr> X-Mailman-Approved-At: Sat, 10 Jan 2015 10:22:24 -0800 Cc: Bartosz X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2015 12:03:41 -0000 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)