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

Re: Completion in the first character position



On Jul 25,  2:14pm, Oliver Kiddle wrote:
} Subject: Completion in the first character position
}
} I am writing a shell script where I'm prompting the user to enter
} various information. I'm using vared to read what is entered into a
} variable after using compctl -C to setup completions (and a setopt
} autolist). I could have used the new style completions but it is a
} fairly simple case and I use 3.0.8 where the script will run.

I have a similar script and a similar situation, but I used

  compctl -Tx 'p[1,-1]' -f - 'W[0,*]' -k l ${${ZSH_VERSION##3.0*}:+-tn}

where `l' holds the list of words to be completed.  Hmm, I guess I'm
also using a `select' loop to read what is entered, as ZLE is enabled
at the PS3 prompt.

} The problem is that when I press tab to complete in the first character
} position, a tab is inserted and the completions are not listed.

Even sillier is that ^D in this same position _does_ produce a list,
rather than exiting from `select'.  That doesn't appear to be the case
any longer with the new completion system.

I suppose that might even be worthy of a patch for 3.0.8 ...

} Is there an option or something to turn this off? I've looked through
} the manual but can't see one. As a feature, it is probably less useful
} with the new completion system because the same can be achieved with a
} style anyway.

On Jul 25,  3:39pm, Sven Wischnowsky replied:
} Subject: Re: Completion in the first character position
}
} Yes, since this is possible in the new completion system (even the
} default there, inside vared), I guess we won't add an option for it.

My aforementioned script does

    local curcontext=${0}:::
    zstyle ":completion:${0}:*" completer _null
    zstyle ":completion:${0}:*" insert-tab no
    _null() { compcall -T -D }

to bypass new completion after the compctl -Tx has been installed and
stop tabs being inserted at the beginnings of lines.

Which reminds me:  `zed' should do something similar.  As should vared
when editing an element of the functions assoc -- is there a way to be
that specific about the vared context?

}   bindkey -s '\t' '\ec'  # or something better than \ec
}   bindkey '\ec' complete-word

Cute.

} And now you wish for vared-local keymaps, of course ;-)

The trick used by zed to set and restore bindings should be sufficient.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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