zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Update make completion with gnu options
@ 2013-07-12  6:46 Nick Cross
  2013-07-12  8:38 ` Peter Stephenson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Nick Cross @ 2013-07-12  6:46 UTC (permalink / raw)
  To: zsh-workers

Hi,

Here are the additional commands for make. Thanks to Bart Schaefer who helped with correcting the make completion. I *think* its correct now ;-)

Hope it helps,

Regards

Nick


=======


commit 6245a950510bb47611d2cc2a660c21c2d82a2ca5
Author: Nick Cross <zsh@goots.org>
Date:   Thu Jul 11 22:07:18 2013 +0100

    Update make completion with gnu options

diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index 72d16bb..5dd0a21 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -158,13 +158,36 @@ _make() {
   if [[ $is_gnu == gnu ]]
   then
     incl="(-|)include"
-    # TBD: update option_specs
     option_specs=(
-      '-C[change directory first]:directory:->dir'
-      '-I[include directory for makefiles]:directory:->dir'
-      '-f[specify makefile]:makefile:->file'
-      '-o[specify file not to remake]:file not to remake:->file'
-      '-W[pretend file was modified]:file to treat as modified:->file'
+      {-B,--always-make}'[Unconditionally make all targets]'
+      {-C,--directory=}'[change directory first]:directory:->dir'
+      '-d[Print lots of debug information]'
+      '--debug=-[Print various types of debug information]:FLAGS'
+      {-e,--environment-overrides}'[Environment variables override makefiles]'
+      '--eval=-[Evaluate STRING as a makefile statement]:STRING'
+      {-f,--file=,--makefile=}'[Read FILE as a makefile]:file:->file'
+      '-h[Print this message and exit]'
+      {-i,--ignore-errors}'[Ignore errors from recipes]'
+      {-I,--include-dir=}'[Search DIRECTORY for included makefiles]:directory:->dir'
+      {-j,--jobs=}'[Allow N jobs at once; infinite jobs with no arg]:number of jobs'
+      {-k,--keep-going}"[Keep going when some targets can't be made]"
+      {-l,--load-average=,--max-load}"[Don't start multiple jobs unless load is below N]:load"
+      {-L,--check-symlink-times}'[Use the latest mtime between symlinks and target]'
+      {-n,--just-print,--dry-run,--recon}"[Don't actually run any recipe; just print them]"
+      {-o,--old-file=,--assume-old=}"[Consider FILE to be very old and don't remake it]:file not to remake:->file"
+      {-p,--print-data-base}'[Print makes internal database]'
+      {-q,--question}'[Run no recipe; exit status says if up to date]'
+      {-r,--no-builtin-rules}'[Disable the built-in implicit rules]'
+      {-R,--no-builtin-variables}'[Disable the built-in variable settings]'
+      {-s,--silent,--quiet}"[Don't echo recipes]"
+      {-S,--no-keep-going,--stop}'[Turns off -k]'
+      {-t,--touch}'[Touch targets instead of remaking them]'
+      {-v,--version}'[Print the version number of make and exit]'
+      {-w,--print-directory}'[Print the current directory]'
+      '--no-print-directory[Turn off -w, even if it was turned on implicitly]'
+      {-W,--what-if=,--new-file=,--asume-new=}'[Consider FILE to be infinitely new]:file to treat as modified:->file'
+      '--warn-undefined-variables[Warn when an undefined variable is referenced]'
+      '--warn-undefined-functions[Warn when an undefined user function is called]'
     )
   else
     # Basic make options only.
@@ -191,8 +214,7 @@ _make() {
     ;;
 
     (target)
-    file=($opt_args[(K)(-f|--file|--makefile)])
-    file=$file[1]
+    file=${(v)opt_args[(I)(-f|--file|--makefile)]}
     if [[ -n $file ]]
     then
       [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file


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

* Re: [PATCH] Update make completion with gnu options
  2013-07-12  6:46 [PATCH] Update make completion with gnu options Nick Cross
@ 2013-07-12  8:38 ` Peter Stephenson
  2013-07-12 23:46 ` Bart Schaefer
  2013-07-17 15:35 ` Jun T.
  2 siblings, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 2013-07-12  8:38 UTC (permalink / raw)
  To: Nick Cross, zsh-workers

On Fri, 12 Jul 2013 07:46:25 +0100
Nick Cross <zsh@goots.org> wrote:
> Here are the additional commands for make. Thanks to Bart Schaefer who
> helped with correcting the make completion. I *think* its correct now
> ;-)

Thanks, I've committed it.

pws


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

* Re: [PATCH] Update make completion with gnu options
  2013-07-12  6:46 [PATCH] Update make completion with gnu options Nick Cross
  2013-07-12  8:38 ` Peter Stephenson
@ 2013-07-12 23:46 ` Bart Schaefer
  2013-07-13 17:00   ` Bart Schaefer
  2013-07-17 15:35 ` Jun T.
  2 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2013-07-12 23:46 UTC (permalink / raw)
  To: Nick Cross, zsh-workers

On Jul 12,  7:46am, Nick Cross wrote:
}
} -    file=($opt_args[(K)(-f|--file|--makefile)])
} -    file=$file[1]
} +    file=${(v)opt_args[(I)(-f|--file|--makefile)]}

The (I) subscript flag returns an array of all the possible matching
elements, so if there happens to be more than one file option the
above will not assign a useful file name to $file.


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

* Re: [PATCH] Update make completion with gnu options
  2013-07-12 23:46 ` Bart Schaefer
@ 2013-07-13 17:00   ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2013-07-13 17:00 UTC (permalink / raw)
  To: Nick Cross, zsh-workers

On Jul 12,  4:46pm, Bart Schaefer wrote:
} Subject: Re: [PATCH] Update make completion with gnu options
}
} On Jul 12,  7:46am, Nick Cross wrote:
} }
} } +    file=${(v)opt_args[(I)(-f|--file|--makefile)]}
} 
} The (I) subscript flag returns an array of all the possible matching
} elements, so if there happens to be more than one file option the
} above will not assign a useful file name to $file.

On the other hand, I see that you've no longer declared file as an
array, and the -f options are completed mutually-exclusively, so that
would only happen if someone explicitly typed out a command with more
than one such option and then attempted to complete targets.

However, the (i) flag would still probably be "more correct" here.


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

* Re: [PATCH] Update make completion with gnu options
  2013-07-12  6:46 [PATCH] Update make completion with gnu options Nick Cross
  2013-07-12  8:38 ` Peter Stephenson
  2013-07-12 23:46 ` Bart Schaefer
@ 2013-07-17 15:35 ` Jun T.
  2013-07-18  9:21   ` Oliver Kiddle
  2 siblings, 1 reply; 7+ messages in thread
From: Jun T. @ 2013-07-17 15:35 UTC (permalink / raw)
  To: zsh-workers

A few comments/questions on the recent patches for _make.

[1] I think the following options can be repeated

   -C   -I   -o   -W  (and their --long-option versions)

and '-C' etc. should be replaced by '*-C' in option_spec.
A simple patch for this will be posted in a separate message.

With the patch, 

   $ make -C /foo/bar -C <tab>

will correctly complete the subdirectories of /foo/bar.

[2] Other options can't be repeated. It may be better to replace, for example,

{-B,--always-make}'[Unconditionally make all targets]'

by

'(-B --always-make)'{-B,--always-make}'[Unconditionally make all targets]'

[3] If I set

zstyle ':completion:*:descriptions' format '%B%d%b'

and complete directory after -C or -I, the description I get is not 'directory'
but 'file'. It seems that this can be 'fixed' by replacing '_file' by 
'_path_files' at line 209, but I must say I haven't yet understood how/where
the description is determined.

[4] At line 156, _pick_variant is used as

_pick_variant -r is_gnu gnu=GNU unix -v -f

Why the last '-f' is necessary here?



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

* Re: [PATCH] Update make completion with gnu options
  2013-07-17 15:35 ` Jun T.
@ 2013-07-18  9:21   ` Oliver Kiddle
  2013-07-18 11:44     ` Jun T.
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Kiddle @ 2013-07-18  9:21 UTC (permalink / raw)
  To: Jun T.; +Cc: zsh-workers

"Jun T." wrote:
> 
> Why the last '-f' is necessary here?

Because otherwise, most non-GNU make's will actually attempt to make
stuff. The -v enables distributed building with some implementations of
make, for example. Unlike -v, the -f option is fairly standard and
supplying it without a filename is a fairly good way to ensure that any
make will print an error and exit.

Oliver


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

* Re: [PATCH] Update make completion with gnu options
  2013-07-18  9:21   ` Oliver Kiddle
@ 2013-07-18 11:44     ` Jun T.
  0 siblings, 0 replies; 7+ messages in thread
From: Jun T. @ 2013-07-18 11:44 UTC (permalink / raw)
  To: zsh-workers


On 2013/07/18, at 18:21, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
>> Why the last '-f' is necessary here?
> 
> Because otherwise, most non-GNU make's will actually attempt to make
> stuff. The -v enables distributed building with some implementations of
> make, for example. Unlike -v, the -f option is fairly standard and
> supplying it without a filename is a fairly good way to ensure that any
> make will print an error and exit.

Aha! Thanks for the clarification.

(important tricks of the trade are always undocumented...)


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

end of thread, other threads:[~2013-07-18 11:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-12  6:46 [PATCH] Update make completion with gnu options Nick Cross
2013-07-12  8:38 ` Peter Stephenson
2013-07-12 23:46 ` Bart Schaefer
2013-07-13 17:00   ` Bart Schaefer
2013-07-17 15:35 ` Jun T.
2013-07-18  9:21   ` Oliver Kiddle
2013-07-18 11:44     ` Jun T.

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