Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Three questions about a completer



On Sep 14, 10:32pm, Jesper Nygards wrote:
}
} Hmm, this was much harder than I thought. I see no difference with the
} addition of the compstate[insert] line.

Hm.  I don't have any problem making what you posted in users/21901
switch forward to backward or backward to forward, even without the
compstate[insert] assignment (as borne out by you finding it already
set to "menu" on entry).

I don't see where you've ever told us what version number of zsh you
have ... oh.

Date:   Mon Mar 7 13:15:40 2016 +0100

    38043: allow any completion widget to cycle matches for menu completion
    to fix reverse menu completion

So it works for me because I'm running the most recent dev build.

That means you'll have to do a bit of the work of preserving the menu:

    typeset -Hga __lsmatches

    _list-result () {
      if [[ $WIDGET != $LASTWIDGET ]]
      then
        if [[ $LASTWIDGET = *list-comp ]]
        then
          # Rotate stored completions to start in the right place
          # Replace (b) with (q) here if zsh complains about (b)
          integer here=$__lsmatches[(I)${(b)words[CURRENT]}]
          if ((here)); then
            __lsmatches=( $__lsmatches[here,-1] $__lsmatches[1,here-1] )
          fi
        else
          # Store the matching completions in case needed again
          compadd -O __lsmatches \
              -M 'l:|=* m:{[:lower:]}={[:upper:]}' -f ${__lsdir:-HOME}/*
        fi
        # Now add, preserving the order previously calculated
        compadd -V $WIDGET -U -f -a __lsmatches
      fi
      compstate[list]='' 
    }



Messages sorted by: Reverse Date, Date, Thread, Author