From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17192 invoked by alias); 19 Jun 2015 15:20:43 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35529 Received: (qmail 20698 invoked from network); 19 Jun 2015 15:20:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1434726886; bh=i/VmVKoqaO3w3Xex0bgOqz7/ru3CbvvXLUL4408+gJw=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=f8HGNbQV4MO0rhl4lZQKWibJh31xeT9iJcxwnuRi/slm7HwL9ZdOg/17V/kR134v0+NzPreQLrZZODUbUk5/2QH08dxhY58lh3YrKzEfDG8+CAjXnrmGf3YaOIelsWJEVhFKzkkmtwfFsV+56VaEx0tHMLH6rn/t4cwa2vIrg8+2MI0c2XAD91DiWBKeNp1WCQCkeesB1dG9JkHQHWSzMiqz2hAIwWn19FpmyVuUo3x6vChOVFm3sCJ6z4PY0/R2OvH3CwHanXOKLOUtpcDLGhQo2CIyZVuU6SQk1YbUARiY51pQY8LA/vc2N5zzX28JLOxNJla5zb1xrIImLUGXTA== X-Yahoo-Newman-Id: 976543.70865.bm@smtp128.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: GahZyzoVM1l5GusY3q4e5Cj93bNuNvr1InM.hd7saC.mpZE uFE8p_.Kxu_QerUllLOsFcdZvVjhmuLHoW5sJmmvQg0IROecG9oVZiEf1Goe G5Ju7k0kJfYpVKyboxr3irBLSo.g1TnaVqoB0NY9u7uZ_s7ktryhIsW79Cu4 3OGDSMesFzpezB.rudjzbtVPwPFhzi9h2QuBbCzEwN5asxLqODumono986bm tLndqdwjjPOkfTPbFqhFi82GXomEA1zBqejPxiizmscF_qBFpfAWhUTM_UEj qTLvjHLpUEjbUKV0RBIJgizKjG34YcGg48R7b_wyhmYS55uHu03EGdWwONcH tjVqM._Wta9UoYbAixTf_FrMMMgYiBrA6goaaDQNXkkpPCmJKn6xk0fTqXnd k5qnmjLmcSKBENJi0bh2VDBZYR99r8dNsNTCbNWowJcT4OkOSlSfw4UcZITw tUasn8IEWR9.q0yIFdHVvkIaiGEPQLNQUv2ru6Y20h_tcQcRq.JhQG7rowxs ZTLxD0NGam9sILlXxoY2Q76_XcU5ppA-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: zsh-workers@zsh.org In-reply-to: <87bngcpwer.fsf@topbug.net> From: Oliver Kiddle References: <87bngcpwer.fsf@topbug.net> To: Hong Xu Subject: Re: BUG: java command auto complete is incorrect if `-jar` is used MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6391.1434726884.1@thecus.kiddle.eu> Date: Fri, 19 Jun 2015 17:14:44 +0200 Message-ID: <6392.1434726884@thecus.kiddle.eu> Hong Xu wrote: > java [ options ] -jar file.jar [ argument ... ] Thanks for the bug report. This was broken in message 13914, replacing _default by _normal. There seems to have been some notion at the time of making it easy to provide a function for particular java applications. I'm not sure how it might have helped in that case because the jar file is not assigned to the first element of $words. The following patch adds an = to the _arguments spec as follows as an alternative fix for this. I'd have been inclined to revert to _default but maybe I've missed something. - '*::args: _normal' \ + '*::args:= _normal' \ The patch is also a partial job of updating other java options though some of them have grown to the point where the option completion is less useful. Oliver diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java index 7b1dce1..2aef15a 100644 --- a/Completion/Unix/Command/_java +++ b/Completion/Unix/Command/_java @@ -7,45 +7,76 @@ typeset -A opt_args tmpassoc jdb_args=() case "$service" in +javac|jar) + if compset -P @; then + _wanted files expl 'option file' _files + return + fi + ;| # continue javac) _arguments -C \ '-g-[generate debugging information]:debug:->debug' \ + '-A-[specify option to annotation processors]:option' \ + '-implicit\:-[control generation of class files for implicitly loaded sources]:implicit:(class none)' \ '-nowarn[generate no warnings]' \ '-verbose[output messages about what the compiler is doing]' \ '-deprecation[output source locations where deprecated APIs are used]' \ - '-classpath[specify where to find user class files]:class path:->classpath' \ + '(-cp -classpath)'{-cp,-classpath}'[specify where to find user class files]:class path:->classpath' \ '-sourcepath[specify where to find input source files]:source path:->sourcepath' \ '-bootclasspath[override location of bootstrap class files]:bootstrap class path:->bootstrapclasspath' \ '-extdirs[override location of installed extensions]:extensions directories:->extdirs' \ '-d[specify where to place generated class files]:directory:_files -/' \ '-encoding[specify character encoding used by source files]:encoding:->encoding' \ - '-source[provide source compatibility with specified release]:release:(1.{2..5})' \ + '-proc\:-[control annotation processing]:annotation processing:(none only)' \ + '-processor[specify annotation processors to run]:class:_files' \ + '-processorpath[specify where to find annotation processors]:directory:_directories' \ + '-s[specify directory for generated source files]:directory:_directories' \ + '-source[provide source compatibility with specified release]:release:(1.{2..8} {5..8})' \ '-target[specify VM version]:release:(1.{1..5})' \ - '-help[print a synopsis of standard options]' \ + '(-)-help[print a synopsis of standard options]' \ + '(-)-version[print version information]' \ + '(-)-X[display information about non-standard options]' \ '*:java source file:_files -g \*.java\(-.\)' && return 0 ;; jdb) jdb_args=( '-host[specify host to connect to]:host:_hosts' - '-password[specify password]:password:' + '-password[specify password]:password' + '-attach[attach to running VM]:address' + '-listen[wait for VM to connect]:address' + '-listenany[wait for VM to connect at any available address]' + '-launch[launch VM immediately]' + '-listconnectors[list the connectors available in this VM]' + '-connect[connect to target VM]:connector' + -dbgtrace -tclient -tserver + '-J-[java runtime option]:option' ) ;& java) _arguments -C \ "$jdb_args[@]" \ + -client -server -d32 -d64 \ + '-agentlib\:-:agent library' \ + '-agentpath\:-:path:_directories' \ + '-javaagent\:-:path:_directories' \ '(-cp -classpath)'{-cp,-classpath}'[specify path for user class files]:class path:->classpath' \ '-D-[specify a property]:property:->property' \ + \*{-enableassertions,-ea}-::class \ + \*{-disableassertions,-da}-::class \ + '(-enablesystemassertions,-esa,-disablesystemassertions,-dsa)'{-enablesystemassertions,-esa,-disablesystemassertions,-dsa} \ '(-verbose:class)-verbose[print class information]' \ '(-verbose)-verbose\:class[print class information]' \ '-verbose\:gc[print gc information]' \ '-verbose\:jni[print JNI information]' \ - '-version[print version]' \ - '-help[print help message]' \ - '(- 1)-jar[specify a program capsulated as jar]:jar:_files -g \*.jar\(-.\)' \ + '(- 1)-version[print version]' \ + '-showversion[print version and contrinue]' \ + '(- 1)-'{\?,help}'[print help message]' \ + '(- 1)-X-[non-standard java option]:option' \ + '(- 1)-jar[specify a program encapsulated as jar]:jar:_files -g \*.jar\(-.\)' \ '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}' \ - '*::args: _normal' \ + '*::args:= _normal' \ && return 0 ;; @@ -111,16 +142,20 @@ jar) '(c t x )u[update archive]' \ 'f[specify archive file]' \ 'v[verbose mode]' \ - 'm[specify manifest file]' \ + '(e)m[specify manifest file]' \ + '(m)e[specify class of for application entry point]' \ '0[store only without using ZIP compression]' \ - 'M[do not create manifest file]' && return + 'M[do not create manifest file]' \ + 'i[generate index information for specified jar files]' && return else jar_cmd="${words[2]#-}" tmpassoc=( m ':manifest file:_files' + e ':main class' f ':archive file:_files -g "*.([ejw]ar|zip)(-.)"' ) - _arguments -C \ + _arguments '*-C[directory of class file]:directory:_directories' \ + '-J-[java runtime option]:option' \ "${jar_cmd/[^-]*/:dummy:}" \ ${${(s::)jar_cmd}/(#b)(?)/$tmpassoc[$match[1]]} \ '*:file:->jararg' && return 0 @@ -140,6 +175,7 @@ javah|javah_g) '-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \ '-old[generate old JDK1.0-style header files]' \ '-force[force output]' \ + '-J-[java runtime option]:option' \ '*:class:_java_class -m main ${(kv)opt_args[(i)-classpath]}' && return 0 ;; @@ -558,20 +594,14 @@ docsrc) ;; jararg) - if [[ -prefix - ]]; then - tmp=('-C:chdir') - _describe -o 'option' tmp -- && return - elif [[ "$words[CURRENT - 2]" == -C ]]; then + if [[ "$words[CURRENT - 2]" == -C ]]; then _wanted file expl 'input file' _files -W "($words[CURRENT - 1])" && return - elif [[ "$words[CURRENT - 1]" == -C ]]; then - _wanted directories expl 'chdir to' _files -/ && return elif [[ $words[2] = *x* ]]; then jf="$words[3]" if [[ $jf != $_jar_cache_name && -f $jf ]]; then _jar_cache_list=("${(@f)$($words[1] tf $jf)}") _jar_cache_name=$jf fi - _wanted files expl 'file from archive' _multi_parts / _jar_cache_list && return else _wanted files expl 'input file' _files && return