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 16FF6429E26 for ; Fri, 24 Jun 2011 16:26:59 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 XIzE-ZhFdieX for ; Fri, 24 Jun 2011 16:26:58 -0700 (PDT) Received: from mail-iw0-f181.google.com (mail-iw0-f181.google.com [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 771CF429E25 for ; Fri, 24 Jun 2011 16:26:58 -0700 (PDT) Received: by iwn37 with SMTP id 37so3145830iwn.26 for ; Fri, 24 Jun 2011 16:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:user-agent:date:message-id :mime-version:content-type; bh=XleEkWu9mwomieay0zl8/4DmCvvK/oIWbMT9M5ZJo24=; b=qf7WsuIyuvR+KxT9dvzC/q58QWnUtYHP/xHQQyUjDRDTvXraJXClPFBcZ+qUgQMOKh IcQbpXoZybk8WydWv9u9kVFJ6cEvvEWOLOjjOxiCeSIG95hurRuY0x7IXerJi8DI5EDM raRlu1cqFsUlrfEBdXulEmZeJYdUPA5PzOvDM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; b=mEfxWfYfGKvn6oeD5thspH+aySLoOQWVbvzzMKwFjZWdXb6oZ7dTfzOwL5s3EWZJJ4 Ku0RdEMOGz/XjGh/5qhWoVzs4ShEjyf9ayJQvXfHWUxpqaCTWpwDvprhQSRTpk7eJ6aC kgcJ3w0ZbMBBReryLriKN4pcyIJmj2icNBgKk= Received: by 10.42.147.201 with SMTP id o9mr3959903icv.412.1308958017281; Fri, 24 Jun 2011 16:26:57 -0700 (PDT) Received: from localhost ([74.205.145.146]) by mx.google.com with ESMTPS id y1sm3044316ica.4.2011.06.24.16.26.56 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 16:26:56 -0700 (PDT) From: Mark Anderson To: notmuch@notmuchmail.org Subject: [PATCH 2/2] search --output=files: Output all filenames for each matching message User-Agent: Notmuch/0.5-283-gb744eac (http://notmuchmail.org) Emacs/23.2.1 (i686-pc-linux-gnu) Date: Fri, 24 Jun 2011 17:26:55 -0600 Message-ID: <878vsqdd4w.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Fri, 24 Jun 2011 23:26:59 -0000 Messages in the database can have multiple files associated with a single message-id, but until now only one filename for each message has been reported by "notmuch search --output=files" Signed-off-by: Mark Anderson --- Perhaps someone can offer a little help making the "separator" code tighter, but this works. notmuch-search.c | 29 ++++++++++++++++++++++------- 1 files changed, 22 insertions(+), 7 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 616fe68..faccaf7 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -275,6 +275,7 @@ do_search_messages (const search_format_t *format, { notmuch_message_t *message; notmuch_messages_t *messages; + notmuch_filenames_t *filenames; int first_message = 1; messages = notmuch_query_search_messages (query); @@ -289,19 +290,33 @@ do_search_messages (const search_format_t *format, { message = notmuch_messages_get (messages); - if (! first_message) - fputs (format->item_sep, stdout); - if (output == OUTPUT_FILES) { - format->item_id (message, "", - notmuch_message_get_filename (message)); + filenames = notmuch_message_get_filenames (message); + + for (; + notmuch_filenames_valid (filenames); + notmuch_filenames_move_to_next (filenames)) + { + if (! first_message) + fputs (format->item_sep, stdout); + + format->item_id (message, "", + notmuch_filenames_get (filenames)); + + first_message = 0; + } + + notmuch_filenames_destroy( filenames ); + } else { /* output == OUTPUT_MESSAGES */ + if (! first_message) + fputs (format->item_sep, stdout); + format->item_id (message, "id:", notmuch_message_get_message_id (message)); + first_message = 0; } - first_message = 0; - notmuch_message_destroy (message); } -- 1.7.4.1