user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/2] filter/rubylang: reuse altid entry from inbox object
Date: Thu, 22 Jun 2017 22:02:10 +0000	[thread overview]
Message-ID: <20170622220211.8956-1-e@80x24.org> (raw)
In-Reply-To: <20170622071136.GA8242@dcvr>

This allows users to DRY up their config a bit and avoid
specifying altid twice when reusing the NNTP-centric msgmap
for [ruby-*:\d+] serial numbers.

My current work-in-progress ~/.public-inbox/config entry
for the ruby-core list is:

------8<-------
[publicinbox "ruby-core"]
	address = ruby-core@ruby-lang.org
	url = //public-inbox.org/ruby-core
	mainrepo = /path/to/ruby-core.git
	newsgroup = inbox.comp.lang.ruby.core
	watchheader = List-Id:<ruby-core.ruby-lang.org>
	altid = serial:ruby-core:file=msgmap.sqlite3
	watch = maildir:/path/to/Maildir/.INBOX.ruby
	filter = PublicInbox::Filter::RubyLang
---
 lib/PublicInbox/Filter/RubyLang.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Filter/RubyLang.pm b/lib/PublicInbox/Filter/RubyLang.pm
index ec4bc32..5240e8d 100644
--- a/lib/PublicInbox/Filter/RubyLang.pm
+++ b/lib/PublicInbox/Filter/RubyLang.pm
@@ -15,10 +15,13 @@ sub new {
 	my ($class, %opts) = @_;
 	my $altid = delete $opts{-altid};
 	my $self = $class->SUPER::new(%opts);
+	my $ibx = $self->{-inbox};
 	# altid = serial:ruby-core:file=msgmap.sqlite3
+	if (!$altid && $ibx && $ibx->{altid}) {
+		$altid ||= $ibx->{altid}->[0];
+	}
 	if ($altid) {
 		require PublicInbox::MID; # mid_clean
-		my $ibx = $self->{-inbox};
 		require PublicInbox::AltId;
 		$self->{-altid} = PublicInbox::AltId->new($ibx, $altid, 1);
 	}
-- 
EW


  reply	other threads:[~2017-06-22 22:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 23:33 [REJECT] add filter for RubyLang lists Eric Wong
2017-06-22  0:31 ` Eric Wong
2017-06-22  7:11 ` [PATCH v2] " Eric Wong
2017-06-22 22:02   ` Eric Wong [this message]
2017-06-22 22:02     ` [PATCH 2/2] test for PublicInbox::Filter::RubyLang Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170622220211.8956-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).