* Re: configure --with- completion [not found] <20150904084027.GA15509@zira.vinc17.org> @ 2015-10-20 13:00 ` Vincent Lefevre 2015-10-21 16:11 ` Jun T. 0 siblings, 1 reply; 4+ messages in thread From: Vincent Lefevre @ 2015-10-20 13:00 UTC (permalink / raw) To: zsh-workers [Moved to workers] On 2015-09-04 10:40:27 +0200, Vincent Lefevre wrote: > In MPFR, I can do: > > ./configure --with-gmp=[TAB] > ./configure --with-gmp-include=[TAB] > ./configure --with-gmp-lib=[TAB] > > and complete with directory names, but > > ./configure --with-gmp-build=[TAB] > > doesn't allow me to complete with directory names. > > FYI, "./configure --with-[TAB]" outputs: > > Completing option > --with-gmp -- GMP install directory > --with-gmp-build -- GMP build directory (please read INSTALL file) > --with-gmp-include -- GMP include directory > --with-gmp-lib -- GMP lib directory > --with-gnu-ld -- assume the C compiler uses GNU ld (default=no) > --with-mulhigh-size -- internal threshold table for mulhigh > --with-pic -- try to use only PIC/non-PIC objects (default=use > --with-sysroot -- Search for dependent libraries within DIR > --without-gmp -- GMP install directory > --without-gmp-build -- GMP build directory (please read INSTALL file) > --without-gmp-include -- GMP include directory > --without-gmp-lib -- GMP lib directory > --without-gnu-ld -- assume the C compiler uses GNU ld (default=no) > --without-mulhigh-size -- internal threshold table for mulhigh > --without-pic -- try to use only PIC/non-PIC objects (default=use > --without-sysroot -- Search for dependent libraries within DIR > > and "./configure --help" outputs: > > [...] > --with-gmp-include=DIR GMP include directory > --with-gmp-lib=DIR GMP lib directory > --with-gmp=DIR GMP install directory > --with-gmp-build=DIR GMP build directory (please read INSTALL file) > [...] > > Is there something missing in zsh completion? The problem seems to come to the fact that --with-gmp-build=DIR GMP build directory (please read INSTALL file) is listed after --with-gmp=DIR GMP install directory by "./configure --help". If I switch these lines, everything works as expected. There's no reason to depend on the order of the options listed by "./configure --help". So, this seems to be a bug somewhere in the zsh completion system. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: configure --with- completion 2015-10-20 13:00 ` configure --with- completion Vincent Lefevre @ 2015-10-21 16:11 ` Jun T. 2015-10-22 7:51 ` Jun T. 0 siblings, 1 reply; 4+ messages in thread From: Jun T. @ 2015-10-21 16:11 UTC (permalink / raw) To: zsh-workers 2015/10/20 22:00, Vincent Lefevre <vincent@vinc17.net> wrote: > The problem seems to come to the fact that > > --with-gmp-build=DIR GMP build directory (please read INSTALL file) > > is listed after > > --with-gmp=DIR GMP install directory Yes. For example, % _foo() { _arguments : '-x=:switch:(on off)' '-xy=:answer:(yes no)' '*:file:_files' } % compdef _foo foo % foo -xy=<TAB> this completes nothing. If -x and -xy are exchanged, it works as expected. In ca_get_opt() (computil.c:1167), the current word seems to be compared with optspecs in the order they are passed to _arguments. In the example above, the current word "-xy=" is first compared with '-x', and since '-x' matches with the beginning of "-xy=" (strpfx() at line 1695), it is considered as the option -x followed by 'y='. So the next (correct) optspec '-xy' is not tried. Probably we need to look at the next character after the option '-x' ('y' in the above example), and if the type of the option is CAO_OEQUAL and the next character is not '=' (or NULL), then reject '-x' and go to the next possible option '-xy'. But I rather hesitate to modify functions which I don't understand well yet. A workaround (for '_arguments --') would be to modify _arguments as in the patch below. It sorts the optspecs generated by '_arguments --' so that --with-gmp-build comes before --with-gmp. But this patch has effect only with '_arguments --', and does not fix the example above (-x and -xy). Patching computil.c would be better ... diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 87fb20e..fa9750e 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -303,7 +303,13 @@ if (( long )); then fi fi done - set -A "$name" "${(@)cache:# #}" + # Sort the optspecs in $cache so that -xy comes before -x (this + # seems to be required by a restriction (or bug) of comparguments). + # We do this by the following steps: + # add '~' at the end of option name, sort, and remove '~'. + # ('~'=0x7e comes after any other printable ASCII characters) + tmp=( ${${(o)${${cache:# #}/(#b)([a-zA-Z0-9_-]#)/$match[1]~}}/\~/} ) + set -A "$name" "$tmp[@]" fi set -- "$tmpargv[@]" "${(@P)name}" fi ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: configure --with- completion 2015-10-21 16:11 ` Jun T. @ 2015-10-22 7:51 ` Jun T. 2015-10-24 17:00 ` Peter Stephenson 0 siblings, 1 reply; 4+ messages in thread From: Jun T. @ 2015-10-22 7:51 UTC (permalink / raw) To: zsh-workers On 2015/10/22, at 1:11, Jun T. <takimoto-j@kba.biglobe.ne.jp> wrote: > > But this patch has effect only with '_arguments --', and does not fix > the example above (-x and -xy). Patching computil.c would be better ... So this is a minimal patch I can think of. Is this reasonable? diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index e5db086..b664f30 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -1693,10 +1693,13 @@ ca_get_opt(Cadef d, char *line, int full, char **end) for (p = d->opts; p; p = p->next) if (p->active && ((!p->args || p->type == CAO_NEXT) ? !strcmp(p->name, line) : strpfx(p->name, line))) { + int l = strlen(p->name); + if ((p->type == CAO_OEQUAL || p->type == CAO_EQUAL) && + line[l] && line[l] != '=') + continue; + if (end) { /* Return a pointer to the end of the option. */ - int l = strlen(p->name); - if ((p->type == CAO_OEQUAL || p->type == CAO_EQUAL) && line[l] == '=') l++; ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: configure --with- completion 2015-10-22 7:51 ` Jun T. @ 2015-10-24 17:00 ` Peter Stephenson 0 siblings, 0 replies; 4+ messages in thread From: Peter Stephenson @ 2015-10-24 17:00 UTC (permalink / raw) To: zsh-workers On Thu, 22 Oct 2015 16:51:54 +0900 "Jun T." <takimoto-j@kba.biglobe.ne.jp> wrote: > On 2015/10/22, at 1:11, Jun T. <takimoto-j@kba.biglobe.ne.jp> wrote: > > > > But this patch has effect only with '_arguments --', and does not fix > > the example above (-x and -xy). Patching computil.c would be better ... > > So this is a minimal patch I can think of. > Is this reasonable? In this part of the code, committing it and seeing if it has any negative effects is about the only way of finding out. pws ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-24 17:05 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20150904084027.GA15509@zira.vinc17.org> 2015-10-20 13:00 ` configure --with- completion Vincent Lefevre 2015-10-21 16:11 ` Jun T. 2015-10-22 7:51 ` Jun T. 2015-10-24 17:00 ` Peter Stephenson
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).