* PATCH: Re: _arguments parsing of --help output
@ 2000-07-26 8:38 Sven Wischnowsky
2000-07-26 9:58 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 2000-07-26 8:38 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> On Jul 24, 10:52am, Sven Wischnowsky wrote:
> } Subject: Re: _arguments parsing of --help output
> }
> } Bart Schaefer wrote:
> }
> } > Many GNU commands include short options in the --help output as well
> } > [...]
> } > Is there a reason that we don't attempt to complete the short forms?
> }
> } _arguments '-e:ea:(1 2)' -e -b -p
> }
> } This will make `foo -e <TAB>' complete `1' and `2' but `foo -' lists
> } both (with auto-descriptions).
>
> I don't understand here what you mean by "`foo -' lists both".
With:
zstyle ':completion:*:option(-*|s)' auto-description 'specify %d'
and Case 1 below `tst <TAB>' gives:
% tst --
--e -- specify ea
--b --e --p
I.e. --e is listed twice, the first one is the `--e:ea:(1 2)' and the
second one is the auto-detected one.
Should we make _arguments use only the first, last or most `specifc'
one (`most specific' could mean that it describes more arguments than
the other specs for that same option)?
> ...
>
> _tst() { _arguments -- '*--e:ea:(1 2)' } # Case 3
>
> In combination with:
>
> tst() { print -l - --e --b --p }
> compdef _tst tst
>
> ...
>
> Case 2: Completion after `tst' lists --e --b --p and completion after
> `tst --e' completes `--' and then lists --b and --p; 1 or 2 are never
> completed.
>
> Case 3: Exactly like Case 2.
>
> So case 1 behaves as I expected, and case 3 appears to be broken. (I
> also tried '*e:ea:(1 2)' and a few other patterns.) I'm not sure what
> I should be expecting from case 2.
The same as from the second case.
The problem was that _arguments only used those specs after the `--'
for options described (in the --help output) by something containing
an equal sign (`--out=FILE' or some such).
The patch below changes that. The descriptions are used as they are,
i.e. in the example above `tst --e <TAB>' works, but `tst --e=<TAB>'
does not. I think this is right. I think I could be convinced
otherwise.
Bye
Sven
Index: Completion/Base/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.27
diff -u -r1.27 _arguments
--- Completion/Base/_arguments 2000/05/31 06:11:08 1.27
+++ Completion/Base/_arguments 2000/07/26 08:36:35
@@ -142,11 +142,16 @@
cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" )
fi
- # Everything else is just added as an option without arguments.
+ # Everything else is just added as an option without arguments or
+ # as described by $descr.
if (( $#tmp )); then
tmp=("${(@)tmp//[^a-zA-Z0-9-]}")
- cache=( "$cache[@]" "$tmp[@]" )
+ if [[ -n "$descr" ]]; then
+ cache=( "$cache[@]" "${(@)^tmp}${descr}" )
+ else
+ cache=( "$cache[@]" "$tmp[@]" )
+ fi
fi
done
set -A "$name" "${(@)cache:# #}"
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: Re: _arguments parsing of --help output
2000-07-26 8:38 PATCH: Re: _arguments parsing of --help output Sven Wischnowsky
@ 2000-07-26 9:58 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2000-07-26 9:58 UTC (permalink / raw)
To: zsh-workers
On Jul 26, 10:38am, Sven Wischnowsky wrote:
} Subject: PATCH: Re: _arguments parsing of --help output
}
} zstyle ':completion:*:option(-*|s)' auto-description 'specify %d'
}
} % tst --
} --e -- specify ea
} --b --e --p
}
} I.e. --e is listed twice, the first one is the `--e:ea:(1 2)' and the
} second one is the auto-detected one.
}
} Should we make _arguments use only the first, last or most `specifc'
} one (`most specific' could mean that it describes more arguments than
} the other specs for that same option)?
Hm. If somebody actually puts a description of the same option both
before and after the `--' in the _arguments positional-parameter list,
I think they should get both descriptions included in the listing. In
other cases I suppose I'd prefer that it take only the user-supplied
description (not the parsed --help one), but I don't think it's very
important to change the current behavior.
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-07-26 9:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-26 8:38 PATCH: Re: _arguments parsing of --help output Sven Wischnowsky
2000-07-26 9:58 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).