user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/2] lei {edit,forget}-search
@ 2021-04-20  7:16 Eric Wong
  2021-04-20  7:16 ` [PATCH 1/2] lei forget-search: new command to forget saved searches Eric Wong
  2021-04-20  7:16 ` [PATCH 2/2] lei edit-search: command to tweak search parameters Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2021-04-20  7:16 UTC (permalink / raw)
  To: meta

Some convenience commands, since I expect users will want to
tweak and experiment with things.

I don't think "mv-search" (formerly "mv-query") is necessary
since it's easy enough to use "lei convert" (testing anything
requiring authentication is not fun nor easily automated, atm).

Eric Wong (2):
  lei forget-search: new command to forget saved searches
  lei edit-search: command to tweak search parameters

 MANIFEST                           |  2 ++
 lib/PublicInbox/LEI.pm             |  6 ++++--
 lib/PublicInbox/LeiEditSearch.pm   | 25 +++++++++++++++++++++++
 lib/PublicInbox/LeiForgetSearch.pm | 32 ++++++++++++++++++++++++++++++
 t/lei-q-save.t                     | 11 ++++++++++
 5 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 lib/PublicInbox/LeiEditSearch.pm
 create mode 100644 lib/PublicInbox/LeiForgetSearch.pm

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] lei forget-search: new command to forget saved searches
  2021-04-20  7:16 [PATCH 0/2] lei {edit,forget}-search Eric Wong
@ 2021-04-20  7:16 ` Eric Wong
  2021-04-20  7:16 ` [PATCH 2/2] lei edit-search: command to tweak search parameters Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-04-20  7:16 UTC (permalink / raw)
  To: meta

Readers may lose interest in subscription topics.  This lets
them avoid clutter by forgetting a saved search.

This does not and will not destroy the contents of an --output
mailbox.  In other words, this is similar to unsubscribing
from an Atom/RSS feed or NNTP group.

I've also decided we won't support 'mv-search', since it'll
probably be rarely used and "lei convert" can be used, instead.
---
 MANIFEST                           |  1 +
 lib/PublicInbox/LEI.pm             |  4 ++--
 lib/PublicInbox/LeiForgetSearch.pm | 32 ++++++++++++++++++++++++++++++
 t/lei-q-save.t                     | 11 ++++++++++
 4 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 lib/PublicInbox/LeiForgetSearch.pm

diff --git a/MANIFEST b/MANIFEST
index f35c514c..d4055af4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -191,6 +191,7 @@ lib/PublicInbox/LeiConvert.pm
 lib/PublicInbox/LeiCurl.pm
 lib/PublicInbox/LeiDedupe.pm
 lib/PublicInbox/LeiExternal.pm
+lib/PublicInbox/LeiForgetSearch.pm
 lib/PublicInbox/LeiHelp.pm
 lib/PublicInbox/LeiImport.pm
 lib/PublicInbox/LeiInit.pm
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index c0385eb5..c3c79631 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -160,8 +160,8 @@ our %CMD = ( # sorted in order of importance/use:
 
 'ls-search' => [ '[PREFIX]', 'list saved search queries',
 		qw(format|f=s pretty l ascii z|0), @c_opt ],
-'rm-query' => [ 'QUERY_NAME', 'remove a saved search', @c_opt ],
-'mv-query' => [ qw(OLD_NAME NEW_NAME), 'rename a saved search', @c_opt ],
+'forget-search' => [ 'OUTPUT', 'forget a saved search',
+		qw(verbose|v+), @c_opt ],
 
 'plonk' => [ '--threads|--from=IDENT',
 	'exclude mail matching From: or threads from non-Message-ID searches',
diff --git a/lib/PublicInbox/LeiForgetSearch.pm b/lib/PublicInbox/LeiForgetSearch.pm
new file mode 100644
index 00000000..b5fe5fb1
--- /dev/null
+++ b/lib/PublicInbox/LeiForgetSearch.pm
@@ -0,0 +1,32 @@
+# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# "lei forget-search" forget/remove a saved search "lei q --save"
+package PublicInbox::LeiForgetSearch;
+use strict;
+use v5.10.1;
+use PublicInbox::LeiSavedSearch;
+use PublicInbox::LeiUp;
+use File::Path ();
+use SelectSaver;
+
+sub lei_forget_search {
+	my ($lei, $out) = @_;
+	my $d = PublicInbox::LeiSavedSearch::lss_dir_for($lei, \$out);
+	if (-e $d) {
+		my $save;
+		my $opt = { safe => 1 };
+		if ($lei->{opt}->{verbose}) {
+			$opt->{verbose} = 1;
+			$save = SelectSaver->new($lei->{2});
+		}
+		File::Path::remove_tree($d, $opt);
+	} else {
+		$lei->fail("--save was not used with $out cwd=".
+					$lei->rel2abs('.'));
+	}
+}
+
+*_complete_forget_search = \&PublicInbox::LeiUp::_complete_up;
+
+1;
diff --git a/t/lei-q-save.t b/t/lei-q-save.t
index 58342171..5a2f7fff 100644
--- a/t/lei-q-save.t
+++ b/t/lei-q-save.t
@@ -110,5 +110,16 @@ test_lei(sub {
 	like($mb, qr/<qp\@example\.com>/, 'new result written w/ -a');
 
 	lei_ok(qw(up --all=local));
+
+	ok(!lei(qw(forget-search), "$home/bogus"), 'bogus forget');
+	lei_ok qw(_complete lei forget-search);
+	like($lei_out, qr/mbrd-aug/, 'forget-search completion');
+	lei_ok(qw(forget-search -v), "$home/mbrd-aug");
+	is($lei_out, '', 'no output');
+	like($lei_err, qr/\bmbrd-aug\b/, '-v (verbose) reported unlinks');
+	lei_ok qw(_complete lei forget-search);
+	unlike($lei_out, qr/mbrd-aug/,
+		'forget-search completion cleared after forget');
+	ok(!lei('up', "$home/mbrd-aug"), 'lei up fails after forget');
 });
 done_testing;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] lei edit-search: command to tweak search parameters
  2021-04-20  7:16 [PATCH 0/2] lei {edit,forget}-search Eric Wong
  2021-04-20  7:16 ` [PATCH 1/2] lei forget-search: new command to forget saved searches Eric Wong
@ 2021-04-20  7:16 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-04-20  7:16 UTC (permalink / raw)
  To: meta

This may be useful for users to tweak search parameters.
This command is also the reason lei.saved-search is a git-config
file rather than JSON.
---
 MANIFEST                         |  1 +
 lib/PublicInbox/LEI.pm           |  2 ++
 lib/PublicInbox/LeiEditSearch.pm | 25 +++++++++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 lib/PublicInbox/LeiEditSearch.pm

diff --git a/MANIFEST b/MANIFEST
index d4055af4..197da2c0 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -190,6 +190,7 @@ lib/PublicInbox/LeiBlob.pm
 lib/PublicInbox/LeiConvert.pm
 lib/PublicInbox/LeiCurl.pm
 lib/PublicInbox/LeiDedupe.pm
+lib/PublicInbox/LeiEditSearch.pm
 lib/PublicInbox/LeiExternal.pm
 lib/PublicInbox/LeiForgetSearch.pm
 lib/PublicInbox/LeiHelp.pm
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index c3c79631..8fa89944 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -162,6 +162,8 @@ our %CMD = ( # sorted in order of importance/use:
 		qw(format|f=s pretty l ascii z|0), @c_opt ],
 'forget-search' => [ 'OUTPUT', 'forget a saved search',
 		qw(verbose|v+), @c_opt ],
+'edit-search' => [ 'OUTPUT', "edit saved search via `git config --edit'",
+			@c_opt ],
 
 'plonk' => [ '--threads|--from=IDENT',
 	'exclude mail matching From: or threads from non-Message-ID searches',
diff --git a/lib/PublicInbox/LeiEditSearch.pm b/lib/PublicInbox/LeiEditSearch.pm
new file mode 100644
index 00000000..fb36fdcd
--- /dev/null
+++ b/lib/PublicInbox/LeiEditSearch.pm
@@ -0,0 +1,25 @@
+# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+
+# "lei edit-search" edit a saved search following "lei q --save"
+package PublicInbox::LeiEditSearch;
+use strict;
+use v5.10.1;
+use PublicInbox::LeiSavedSearch;
+use PublicInbox::LeiUp;
+
+sub lei_edit_search {
+	my ($lei, $out) = @_;
+	my $lss = PublicInbox::LeiSavedSearch->up($lei, $out) or return;
+	my @cmd = (qw(git config --edit -f), $lss->{'-f'});
+	$lei->qerr("# spawning @cmd");
+	if ($lei->{oneshot}) {
+		exec(@cmd) or die "exec @cmd: $!\n";
+	} else {
+		$lei->send_exec_cmd([], \@cmd, {});
+	}
+}
+
+*_complete_edit_search = \&PublicInbox::LeiUp::_complete_up;
+
+1;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-20  7:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  7:16 [PATCH 0/2] lei {edit,forget}-search Eric Wong
2021-04-20  7:16 ` [PATCH 1/2] lei forget-search: new command to forget saved searches Eric Wong
2021-04-20  7:16 ` [PATCH 2/2] lei edit-search: command to tweak search parameters Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git