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

Re: odd completion misbehavior?



On Thu, 20 Oct 2011, Danek Duvall wrote:

With the following completion function:

	_danek() {
		_arguments \
			"--zoo-name" \
			"--zipple-zoo-name"
	}

and running under zsh -f with only

   autoload -Uz compinit
   compinit -i
   compdef _danek danek

if I type "danek --z<TAB>", I end up with "danek --z-name", with the cursor on the dash between "z" and "name". If I hit tab again, I end up with "danek --zoo-name ", with the cursor after the final space. If I setopt menucomplete, I get reasonable behavior.

What have I done wrong with the completion function?

(Everywhere below, I'm marking the cursor position with '|')

Nothing. Zsh is completing the entirety of the unambiguous portions. All of the possible completions in that context:

'--zoo-name' and '--zipple-zoo-name'

begin with: '--z'
and end with: '-name'

So, zsh completes as much as possible.

I'm also interested in a way to disable this behavior, but looking at all of the instances of 'suffix' and 'ambiguous' in anything remotely completion-related in zshall didn't turn up what style to set/unset (if such a style exists).

In my case, the place this bothers me is with _mysql and the --default-character-set, --defaults-file, and --defaults-extra-file settings:

mysql --def|<Tab>
mysql --default|-               # makes sense
mysql --defaults|<Tab>-         # add the 's'
mysql --defaults|<Tab>-file     # okay, now everything starts w/ '--defaults' and ends w/ '-file'
mysql --defaults-file=|         # but, tab again gets me --defaults-file, even though it was still ambiguous with --defaults-extra-file

Might be some way in which my styles are set up (accept-exact somewhere?). But, I'm still getting my feet wet with zstyle.

--
Best,
Ben



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