nixpkgs-ml-tools

nixpkgs mailing list tools
git clone git://jb55.com/nixpkgs-ml-tools
Log | Files | Refs | README | LICENSE

commit c9dc99e43205218f045afdb9faad3014bc33370f
parent 0f8c876d0e060fc0793a16ea124d452e0b581f02
Author: Matthias Beyer <mail@beyermatthias.de>
Date:   Sun, 18 Apr 2021 16:14:44 +0200

Add fuzzy selection

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>

Diffstat:
Mnotmuch-am | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/notmuch-am b/notmuch-am @@ -31,6 +31,7 @@ _arg_am="off" _arg_3="off" _arg_amsignoff="off" _arg_fuzzy="off" +_arg_fuzzy_search="" print_help() @@ -41,7 +42,7 @@ print_help() printf '\t%s\n' "--am, --no-am: Call git-am instead of generating a mbox file (off by default)" printf '\t%s\n' "-3: Call git-am with -3 (off by default, only effective with --am)" printf '\t%s\n' "-s, --signoff: Call git-am with --signoff (off by default, only effective with --am)" - printf '\t%s\n' "--fuzzy: Use fzf to interactively select the thread for the patchset to apply" + printf '\t%s\n' "-f, --fuzzy <search>: Use fzf to interactively select the thread for the patchset to apply, pass <search> to notmuch-search, if given" printf '\t%s\n' "-h, --help: Prints help" printf %s "\ @@ -84,8 +85,9 @@ parse_commandline() -l|--add-link) _arg_b4addlink="on" ;; - --fuzzy) + -f|--fuzzy) _arg_fuzzy="on" + _arg_fuzzy_search="${2:-*}" ;; *) _last_positional="$1" @@ -101,10 +103,10 @@ parse_commandline() handle_passed_args_count() { local _required_args_string="'thread-id'" - if [[ "${_positionals_count}" -ge 1 ]] && [[ "$_arg_fuzzy" == "off" ]]; then + if [[ "${_positionals_count}" -ge 2 ]] && [[ "$_arg_fuzzy" == "off" ]]; then _PRINT_HELP=yes die "FATAL ERROR: Not enough positional arguments - we require exactly 1 (namely: $_required_args_string), but got only ${_positionals_count}." 1 fi - if [[ "${_positionals_count}" -le 1 ]] && [[ "$_arg_fuzzy" == "off" ]]; then + if [[ "${_positionals_count}" -lt 1 ]] && [[ "$_arg_fuzzy" == "off" ]]; then _PRINT_HELP=yes die "FATAL ERROR: There were spurious positional arguments --- we expect exactly 1 (namely: $_required_args_string), but got ${_positionals_count} (the last one was: '${_last_positional}')." 1 fi } @@ -171,7 +173,7 @@ if [[ "$_arg_fuzzy" == "on" ]]; then user_email="$(git config user.email)" - thread_id=$(notmuch search --output=summary --format=json "to:$user_email" and subject:PATCH | \ + thread_id=$(notmuch search --output=summary --format=json "$_arg_fuzzy_search" | \ jq -rcC '.[] | [.thread,.date_relative,.subject,.authors] | @tsv' | \ fzf -m --preview "$preview_script" | \ sed 's,\t.*,,; s,^,thread:,')