From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0r.migadu.com with LMTPS id MDCvBO1DjWB6YwEALuJCtg (envelope-from ) for ; Sat, 01 May 2021 14:05:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id SMBbAO1DjWCidAAAbx9fmQ (envelope-from ) for ; Sat, 01 May 2021 12:05:01 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 76A99110C3 for ; Sat, 1 May 2021 14:05:00 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 81E26271EA; Sat, 1 May 2021 08:04:57 -0400 (EDT) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by mail.notmuchmail.org (Postfix) with ESMTPS id 6D3CD2717A for ; Sat, 1 May 2021 08:04:52 -0400 (EDT) Received: by mail-oi1-x22c.google.com with SMTP id n184so806676oia.12 for ; Sat, 01 May 2021 05:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SXOfpbQhNHA0dd1SQ6y38JmMysqHRJgJpioSdHhaV3c=; b=coI/zlT3gU9JDE7NBtwlgH4ssDC+wYhDA42mPcyXOf6cr4kkCirDIWzhnLSAjlEot3 4WO3+a/ePkJ8ZSVM0ZNwwvyj3vVuvpexKeODnZvYFHyIVjsQrBDAKDbLR6NTGQQWBsPD rI9+pA3k0rPBk9YoSYLIelESBagA/oheqdxesOTwZnljzGClzuT8TaonepvoSNu0qGvK 0So7ROg3Rs3ux0/R+2M7VNdoJfNY8fxWQNwK09mxW8syMn0ARKKpIKBae6s6O2GjeL70 BCaRV0bBIJiQZ77/h0GXZPwQaH2wkOZSZSc+XREc1E2TDyTMsUHTU4tVMvLSQqxQfefV HnmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SXOfpbQhNHA0dd1SQ6y38JmMysqHRJgJpioSdHhaV3c=; b=c2kZN65JJalgOZcFaillhj/yoqPd4zT0riOJ+th+/d0chD0+5DFtFYn4hRxmxIyfHK caew+dSdzddXYm+lEv5USBJvAHmM/gRiqyY0P/zjJVgAW2A5DunhV7VTQ5XTDmrqUlS7 FtfUW2IQYKXblR8conar7l5lJdSP2u3/abHf+YpF2H42Bm9+3lozup5wLL+oqyn90bJF mYSGiS78+PXcrG2qdOTzvHRguCwmzZBj8f0+hLx6Gwu+vnC1GZiJbkS4HHMJR7uDDN9P eMSk1Qqz681tGxACaB50AarLBSzyfE8oPX7+dky7VCY8dvbhk5GPMwwxH58g2zmRFovc EnsA== X-Gm-Message-State: AOAM530ZKXUE4zDlVbdQIxu9SXa5CkVbWbzPXjS6nUq2d/DCo+P2xMQM gK4UGWWuDqLrpD7CxRiyLxn4V8Fm6jc1Ag== X-Google-Smtp-Source: ABdhPJzKyEzYIEV599Opl4uh0/1tT01wSp2gQdgQQc159ocCuRqEACSaWDR1qbGKZE8dtJ9GyhHy+w== X-Received: by 2002:aca:a814:: with SMTP id r20mr7432650oie.104.1619870691700; Sat, 01 May 2021 05:04:51 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id j7sm1451887otk.65.2021.05.01.05.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 05:04:51 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH 1/3] ruby: use notmuch_exclude_t enum Date: Sat, 1 May 2021 07:04:46 -0500 Message-Id: <20210501120448.484082-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210501120448.484082-1-felipe.contreras@gmail.com> References: <20210501120448.484082-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Message-ID-Hash: YAA5PVJ4MKBUTW2KZTBYNLDXFPOXO5JZ X-Message-ID-Hash: YAA5PVJ4MKBUTW2KZTBYNLDXFPOXO5JZ X-MailFrom: felipe.contreras@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Ludovic LANGE , Stefano Zacchiroli X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619870700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=tENS6ci5ph/RxM1emqKMJu9p2ulVgwnHur5wJz2wnng=; b=RlkzyonwlgIBhXLeMTZ9Z2t6U2SAu/+KVsyu4+0P7ZoOTC/ha9Ylb59fQsWoJi/SDocHyy nwu9TdtLUxdKuyhGZwFpR9Y9a8dUIMtMVkpVlUJz5Mck88BtbZWq0H1mhAjdiI8jyUCMB9 iRhZTFRCuDY+PaGd+0yK87TGzwjzpA0PogMDGrymkzMqCjuV8q8whsaJvIQZ/5aZvKDasW y1I5WP18s0NkasI0L6jNLsrXKT5nZhzygw1b5qLclPNgvgeLuYjODanDgQ9b1asfxO9Tls T83+K+b9OQU20O0tdaw4kvLyjMOGtzPKdkDMVglfC7cJJHyxgxvtChCV0Fsmlg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619870700; a=rsa-sha256; cv=none; b=qhaFkv3TolfwyoGZHZ66kJWZsrameS+XLKNA/W+QBYmbILPzeeqEX4wqL66q79AX9eHf7p DnAi4qjsSO6Pe1UEZp4E8e50nIhWqja/YXkArafRQEdcmQjQXsVEUQThR184FTJyz5A0dM tB6sPoyj6vQudmSAtFC0XVum1ZriCcFD0I5auAeOKesb5KsWv/RznprUog5gxaPyBT7kvQ y2ljEIHN7ZWt2nIiIgvSWoHxJg5S/FKLmtGNNcgR91mtwv3Rnn+Zz9ou1LfG7E4So5ew9W k8FmcOaT6E5r87rvon3/ElGLwfTN+saxu4Wm2Y947LPUpQrUSYzQnvbBy2Nxiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b="coI/zlT3"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b="coI/zlT3"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 76A99110C3 X-Spam-Score: -1.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: yZasAFavrbCj It exists since 2013, let's allow it to be used in Ruby. Signed-off-by: Felipe Contreras --- bindings/ruby/init.c | 24 ++++++++++++++++++++++++ bindings/ruby/query.c | 8 +++++--- test/T395-ruby.sh | 17 +++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index 819fd1e3..fd73ed8f 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -133,6 +133,30 @@ Init_notmuch (void) * Maximum allowed length of a tag */ rb_define_const (mod, "TAG_MAX", INT2FIX (NOTMUCH_TAG_MAX)); + /* + * Document-const: Notmuch::EXCLUDE_FLAG + * + * Only flag excluded results + */ + rb_define_const (mod, "EXCLUDE_FLAG", INT2FIX (NOTMUCH_EXCLUDE_FLAG)); + /* + * Document-const: Notmuch::EXCLUDE_TRUE + * + * Exclude messages from the results + */ + rb_define_const (mod, "EXCLUDE_TRUE", INT2FIX (NOTMUCH_EXCLUDE_TRUE)); + /* + * Document-const: Notmuch::EXCLUDE_FALSE + * + * Don't exclude anything + */ + rb_define_const (mod, "EXCLUDE_FALSE", INT2FIX (NOTMUCH_EXCLUDE_FALSE)); + /* + * Document-const: Notmuch::EXCLUDE_ALL + * + * Exclude all results + */ + rb_define_const (mod, "EXCLUDE_ALL", INT2FIX (NOTMUCH_EXCLUDE_ALL)); /* * Document-class: Notmuch::BaseError diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 8b46d700..99148c36 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -107,19 +107,21 @@ notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv) } /* - * call-seq: QUERY.omit_excluded=(boolean) => nil + * call-seq: QUERY.omit_excluded=(fixnum) => nil * * Specify whether to omit excluded results or simply flag them. - * By default, this is set to +true+. + * By default, this is set to +Notmuch::EXCLUDE_TRUE+. */ VALUE notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv) { notmuch_query_t *query; + notmuch_exclude_t value; Data_Get_Notmuch_Query (self, query); - notmuch_query_set_omit_excluded (query, RTEST (omitv)); + value = FIXNUM_P (omitv) ? FIX2UINT (omitv) : RTEST(omitv); + notmuch_query_set_omit_excluded (query, value); return Qnil; } diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh index 597330d3..d36d4aff 100755 --- a/test/T395-ruby.sh +++ b/test/T395-ruby.sh @@ -65,4 +65,21 @@ db.all_tags.each do |tag| end EOF +notmuch config set search.exclude_tags deleted +generate_message '[subject]="Good"' +generate_message '[subject]="Bad"' "[in-reply-to]=\<$gen_msg_id\>" +notmuch new > /dev/null +notmuch tag +deleted id:$gen_msg_id + +test_begin_subtest "omit excluded all" +notmuch search --output=threads --exclude=all tag:inbox > EXPECTED +test_ruby <<"EOF" +q = db.query('tag:inbox') +q.add_tag_exclude('deleted') +q.omit_excluded = Notmuch::EXCLUDE_ALL +q.search_threads.each do |t| + puts 'thread:%s' % t.thread_id +end +EOF + test_done -- 2.31.0