~andir/nixpkgs-dev

4 2

[nixpkgs-ml RFC v1 0/2] Re-write fuzzy selection feature

Details
Message ID
<20210418141444.30429-1-mail@beyermatthias.de>
DKIM signature
missing
Download raw message
Hi,

because I broke notmuch-am, I had to rewrite the fuzzy selection feature.
This works as follows now:

    notmuch am --fuzzy 'optional notmuch search terms'

It first searches notmuch with the search terms you provided (if you provide
none, `notmuch search '*'` is executed, which might take a few sec). Then you're
presented with an `fzf -m` selection list of _threads_.
The preview window shows the threads messages.

The selected threads will be used to compute the mbox, or, if you passed --am to
notmuch-am, will be applied.


This is an RFC whether the UI/UX is okay for you guys.
Please TEST whether this works for you and whether I broke something. I tested
this with `--fuzzy`, `--fuzzy 'terms'`, plus `--am` and `-s` - but I might have
missed something.


Matthias


Matthias Beyer (2):
  Revert "Revert "Add fuzzy-patch-thread-selecting""
  Add fuzzy selection

 notmuch-am | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

-- 
2.29.3

[nixpkgs-ml RFC v1 1/2] Revert "Revert "Add fuzzy-patch-thread-selecting""

Details
Message ID
<20210418141444.30429-2-mail@beyermatthias.de>
In-Reply-To
<20210418141444.30429-1-mail@beyermatthias.de> (view parent)
DKIM signature
missing
Download raw message
Patch: +25 -3
This reverts commit 159fe820d4a0cb420fe89c2d133f0ceb1cdef1a3.
---
 notmuch-am | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/notmuch-am b/notmuch-am
index 448c9b3..4a642f4 100755
--- a/notmuch-am
+++ b/notmuch-am
@@ -30,6 +30,7 @@ _positionals=()
_arg_am="off"
_arg_3="off"
_arg_amsignoff="off"
_arg_fuzzy="off"


print_help()
@@ -40,6 +41,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' "-h, --help: Prints help"
    printf %s "\

@@ -82,6 +84,9 @@ parse_commandline()
            -l|--add-link)
                _arg_b4addlink="on"
                ;;
            --fuzzy)
                _arg_fuzzy="on"
                ;;
            *)
                _last_positional="$1"
                _positionals+=("$_last_positional")
@@ -96,8 +101,12 @@ parse_commandline()
handle_passed_args_count()
{
    local _required_args_string="'thread-id'"
    test "${_positionals_count}" -ge 1 || _PRINT_HELP=yes die "FATAL ERROR: Not enough positional arguments - we require exactly 1 (namely: $_required_args_string), but got only ${_positionals_count}." 1
    test "${_positionals_count}" -le 1 || _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
    if [[ "${_positionals_count}" -ge 1 ]] && [[ "$_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
        _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
}


@@ -155,5 +164,18 @@ main () {
    rm -f "$mbox"
}

[ -n "$1" ] || usage && main "$_arg_thread_id"
thread_id="$_arg_thread_id"

if [[ "$_arg_fuzzy" == "on" ]]; then
    preview_script='echo {} | sed "s,\t.*,,; s,^,thread:," | xargs notmuch search --output=files --format=text | xargs grep -ihE "^Subject" | sort'

    user_email="$(git config user.email)"

    thread_id=$(notmuch search --output=summary --format=json "to:$user_email" and subject:PATCH | \
        jq -rcC '.[] | [.thread,.date_relative,.subject,.authors] | @tsv' | \
        fzf -m --preview "$preview_script" | \
        sed 's,\t.*,,; s,^,thread:,')
fi

[ -n "$1" ] || usage && main "$thread_id"

-- 
2.29.3

[nixpkgs-ml RFC v1 2/2] Add fuzzy selection

Details
Message ID
<20210418141444.30429-3-mail@beyermatthias.de>
In-Reply-To
<20210418141444.30429-1-mail@beyermatthias.de> (view parent)
DKIM signature
missing
Download raw message
Patch: +7 -5
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
---
 notmuch-am | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/notmuch-am b/notmuch-am
index 4a642f4..acbea5b 100755
--- 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:,')
-- 
2.29.3
Details
Message ID
<20210418141956.uw76kcncw3ogxfn6@hoshi>
In-Reply-To
<20210418141444.30429-1-mail@beyermatthias.de> (view parent)
DKIM signature
missing
Download raw message
On 18-04-2021 16:14:42, Matthias Beyer wrote:
> Matthias Beyer (2):
>   Revert "Revert "Add fuzzy-patch-thread-selecting""
>   Add fuzzy selection

I guess before this gets applied, I should rebase and fixup the commit messages.

Also, maybe we should just re-generate (using argbash.io) the CLI parser because
I'm not 100% confident that I did not break anything ;-)
Details
Message ID
<20210418161409.dhrb4i4zylxrugxu@quiver>
In-Reply-To
<20210418141444.30429-1-mail@beyermatthias.de> (view parent)
DKIM signature
missing
Download raw message
On Sun, Apr 18, 2021 at 04:14:42PM +0200, Matthias Beyer wrote:
>Hi,
>
>because I broke notmuch-am, I had to rewrite the fuzzy selection feature.
>This works as follows now:
>
>    notmuch am --fuzzy 'optional notmuch search terms'

ah perfect this makes it much more useful to me.

tested and works great, thanks!

To jb55.com:nixpkgs-ml-tools
    159fe82..c9dc99e  master -> master
Reply to thread Export thread (mbox)