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

Re: How to get compadd to not sort words?



On Dec 15,  1:59am, Rocky Bernstein wrote:
}
} Many thanks.
} 
} This does the trick. I'm happy with getting this in the order given without
} special formatting of negative numbers.

You're welcome.  The special formatting was just an example I picked to
show how you'd associate styles with the completion results.

In fact, just to flesh out the example a little ...

If you want ^Xh (_complete_help) to be able to generate useful help for
the context, you need to call _tags to initialize that part of the
system, and then you should use the _requested wrapper to make the call
to _description and compadd.  So you might do

    _unsorted() {
      local expl ret=1
      _tags numbers letters
      while _tags; do
        if _requested -V numbers expl 'Some Numbers' compadd 1 2 -1 -2 3 0
	then ret=0
	fi
	if _requested -V letters expl 'Some Letters' compadd A B Z X C M 
	then ret=0
	fi
      done
      return ret
    }

This is obviously a lot more interesting if the completions are more than
a single character/digit.  For sorted groups, use -J instead of -V.  (No,
there isn't a mnemonic for why -J and -V got used here; it was because
they were single letters not already being used for something else.)



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