zsh-workers
 help / color / mirror / code / Atom feed
* buggy configure completion
@ 2016-08-30 23:23 Vincent Lefevre
  2016-08-31  3:00 ` buggy configure completion - when both --enable-foo and --disable-foo are listed Daniel Shahaf
  2016-08-31  3:03 ` Daniel Shahaf
  0 siblings, 2 replies; 10+ messages in thread
From: Vincent Lefevre @ 2016-08-30 23:23 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]

I've attached the "configure --help" output for MPFR.
I'm using:

  zstyle ':completion:*' format 'Completing %d'

With zsh 5.2, I get the following, which doesn't make sense:

zira:~/software/mpfr> ./configure --enable-decimal-float[Tab]
Completing option
--enable-decimal-float  -- build conversion functions from/to decimal floats
--enable-decimal-float  -- explicitly disable decimal floats support

One has from the "configure --help" output:

  --disable-decimal-float explicitly disable decimal floats support
  --enable-decimal-float  build conversion functions from/to decimal floats
                          [default=autodetect]

And there is an inconsistency:

zira:~/software/mpfr> ./configure --enable-log[Tab]

gives

./configure --enable-logging []

where [] is the cursor. But

zira:~/software/mpfr> ./configure --enable-gmp-int[Tab]

gives:

zira:~/software/mpfr> ./configure --enable-gmp-internals=[]

and

zira:~/software/mpfr> ./configure --enable-gmp-internals --[Tab]

gives:

zira:~/software/mpfr> ./configure --enable-gmp-internals --[]
Completing --enable-gmp-internals

instead of completing a new option.

-- 
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)

[-- Attachment #2: configure-help --]
[-- Type: text/plain, Size: 7727 bytes --]

`configure' configures MPFR 4.0.0-dev to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/mpfr]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-silent-rules   less verbose build output (undo: "make V=1")
  --disable-silent-rules  verbose build output (undo: "make V=0")
  --disable-maintainer-mode
                          disable make rules and dependencies not useful (and
                          sometimes confusing) to the casual installer
  --enable-gmp-internals  enable use of GMP undocumented functions [default=no]
  --enable-assert         enable ASSERT checking [default=no]
  --enable-logging        enable MPFR logging (the system must support it)
                          [default=no]
  --disable-thread-safe   explicitly disable TLS support
  --enable-thread-safe    build MPFR as thread safe, i.e. with TLS support
                          (the system must support it) [default=autodetect]
  --enable-shared-cache   enable use of caches shared by all threads,
                          for all MPFR constants.  It usually makes MPFR
                          dependent on PTHREAD [default=no]
  --enable-warnings       allow MPFR to output warnings to stderr [default=no]
  --enable-tests-timeout=NUM
                          [for developers] enable timeout for test programs
                          (NUM seconds, <= 9999) [default=no]; if this is
                          enabled, the environment variable $MPFR_TESTS_TIMEOUT
                          overrides NUM (0: no timeout)
  --enable-tune-for-coverage
                          [for developers] tune MPFR for coverage tests
  --enable-dependency-tracking
                          do not reject slow dependency extractors
  --disable-dependency-tracking
                          speeds up one-time build
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-static[=PKGS]  build static libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --disable-decimal-float explicitly disable decimal floats support
  --enable-decimal-float  build conversion functions from/to decimal floats
                          [default=autodetect]
  --disable-float128      explicitly disable __float128 support
  --enable-float128       build conversion functions from/to __float128
                          [default=autodetect]
  --enable-mini-gmp       build MPFR with mini-gmp (experimental) [default=no]
  --enable-debug-prediction
                          [for developers] enable debug of branch prediction
                          (for x86 and x86-64 with GCC, static libs)
  --enable-lto            build MPFR with link-time-optimization
                          (experimental) [default: no]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --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)
  --with-mulhigh-size=NUM internal threshold table for mulhigh
  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                          both]
  --with-aix-soname=aix|svr4|both
                          shared library versioning (aka "SONAME") variant to
                          provide on AIX, [default=aix].
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-sysroot[=DIR]    Search for dependent libraries within DIR (or the
                          compiler's sysroot if not specified).

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  LT_SYS_LIBRARY_PATH
              User-defined run-time library search path.

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to the package provider.

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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-30 23:23 buggy configure completion Vincent Lefevre
@ 2016-08-31  3:00 ` Daniel Shahaf
  2016-08-31  6:15   ` Vincent Lefevre
  2016-08-31 20:27   ` m0viefreak
  2016-08-31  3:03 ` Daniel Shahaf
  1 sibling, 2 replies; 10+ messages in thread
From: Daniel Shahaf @ 2016-08-31  3:00 UTC (permalink / raw)
  To: zsh-workers

You raise two separate issues, so let's split them into separate
subthreads.

Vincent Lefevre wrote on Wed, Aug 31, 2016 at 01:23:32 +0200:
> With zsh 5.2, I get the following, which doesn't make sense:
> 
> zira:~/software/mpfr> ./configure --enable-decimal-float[Tab]
> Completing option
> --enable-decimal-float  -- build conversion functions from/to decimal floats
> --enable-decimal-float  -- explicitly disable decimal floats support
> 
> One has from the "configure --help" output:
> 
>   --disable-decimal-float explicitly disable decimal floats support
>   --enable-decimal-float  build conversion functions from/to decimal floats
>                           [default=autodetect]

What do you expect to see?  How should the two strings ("build .." and
"explicitly ...") be handled?

Minimal example:

% print -rl -- '#!/bin/sh' 'cat <<"EOF"' '  --enable-foo  enable foo' '  --disable-foo  disable foo' 'EOF' >configure
% chmod +x configure
% ./configure --<TAB>
--disable-foo  --enable-foo  -- enable foo                                    
--disable-foo  --enable-foo  -- disable foo                                   

I think that's the best we can do without writing new C code to suport
multiline descriptions.

Cheers,

Daniel


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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-30 23:23 buggy configure completion Vincent Lefevre
  2016-08-31  3:00 ` buggy configure completion - when both --enable-foo and --disable-foo are listed Daniel Shahaf
@ 2016-08-31  3:03 ` Daniel Shahaf
  2016-08-31  6:45   ` Vincent Lefevre
  1 sibling, 1 reply; 10+ messages in thread
From: Daniel Shahaf @ 2016-08-31  3:03 UTC (permalink / raw)
  To: zsh-workers

Vincent Lefevre wrote on Wed, Aug 31, 2016 at 01:23:32 +0200:
> And there is an inconsistency:
> 
> zira:~/software/mpfr> ./configure --enable-log[Tab]
> 
> gives
> 
> ./configure --enable-logging []
> 
> where [] is the cursor. But
> 
> zira:~/software/mpfr> ./configure --enable-gmp-int[Tab]
> 
> gives:
> 
> zira:~/software/mpfr> ./configure --enable-gmp-internals=[]
> 
> and
> 
> zira:~/software/mpfr> ./configure --enable-gmp-internals --[Tab]
> 
> gives:
> 
> zira:~/software/mpfr> ./configure --enable-gmp-internals --[]
> Completing --enable-gmp-internals
> 
> instead of completing a new option.

It thinks --enable-gmp-internals takes an argument.  This seems to
happen whenever there's an "=" sign on that line of the --help output.

>From the trace output:

+_arguments:143> lopts+=( '--enable-foo:enable fo=o' ) 
⋮
+_arguments:266> tmpo=( '--enable-foo:enable fo=o' '--disable-foo:enable fo=o' ) 
+_arguments:267> ((  2  ))
+_arguments:268> tmp=( ) 
+_arguments:270> opt=--enable-foo:enable fo=o
+_arguments:271> [[ '--enable-foo:enable fo=o' == (#b)(*):([^:]#) ]]
+_arguments:272> opt=--enable-foo 
+_arguments:273> odescr='[enable fo=o]' 
+_arguments:277> opt2='--enable-foo=[enable fo=o]' 

Line 143 is in the handling of "--help" parsing.  The other lines look
for --foo=[…]:… specs.  The pattern in 266/268 appears to match the
'=' sign even though it's in the second colon-separated field, where it
doesn't denote a mandatory argument.

I'm guessing the pattern match on lines 266/268 should be fixed, but I'm
not sure how.

Cheers,

Daniel


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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-31  3:00 ` buggy configure completion - when both --enable-foo and --disable-foo are listed Daniel Shahaf
@ 2016-08-31  6:15   ` Vincent Lefevre
  2016-08-31  9:09     ` Daniel Shahaf
  2016-08-31 20:27   ` m0viefreak
  1 sibling, 1 reply; 10+ messages in thread
From: Vincent Lefevre @ 2016-08-31  6:15 UTC (permalink / raw)
  To: zsh-workers

On 2016-08-31 03:00:55 +0000, Daniel Shahaf wrote:
> Vincent Lefevre wrote on Wed, Aug 31, 2016 at 01:23:32 +0200:
> > With zsh 5.2, I get the following, which doesn't make sense:
> > 
> > zira:~/software/mpfr> ./configure --enable-decimal-float[Tab]
> > Completing option
> > --enable-decimal-float  -- build conversion functions from/to decimal floats
> > --enable-decimal-float  -- explicitly disable decimal floats support
> > 
> > One has from the "configure --help" output:
> > 
> >   --disable-decimal-float explicitly disable decimal floats support
> >   --enable-decimal-float  build conversion functions from/to decimal floats
> >                           [default=autodetect]
> 
> What do you expect to see?  How should the two strings ("build .." and
> "explicitly ...") be handled?
> 
> Minimal example:
> 
> % print -rl -- '#!/bin/sh' 'cat <<"EOF"' '  --enable-foo  enable foo' '  --disable-foo  disable foo' 'EOF' >configure
> % chmod +x configure
> % ./configure --<TAB>
> --disable-foo  --enable-foo  -- enable foo                                    
> --disable-foo  --enable-foo  -- disable foo                                   

The problem is that it says "build conversion functions from/to
decimal floats" after --enable-decimal-float while it corresponds
to --disable-decimal-float. So, I'd say, either

--enable-decimal-float  -- build conversion functions from/to decimal floats
--disable-decimal-float -- explicitly disable decimal floats support

(thus skipping the --disable-decimal-float when one completes on
--enable[Tab]), or add "=no" for the disable cases, e.g.:

--enable-decimal-float    -- build conversion functions from/to decimal floats
--enable-decimal-float=no -- explicitly disable decimal floats support

-- 
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] 10+ messages in thread

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-31  3:03 ` Daniel Shahaf
@ 2016-08-31  6:45   ` Vincent Lefevre
  0 siblings, 0 replies; 10+ messages in thread
From: Vincent Lefevre @ 2016-08-31  6:45 UTC (permalink / raw)
  To: zsh-workers

On 2016-08-31 03:03:04 +0000, Daniel Shahaf wrote:
> It thinks --enable-gmp-internals takes an argument.  This seems to
> happen whenever there's an "=" sign on that line of the --help output.
[...]
> Line 143 is in the handling of "--help" parsing.  The other lines look
> for --foo=[…]:… specs.  The pattern in 266/268 appears to match the
> '=' sign even though it's in the second colon-separated field, where it
> doesn't denote a mandatory argument.
> 
> I'm guessing the pattern match on lines 266/268 should be fixed, but I'm
> not sure how.

Another example is the following with autoconf-generated configure:

  --enable-silent-rules   less verbose build output (undo: "make V=1")
  --disable-silent-rules  verbose build output (undo: "make V=0")

Moreover, still with autoconf-generated configure, --enable-*
options always accept an argument. More precisely:

  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]

though actually, one generally doesn't provide one (anyway, one cannot
complete on arguments since one doesn't know what is accepted).

I'd say that the rules should be:

* If one just has the option, e.g.

  --enable-gmp-internals  enable use of GMP undocumented functions [default=no]

  (anything after a space following the option being ignored), the
  completion shouldn't assume that the user will give an argument,
  though he might add one after completing.

* If there is a "=" just after the option, e.g.

  --with-mulhigh-size=NUM internal threshold table for mulhigh

  then an argument is assumed.

* If there is an explicit *optional* argument in the --help output,
  e.g.

  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-static[=PKGS]  build static libraries [default=yes]

  (as generated by libtool), then this should also be taken into
  account, but I think that this should be like in the first case.

-- 
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] 10+ messages in thread

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-31  6:15   ` Vincent Lefevre
@ 2016-08-31  9:09     ` Daniel Shahaf
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Shahaf @ 2016-08-31  9:09 UTC (permalink / raw)
  To: zsh-workers

Vincent Lefevre wrote on Wed, Aug 31, 2016 at 08:15:55 +0200:
> On 2016-08-31 03:00:55 +0000, Daniel Shahaf wrote:
> > Vincent Lefevre wrote on Wed, Aug 31, 2016 at 01:23:32 +0200:
> > > With zsh 5.2, I get the following, which doesn't make sense:
> > > 
> > > zira:~/software/mpfr> ./configure --enable-decimal-float[Tab]
> > > Completing option
> > > --enable-decimal-float  -- build conversion functions from/to decimal floats
> > > --enable-decimal-float  -- explicitly disable decimal floats support
> > > 
> > > One has from the "configure --help" output:
> > > 
> > >   --disable-decimal-float explicitly disable decimal floats support
> > >   --enable-decimal-float  build conversion functions from/to decimal floats
> > >                           [default=autodetect]
> > 
> > What do you expect to see?  How should the two strings ("build .." and
> > "explicitly ...") be handled?
> > 
> > Minimal example:
> > 
> > % print -rl -- '#!/bin/sh' 'cat <<"EOF"' '  --enable-foo  enable foo' '  --disable-foo  disable foo' 'EOF' >configure
> > % chmod +x configure
> > % ./configure --<TAB>
> > --disable-foo  --enable-foo  -- enable foo                                    
> > --disable-foo  --enable-foo  -- disable foo                                   
> 
> The problem is that it says "build conversion functions from/to
> decimal floats" after --enable-decimal-float while it corresponds
> to --disable-decimal-float.

I see.  I missed that in my previous reply.  Thanks for spelling it out.

I agree, the current completion is misleading.  This occurs with zsh's
configure script too:
.
% ./configure --enable-<TAB>
--enable-dynamic             -- turn off dynamically loaded binary modules

> So, I'd say, either
> 
> --enable-decimal-float  -- build conversion functions from/to decimal floats
> --disable-decimal-float -- explicitly disable decimal floats support
> 

You can sort of get this with a matchspec.  If you take the _configure
function in master, delete the -s parameter, and add a -M parameter,
like this:

_configure () {
        _arguments -M 'B:--en=--dis B:--dis=--en' : -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' '*=(E|)PREFIX*:prefix directory:_files -/' '*=PROGRAM*:program:_command_names -e' '*=NAME*executable*:program:_command_names -e' '*=NAME*:file:_files'
}

The behaviour of this function is different in three ways from the
_configure function in current master:

1) This function shows the correct --disable/--enable argument to the
left of each description:
.
% ./configure --en<TAB>
> option
--disable-dynamic            - turn off dynamically loaded binary modules
--disable-dynamic-nss        - do not call functions that will require dynamic NSS
--disable-gdbm               - turn off search for gdbm library
   …able-additional-fpath    - add directories to default function path
   …able-ansi2knr            - translate source to K&R C before compiling
   …able-cap                 - enable the search for POSIX capabilities (may
.
... and if you choose one of the first three options, the string inserted
in to the command line is "--enable-dynamic", not "--disable-dynamic".

2) Completing «./configure --<TAB>» will show next to each docstring
*either* the --enable-* or --disable-*, but not both.  This means the
user can tell at a glance whether the docstring describes --enable or
--disable, but also that (in the above example) the user has to type 'e'
'n' <TAB> to get compsys to fill in the rest of the word "-enable-dynamic".

3) «./configure --e<TAB>» won't offer the --enable-* counterparts of
options shown in the first output as --disable-*.  (I assume some smarter
matchspec could take care of this.)

Or maybe there's a better approach that doesn't use matchspecs at all.

> (thus skipping the --disable-decimal-float when one completes on
> --enable[Tab]), or add "=no" for the disable cases, e.g.:
> 
> --enable-decimal-float    -- build conversion functions from/to decimal floats
> --enable-decimal-float=no -- explicitly disable decimal floats support

Cheers,

Daniel


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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-31  3:00 ` buggy configure completion - when both --enable-foo and --disable-foo are listed Daniel Shahaf
  2016-08-31  6:15   ` Vincent Lefevre
@ 2016-08-31 20:27   ` m0viefreak
  2016-09-02  1:27     ` Bart Schaefer
  1 sibling, 1 reply; 10+ messages in thread
From: m0viefreak @ 2016-08-31 20:27 UTC (permalink / raw)
  To: zsh-workers



On 31.08.2016 05:00, Daniel Shahaf wrote:
> I think that's the best we can do without writing new C code to suport
> multiline descriptions.

This has been working well for me:

zstyle ':completion:*:configure:*:options' command $'print -r -- "${$(COLUMNS=9999 ${~words[1]} --help)//\n        #/ }"'


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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-08-31 20:27   ` m0viefreak
@ 2016-09-02  1:27     ` Bart Schaefer
  2016-09-02 21:02       ` m0viefreak
  0 siblings, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2016-09-02  1:27 UTC (permalink / raw)
  To: zsh-workers

On Aug 31, 10:27pm, m0viefreak wrote:
}
} On 31.08.2016 05:00, Daniel Shahaf wrote:
} > I think that's the best we can do without writing new C code to suport
} > multiline descriptions.
} 
} This has been working well for me:
} 
} zstyle ':completion:*:configure:*:options' command $'print -r -- "${$(COLUMNS=9999 ${~words[1]} --help)//\n        #/ }"'

If that works, then we ought to be able to rewrite the loop starting
at about line 91 of _arguments.  But that loop already seems to be
looking for lines with leading spaces, whereas if I'm reading your
pattern correctly you're unfolding lines with more than six leading
spaces to make them part of the previous line?

I have to update that to look for more than eight spaces for it to work
right for zsh's ./configure and even then it mysteriously fails to pick
out defaults [/usr/local] and [PREFIX] for --prefix and --exec-prefix
respectively, though it gets it right for --datarootdir et al.


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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-09-02  1:27     ` Bart Schaefer
@ 2016-09-02 21:02       ` m0viefreak
  2016-09-07  5:39         ` Bart Schaefer
  0 siblings, 1 reply; 10+ messages in thread
From: m0viefreak @ 2016-09-02 21:02 UTC (permalink / raw)
  To: zsh-workers


On 02.09.2016 03:27, Bart Schaefer wrote:
> On Aug 31, 10:27pm, m0viefreak wrote:
> }
> } On 31.08.2016 05:00, Daniel Shahaf wrote:
> } > I think that's the best we can do without writing new C code to suport
> } > multiline descriptions.
> } 
> } This has been working well for me:
> } 
> } zstyle ':completion:*:configure:*:options' command $'print -r -- "${$(COLUMNS=9999 ${~words[1]} --help)//\n        #/ }"'
> 
> If that works, then we ought to be able to rewrite the loop starting
> at about line 91 of _arguments.  But that loop already seems to be
> looking for lines with leading spaces, whereas if I'm reading your
> pattern correctly you're unfolding lines with more than six leading
> spaces to make them part of the previous line?
> 
> I have to update that to look for more than eight spaces for it to work
> right for zsh's ./configure

Oh, right, I'm missing one #. It should have been '[8spaces]##':

zstyle ':completion:*:configure:*:options' command $'print -r -- "${$(COLUMNS=9999 ${~words[1]} --help)//\n        ##/ }"'


> and even then it mysteriously fails to pick
> out defaults [/usr/local] and [PREFIX] for --prefix and --exec-prefix
> respectively, though it gets it right for --datarootdir et al.

This works fine for me:

~/sources/zsh $ ./configure --e<TAB>
Completing: option
--enable-additional-fpath    -- add directories to default function path
--enable-ansi2knr            -- translate source to K&R C before compiling
--enable-cap                 -- enable the search for POSIX capabilities (may require additional headers to be added by hand)
--enable-cflags              -- specify C compiler flags
--enable-cppflags            -- specify C preprocessor flags
--enable-custom-patchlevel   -- set a custom ZSH_PATCHLEVEL value
--enable-etcdir              -- the default directory for global zsh scripts
--enable-fndir               -- the directory in which to install functions
--enable-function-subdirs    -- install functions in subdirectories
--enable-ldflags             -- specify linker flags
--enable-libc-musl           -- compile with musl as the C library
--enable-libs                -- specify link libraries
--enable-maildir-support     -- enable maildir support in MAIL and MAILPATH
--enable-max-function-depth  -- limit function depth to MAX, default 1000
--enable-multibyte           -- support multibyte characters
--enable-pcre                -- enable the search for the pcre library (may create run-time library dependencies)
--enable-readnullcmd         -- pager used when READNULLCMD is not set
--enable-runhelpdir          -- the directory in which to install run-help files
--enable-scriptdir           -- the directory in which to install scripts
--enable-site-fndir          -- same for site functions (not version specific)
--enable-site-scriptdir      -- same for site scripts (not version specific)
--enable-stack-allocation    -- allocate stack memory e.g. with `alloca'
--enable-zlogin              -- the full pathname of the global zlogin script
--enable-zlogout             -- the full pathname of the global zlogout script
--enable-zprofile            -- the full pathname of the global zprofile script
--enable-zsh-debug           -- compile with debug code and debugger symbols
--enable-zsh-hash-debug      -- turn on debugging of internal hash tables
--enable-zsh-heap-debug      -- turn on error checking for heap allocation
--enable-zsh-mem             -- compile with zsh memory allocation routines
--enable-zsh-mem-debug       -- debug zsh memory allocation routines
--enable-zsh-mem-warning     -- print warnings for errors in memory allocation
--enable-zsh-secure-free     -- turn on error checking for free()
--enable-zsh-valgrind        -- turn on support for valgrind debugging of heap memory
--enable-zshenv              -- the full pathname of the global zshenv script
--enable-zshrc               -- the full pathname of the global zshrc script
--exec-prefix                -- install architecture-dependent files in EPREFIX (PREFIX)

~/sources/zsh $ ./configure --p<TAB>
Completing: option
--pdfdir                  -- pdf documentation (DOCDIR)
--prefix                  -- install architecture-independent files in PREFIX (/usr/local)
--program-prefix          -- prepend PREFIX to installed program names
--program-suffix          -- append SUFFIX to installed program names
--program-transform-name  -- run sed PROGRAM on installed program names
--psdir                   -- ps documentation (DOCDIR)


Also, slightly related:
The _configure completion could benefit from my patch I sent back in march:
http://www.zsh.org/mla/workers//2016/msg00674.html


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

* Re: buggy configure completion - when both --enable-foo and --disable-foo are listed
  2016-09-02 21:02       ` m0viefreak
@ 2016-09-07  5:39         ` Bart Schaefer
  0 siblings, 0 replies; 10+ messages in thread
From: Bart Schaefer @ 2016-09-07  5:39 UTC (permalink / raw)
  To: zsh-workers

On Sep 2, 11:02pm, m0viefreak wrote:
} Subject: Re: buggy configure completion - when both --enable-foo and --dis
} 
} On 02.09.2016 03:27, Bart Schaefer wrote:
} > I have to update that to look for more than eight spaces for it to work
} > right for zsh's ./configure
} 
} Oh, right, I'm missing one #. It should have been '[8spaces]##':
} 
} zstyle ':completion:*:configure:*:options' command $'print -r -- "${$(COLUMNS=9999 ${~words[1]} --help)//\n        ##/ }"'
} 
} > and even then it mysteriously fails to pick
} > out defaults [/usr/local] and [PREFIX] for --prefix and --exec-prefix
} 
} This works fine for me:

My problem turns out to be _args_cache_${name} stashing away the long
options, which is problematic for things like "configure" that may be
rebuilt with different/new options in the middle of a shell session.
If I "unset -m _args_cache_\*" and then try again, it works.

} Also, slightly related:
} The _configure completion could benefit from my patch I sent back in march:
} http://www.zsh.org/mla/workers//2016/msg00674.html

In that message, you wrote:
>> After parsing the --help output, zsh internally stores that option as
>>   --foo:some option (useful with --bar=baz)
>> 
>> Later it filters the options using the following:
>>   tmp=("${(@M)lopts:##$~pattern(|:*)}")
>> 
>> The (|:*) part is supposed to be limiting the matching to the part
>> before the ':'. This does however not work at all.
>> It will simply use the empty variant and match anyways.

Your patch recommends changing (|:*) to just :* and always append an
extra ":" so that the empty variant is not needed.

I'll point out for the record that zsh tries alternative patterns in
left-to-right order and always uses the first one that succeeds, so it
might also work to change the pattern to (:*|) [and hope your email
reader doesn't interpret that as some sort of emoticon].

However, in workers/39135, Daniel points out that the pattern on lines
266/268 needs fixing, and your change with the appended colon might in
fact accomplish the necessary tweak.  So I'm going to apply/commit
workers/38153 and Vincent can tell us whether it helps him at all.

-- 
Barton E. Schaefer


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

end of thread, other threads:[~2016-09-07  6:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30 23:23 buggy configure completion Vincent Lefevre
2016-08-31  3:00 ` buggy configure completion - when both --enable-foo and --disable-foo are listed Daniel Shahaf
2016-08-31  6:15   ` Vincent Lefevre
2016-08-31  9:09     ` Daniel Shahaf
2016-08-31 20:27   ` m0viefreak
2016-09-02  1:27     ` Bart Schaefer
2016-09-02 21:02       ` m0viefreak
2016-09-07  5:39         ` Bart Schaefer
2016-08-31  3:03 ` Daniel Shahaf
2016-08-31  6:45   ` Vincent Lefevre

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).