From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5097 invoked from network); 3 Mar 2021 22:08:47 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Mar 2021 22:08:47 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614809327; b=PtfpYRDWDCyBPgZCNY2FzV7nuwarVLS+au4/5buawGCdeW8hf+0rJgdtcC2ww9a345RZPOFRUp R1ofHokNIOOxUkUpA5J5jiMnWbKW94xMopF7qakkFJHSrAzAriqpBlQkvaJ0U/ULRluztLXYco UXKAKDRDTqaMc9BOv3GLwqJfL9zZPGi1uCP79mW0prChZoSq56qQlve2lja7gkAJ3dwbtSbhr0 gIoQi7ZX4Ovj2fC0gsn2P/dJb/rkhutnQpJtLO2Oe6MtHaht+gBMiMSy28rZFaU1KY+S/m7+Yh /TGzgekA/u3EnsKhKl35GZaQ71luMzMueXrybgK2F9DN5A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f178.google.com) smtp.remote-ip=209.85.167.178; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1614809327; bh=b+5A64h4nDgn3nsSy9rek3+/KU+Z64LAijpyrScKkmU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:References:Message-ID:Content-Transfer-Encoding:Cc:Date: In-Reply-To:From:Subject:MIME-Version:Content-Type:DKIM-Signature: DKIM-Signature; b=m00/LMlqmi8DjHL/0o+gUCRKRWw1J/AI3cySUWIYc7OXlXlEf9liqEADx39agqE7iipxg+fS33 ddlLPsiHCWA7HBvvSBwb1ERv6iUiTsxPYHwHo0D3xwPFIFQcHEWpYAO7fXjOXHOd50fAYlgdIq SytxJ/SOT4JdKcmO9JJcR3Hf+cbEIyGJbBKJSAa6MqoD1gDutsvUly+IiTS2c0OsABxV6D4rgx jRCHKf89J8gHEkK9XIf8ZpXh4HweYjOS7MxQocVOUb9Wq1PDj6NYNjQAW2cQEyztv3Jqn8xTsJ HglX4cyK2GfUwMKiurnoILT6/xvGAsNHVQy1DfJYTM7zgA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=EVf8w0xY3UrNwR8TDzLu/TVa1A61rcTchYq+toae/S0=; b=TKEIvruH/CdwovroUPdNzUbn63 FTdj2B/BHbkjaJWPUJR4Aeq2C+GGRIreynd7sGvdI51rNCrgSPHEIEYJdDc2HOUKQ0jEjYVcsyVQv LXXTmEGxI8O1NlebIYxoSU4Fv6c7GXMZxAmX983/G8/YpZMDs7J1ndwvUmhJSpJlhFIsuoQVZny4K pnlpd+Gv/2mjFVyLy1Lrt18koJtIWiT+6Q/7QReX0IBWIcPWoMSERBSCK2X4nrj7Vm0XpcaqQhMCv XcN1mszh0UCmLaTfW0oki7ngZG56xloWg8pTBmKt7iGS9Vk5RyF6Zg3wAgmjb6pVmeVDbGIK4QEjg 7OgqVu4w==; Received: from authenticated user by zero.zsh.org with local id 1lHZfi-000C2D-71; Wed, 03 Mar 2021 22:08:46 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f178.google.com) smtp.remote-ip=209.85.167.178; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oi1-f178.google.com ([209.85.167.178]:35092) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lHZfU-000Bsy-81; Wed, 03 Mar 2021 22:08:32 +0000 Received: by mail-oi1-f178.google.com with SMTP id i21so25518746oii.2 for ; Wed, 03 Mar 2021 14:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=EVf8w0xY3UrNwR8TDzLu/TVa1A61rcTchYq+toae/S0=; b=Gn/oyKYDhHU40vHtA71o6HzPxvxvwStHGAhjUBfXNMRCPYB1LuJdCxxiTHYXwp8YzP 1DxvWeVlFhmRN1y/mQVxOINOtxyW96NgPDOhqGHgQTBVy4TQq0KPZfj1FVbM9blsOrWK a5XQrC3FYLwBWmn1cnAFi6/kUHBgtgaqtd62i6Q6/DTj0CusnITeA0FtS8Fupdhx+Llk H6DLF9ChGC3yO9zRJqQAmYXB4D7ouv+8bfM4M1hpPXwakarNYW90sxl1euaKzjbXBs8G T636HnHwKhvAVCEd2oqDYDxo3FaVfKMBq4F0f7dPCHcAbpzClU3UiA0t5khUNJVf56wB Nc+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=EVf8w0xY3UrNwR8TDzLu/TVa1A61rcTchYq+toae/S0=; b=ipT0/OuinFbk0Bnci1R7+CdngOIC7mBA9kxC+lKW9sASFRdFlsMz36ObUKkWZup2v5 4TI4xRDRAg5815qdw1bJG2Lb6HeQwB5yFNq53i2lFlxytHTdOLShuxvla6KpvnqrT5Ef CJ0uhEKbe+C6pxFBf7sGKV+fMxGrAZ81fxEqQPO2ABVkmfot+ICMVYMqpTB65Ax+F4oH mD00w178EBx3r/qKR2mM+wjouCa3GoSlgw4sT3DlJr8wLrsN8Xqfnq7f2385HN43FeZp /Gh4Y6uCiszT9R++ZcE2Tbrru+UcEcuEa9jcduW4uGXMjEMatpBiaB+pQCmepXYmIjg3 WJ1g== X-Gm-Message-State: AOAM532HoI4caQuqtcPtGZiOF3uitC8qEnYZC9u8/6MpEbNrACdThgsn BMOrYQroB1KdCFL8vzsAdwp4Dq8yq2o= X-Google-Smtp-Source: ABdhPJwZpOyRBc3oHNru1qelohVuL0xJ+ZmdV17nMLizcXvKZe9Td8W6Sx4VeHhfa2+LrD7sDsZk4g== X-Received: by 2002:aca:c48c:: with SMTP id u134mr822855oif.31.1614809311132; Wed, 03 Mar 2021 14:08:31 -0800 (PST) Received: from ?IPv6:2601:2c3:ca81:7bc0:147a:84dc:a9b:ce74? ([2601:2c3:ca81:7bc0:147a:84dc:a9b:ce74]) by smtp.gmail.com with ESMTPSA id f13sm4946772ooo.45.2021.03.03.14.08.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 14:08:30 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: Completion script for the ctags program From: Jacob Gelbman In-Reply-To: <20210303200215.GA11821@tarpaulin.shahaf.local2> Date: Wed, 3 Mar 2021 16:08:29 -0600 Cc: zsh-workers@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <31598-1614116362.902856@aI-l.maGv.3QD7> <20210224142437.GC9342@tarpaulin.shahaf.local2> <20210303200215.GA11821@tarpaulin.shahaf.local2> To: Daniel Shahaf X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Seq: 48136 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: I don=E2=80=99t want to get too fancy or complicated with this = completion script, I just want to provide something helpful for 90% of = the time, and I don=E2=80=99t mind it showing a completion for an option = that is meant to be modified. That said, if someone else wants to make = it better in some way, that=E2=80=99s all good. Just I don=E2=80=99t = think it should add all the options that it could be because it would = make the output too long to read. I can=E2=80=99t think of another = command that has options like this, maybe head or tail, which take an = option like -, like -5, the completion script just ignores = options like this, because the command has a -n , so that=E2=80=99= s just as good. kill -, like kill -INT, is kind of similar, but = listing all those options doesn=E2=80=99t result in output that=E2=80=99s = too long. > On Mar 3, 2021, at 2:02 PM, Daniel Shahaf = wrote: >=20 > Jacob, ping? Is a followup patch in the offing? >=20 > As already mentioned, I think some of the review points below are > release blockers. >=20 > Daniel >=20 >=20 > Daniel Shahaf wrote on Wed, Feb 24, 2021 at 14:24:37 +0000: >> Jacob Gelbman wrote on Wed, Feb 24, 2021 at 01:20:24 -0600: >>> #compdef ctags >>=20 >> apt-file(1) on Debian stable shows a few more names: >>=20 >> arduino-ctags: /usr/bin/arduino-ctags >> emacs-bin-common: /usr/bin/ctags.emacs >> emacs-bin-common: /usr/bin/etags.emacs >> exuberant-ctags: /usr/bin/ctags-exuberant >> universal-ctags: /usr/bin/ctags-universal >> xemacs21-bin: /usr/bin/etags.xemacs21 >>=20 >> I assume at least some of these should be added to the #compdef line. = Would >> you do the honours? >>=20 >>> "--alias-=3D[add a pattern detecting a name, can be used as = an alt name for lang]:pattern" >>=20 >> As Oliver said, literal angle brackets in the option name to be >> completed aren't especially helpful. In fact, I'll go as far as to = say >> I don't want users to run into it in released code. Please change = them. >>=20 >> You can use _call_program with --list-languages to generate the right = set of >> option names dynamically. >>=20 >>> elif [ "$_ctags_type" =3D "exuberant" ]; then >>> arguments=3D( >>> "-a[append to tags file]" >>> "-B[use backward searching patterns (?...?)]" >>> "-e[output tag file for use with emacs]" >>> "-f[write tags to specified file. - is stdout]:file:_files" >>=20 >> Is the argument to the -f option allowed to be pasted to it? If so, = s/-f/-f+/. >>=20 >> Also, s/:file:/:output file:/. That part of the string is a = user-facing >> message, so the extra detail is helpful. >>=20 >> Also, you can drop the "- is stdout" part. The descriptions are only >> a summary of the functionality; they aren't meant to be a complete = copy of >> the manual. >>=20 >>> "-F[use forward searching patterns (/.../)]" >>> "-h[specify list of file extensions to be treated as include = files]:" >>=20 >> Write something after the colon. >>=20 >>> "-I[a list of tokens to be specifically handled is read from = either the command line or the specified file]:" >>=20 >> The thing in brackets doesn't describe the action of the option. = Please edit. >>=20 >>> "-L[a list of input file names is read from the specified file. - = is stdin]:file:_files" >>=20 >> Rephrase in the imperative. >>=20 >>> "-R[equivalent to --recurse]" >>=20 >> This is normally rendered as: >>=20 >> '(-r --recurse)'{-R,--recurse}'[description]' >>=20 >>> "--fields=3D[include selected extension fields (flags = afmikKlnsStz)]:flags" >>=20 >> Recommend to move the afmikKlnsStz thing to after the colon, so it'll = be >> shown at a more appropriate point. Also, it would be helpful to = display >> descriptions to the flags using, e.g., =C2=ABcompset=C2=BB (for the = leading plus >> sign) followed by =C2=AB_values -s ''=C2=BB. >>=20 >>> "--file-scope=3D[should tags scoped only for a single file be = included in output]:bool:(yes no)" >>> "--filter=3D[behave as a filter, reading file names from stdin = and writing tags to stdout]:bool:(yes no)" >>> "--filter-terminator=3D[specify string to print to stdout = following the tags for each file parsed when --filter is = enabled]:string" >>> "--format=3D[force output of specified tag file format]:level" >>> "--help[help text]" >>=20 >> "help text" is just a noun phrase. Please use complete decsriptions. >>=20 >> Please use exclusions if needed (=C2=AB'(--foo)--bar[baz]'=C2=BB). >>=20 >>> "--language-force=3D[force all files to be interpreted using = specified language]:language:->language" >>> "--languages=3D[restrict files scanned to these comma-separated = languages]:language:->languages" >>=20 >> Can't say I'm a fan of having two states that differ by a single = letter, >> but so be it. >>=20 >>> "--recurse=3D[recurse]:bool:(yes no)" >>=20 >> Fix the bracketed description. >>=20 >>> _arguments $arguments >>=20 >> Pass any arguments to _arguments that may be needed (for >> instance, -s). >>=20 >>> if [[ "$state" =3D language* ]]; then >>> local -a languages >>> languages=3D(`ctags --list-languages | cut -d" " -f1`) >>=20 >> Use _call_program and $service. >>=20 >>> if [ "$state" =3D "language" ]; then >>> _wanted languages expl language compadd $languages >>=20 >> Don't pass unsanitized command output to a builtin. In this case, >> =C2=ABcompadd -a languages=C2=BB would do. >>=20 >>> elif [ "$state" =3D "languages" ]; then >>> _values -s , languages $languages >>=20 >> Don't pass unsanitized command output to a builtin. I don't know the >> fix off the top of my head. >>=20 >> Thanks for the patch, and especially for adding exubertant and BSD = ctags >> support! >>=20 >> Daniel >>=20 >>=20 >>>=20 >>>=20 >>>=20 >>>=20 >>>> On Feb 23, 2021, at 10:45 PM, Jacob Gelbman = wrote: >>>>=20 >>>> Hey, thanks for looking at the script and adding it to the repo, = although I think some of got pasted in wrong. There=E2=80=99s a lot to = writing completion functions and I=E2=80=99m still not 100% sure how to = do it right. >>>>=20 >>>>> On Feb 23, 2021, at 3:39 PM, Oliver Kiddle wrote: >>>>>=20 >>>>> Jacob Gelbman wrote: >>>>>> I wrote a completion script for the ctags program. Someone might = be able to use it: >>>>>=20 >>>>> Which ctags!? >>>>=20 >>>> I have Universal Ctags 5.9.0 >>>>=20 >>>>> This doesn't match what I have installed on any of my systems. = There >>>>> are multiple implementations of ctags, with it often being just a = link >>>>> to etags - for which there is a completion albeit not a well = maintained >>>>> one. One of the main reasons, a completion doesn't already exist = is >>>>> that it would ideally need to detect the variant and at least have = sane >>>>> fallbacks for variants that aren't handled. It could be useful to = check >>>>> what the existing _etags is handling - that might be the = exhuberant or >>>>> emacs variant. >>>>>=20 >>>>=20 >>>> I located a few other ctags on my computers, I have BSD ctags that = comes by default on the mac. Exuberant Ctags 5.8. and there=E2=80=99s = etags that comes with emacs. I can probably add an if statement based on = the output of ctags =E2=80=94version, and modify the function from that. = If it=E2=80=99s etags, I=E2=80=99ll just: >>>>=20 >>>> _comps[ctags]=3D=E2=80=9C_etags=E2=80=9D; _etags >>>>=20 >>>> And exit. >>>>=20 >>>>> In general, please follow the conventions outlined in >>>>> Etc/completion-style-guide in the zsh source distribution. For = example, >>>>> completion functions usually use just 2 spaces for indentation. >>>>>=20 >>>>>> #compdef ctags >>>>>>=20 >>>>>> local state >>>>>=20 >>>>> If you use states, you need to also handle the context which means >>>>> either passing -C to _arguments and setting up $curcontext or = declaring >>>>> context local and passing it to later functions like _values. >>>>=20 >>>> The -C argument and the context/curcontext variables are confusing = me, a lot. >>>>=20 >>>>>=20 >>>>>> "--alias-=3D[add a pattern detecting a name, can be used = as an alt name for lang]:pattern" \ >>>>>> "--input-encoding-=3D[specify encoding of the input = files]:encoding" \ >>>>>> "--kinddef-=3D[define new kind for ]:kind" \ >>>>>> "--kinds-=3D[enable/disable tag kinds for ]:kind" \ >>>>>=20 >>>>> These would not complete especially helpfully. I suspect that = there is >>>>> supposed to be substituted. >>>>=20 >>>> They=E2=80=99d show up in the menu when you press tab, but if I = filled in the actual values, the list would be too long. >>>>=20 >>>>>=20 >>>>>> if [ "$state" =3D "language" ]; then >>>>>> compadd `ctags --list-languages | cut -d" " -f1` >>>>>=20 >>>>> It would be nicer to use a description by calling for example, = _wanted >>>>> here. >>>>=20 >>>> I can do that. >>>>=20 >>>>>=20 >>>>>> elif [ "$state" =3D "languages" ]; then >>>>>> _values -s , "languages" `ctags --list-languages | cut -d" " = -f1` >>>>>> fi >>>>>=20 >>>>> I'd probably use _sequence here as it is smaller and simpler. But >>>>> _values is fine if none of the languages contain characters that = need >>>>> quoting from it. >>>>=20 >>>> This too. >>>>=20 >>>>>=20 >>>>> The return status from this function will not be correct in all = cases. >>>>> This can have effects like approximate completion being activated >>>>> despite matches having been added by earlier completers. Where = states >>>>> are needed, you nearly always need to either save the status from >>>>> _arguments, typically via a ret variable or check = $compstate[nmatches] >>>>> on exit. >>>>>=20 >>>>> Oliver >>>>=20 >>>=20 >>>=20 >>=20