From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/2] lei edit-search: command to tweak search parameters
Date: Tue, 20 Apr 2021 07:16:55 +0000 [thread overview]
Message-ID: <20210420071655.22700-3-e@80x24.org> (raw)
In-Reply-To: <20210420071655.22700-1-e@80x24.org>
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;
prev parent reply other threads:[~2021-04-20 7:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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: https://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=20210420071655.22700-3-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.
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).