zsh-workers
 help / color / mirror / Atom feed
* Doing useful things in completers
@ 2021-08-06  4:43 Mikael Magnusson
  2021-08-06 17:00 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Magnusson @ 2021-08-06  4:43 UTC (permalink / raw)
  To: zsh-workers

This came up on irc, someone was complaining that file completion
didn't work, turns out the situation they were trying was: mysql
--ssl-ca=/home/<tab>

The _mysql completer just feeps with
---- no match for: `MySQL database', `option', or `corrections'

and the completer code looks like this:
_mysql() {
  _arguments -s \
    "$_mysql_common_opts[@]" "$_mysql_variables_opts[@]" \
    '(--disable-auto-rehash)--auto-rehash[enable automatic rehashing]' \
...other options elided...
    '(--auto-rehash)--disable-auto-rehash[disable automatic hashing]' \
    '(-G --named-commands)--disable-named-commands' \
    ':MySQL database:_mysql_databases'
}

The completer itself hasn't been updated since 2004, and of course we
could add all new options etc to it (and probably should), but I'm
curious if there's some handy way you can rewrite this so that file
completion would be tried for unknown options here (eg, the user
already typed the full option name including the trailing equal sign)?
Nothing comes to mind but I'm not as familiar with completion
intricacies these days...

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Doing useful things in completers
  2021-08-06  4:43 Doing useful things in completers Mikael Magnusson
@ 2021-08-06 17:00 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2021-08-06 17:00 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, Aug 5, 2021 at 9:44 PM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> This came up on irc, someone was complaining that file completion
> didn't work, turns out the situation they were trying was: mysql
> --ssl-ca=/home/<tab>
>
> The completer itself hasn't been updated since 2004, and of course we
> could add all new options etc to it (and probably should), but I'm
> curious if there's some handy way you can rewrite this so that file
> completion would be tried for unknown options here (eg, the user
> already typed the full option name including the trailing equal sign)?

I'm not sure about the mysql completion function in particular, but
adding this to the completer zstyle should help:

_fileoption () {
  compset -P '-*=' && _files
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-06 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06  4:43 Doing useful things in completers Mikael Magnusson
2021-08-06 17:00 ` Bart Schaefer

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ https://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git