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 27362 invoked from network); 3 Mar 2021 20:39:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Mar 2021 20:39:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614803979; b=NAbT2I2DP7GDxCquaXhezy3/avNjhnTcp9URk+oGgjCFsDPmJ0S74j/nN9mAle+YKQ9o65uISh u8DQe+bi0OvWIxvgKR2loiuFLXIjhRbNj/xlDe2rc/toJRufuatZXy39oecp0HfmMhJN8eIEhA rG1GD+jqMaO0wN3NmCk+n/kLHNhRrex9iXMmkxby/Db9oxnyqejxoilsvRjiQ8pHzRIT1VrTnZ kRypAUKIVs4IP90ErVLHK7vmNIteh0U4ObunSBD5g3faR+1yXPXTizT+KhRqxAxObpBGdiScJK rxuYeCxCfVdTfpzLo8yvbynrYpLh24B9Py4LJv6c4yjPQw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f176.google.com) smtp.remote-ip=209.85.167.176; 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=1614803979; bh=aMYsp2BK51IdFRjS01E+Bm/mTAx+XFosAyBLbcIUcms=; 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=TvcVflgohHLAoQf/k2IVsBmi7L0pKwo4LpGmGIiZs4CHqq8BNO541YNPNdjb3WrgNjf24NaUA3 c8Y6nj4HtN5HlYin6wiIuBUhi/K0uN2J6Vt99IjvPWBFS8ArN0XeIJpPcZDMdhj5Hrn4Q083EJ o1oH1iCq4gIYoYXrjeVpu5j51V9hBC63A5PmviZBGgoqYSJh2Ul3HXcU3iU3lZoNDkbMNqp61D jWY0GKQpfbVKgxPlX6b9leHXQ9X9nV2mI3DB6LI/fZqhWYMEbjny4FIvCl7sAI0S4iNHNoojh4 9Imq/rARQzyi7dFpHniplCXvGPwDWsMM923ikE3RBdm60Q==; 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=g2xw80sHddpLyNkSrJKR+KcGtDNZQllOSPXX4nToHrU=; b=uV1VhZsEG5umstnDirgNON9AH3 1WaEqoD94aiFIjFV/zjokEYv9l0gzNSDICOkiGUH2r1Kd+PHvpVDyH1/SDMbSl4uXGQn1BID2F+QJ U7fXVXqEUfMj6AUMWuxX2685G7aHUJFONEh+7Bbt3r1DjuEfaIfSexWkm3F+28DbhWBe1ZqtPs0Em 2fTv1dgUQoPG/8oiZvPdDH3/W8c7zn7RQPfzj8flzeDRMPb0gJQSiuro1W/mgCNTJmds2jfEZ0GEM bjPmia6CuIsCCC/k+pZSPyB0FAqM9yZF+tBRdvcASomSlQ5BERcS59yCm9hAYzfPvBvZJxNlUXYtc 1Xm4K1wQ==; Received: from authenticated user by zero.zsh.org with local id 1lHYHS-0009Dy-8Y; Wed, 03 Mar 2021 20:39:38 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f176.google.com) smtp.remote-ip=209.85.167.176; 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-f176.google.com ([209.85.167.176]:42282) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lHYH7-00094P-E1; Wed, 03 Mar 2021 20:39:19 +0000 Received: by mail-oi1-f176.google.com with SMTP id l64so27485706oig.9 for ; Wed, 03 Mar 2021 12:39:17 -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=g2xw80sHddpLyNkSrJKR+KcGtDNZQllOSPXX4nToHrU=; b=Iy2gyycWM6zB/yV8bHrW2R1uRLMGGE3sU0CqCXrWnErcCYdv4neyDb62MfUgQU+TJ7 LFPBfRpodxiSyL8Q3QAhKMIkaUjb/TWetA2Ouxppft5Qh9ZkbSYL63EDcRdaQgrF2/VI QftmJTGI55vt8uKK2SXE24ujke9uRyw1WV8C+zlFNIExfxWyOJR+e0B3Ww1Hq+M1VT48 mgMXSElGAN4HeKOBngoU9EekoW2JKFC+/V09YPB5ECWLm+wvDVXkzj/7ubYnqRHCYhas 0qUsmlii3U/exD2n2HtT5MGrRnk7kK52jAOlHjDXSGgqBgPYHhNW2SkM6FeKMB61tbvE ezEA== 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=g2xw80sHddpLyNkSrJKR+KcGtDNZQllOSPXX4nToHrU=; b=mVkyn87qzU/HWJWWMtDJEe7nm+w/FoBtCStdO0vl0Juo0zdx/A2XO4ICjVFUJMZFQV rHiYP5/KBE/u9/oE40GE11qkzkYwfRG5wuhChdHNJlUjq/6NEvNlJgczD/tALty5ftVj 8XhXaDl7lpjSgRgLnBkd9x+x5S3KJKQlj+TLzVg4Y0sWTTXAnozTn2WO4OYw5QOcPve3 nIuBlATj2zmhdcCKlQqxwMPZn+Om/a2lLVwjEFoWcqiUYl7j0P8R4PbnNnVV00+n1QrP k1KGOecjDFtDUWk/Nvv8+FQaomLzS5JS/33Ax5OSASHvzfUN6FqX5FGl4HcKaLri35+5 2dBw== X-Gm-Message-State: AOAM53059l+PmlwakU0jTukRm/v3xPGjjyXxNfZFOIZP8BjAeQ61mU1u pmT1TG1n0ezeDIjDBT8bMi4FGFrZiW8= X-Google-Smtp-Source: ABdhPJy6u1/rbGEPdG03zOFFfK4q5twZZ8vhjWIxqa6uo45MgzE0FBA3nfXp4Xn4IMZd5WVdCOAnPQ== X-Received: by 2002:aca:1714:: with SMTP id j20mr567578oii.2.1614803956140; Wed, 03 Mar 2021 12:39:16 -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 u7sm2777369oic.3.2021.03.03.12.39.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Mar 2021 12:39:13 -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 14:39:12 -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: 48133 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 got a little bit hung up on one of the points, which was what to do = about option names that can include the language such as = =E2=80=94alias-, =E2=80=94extras-, =E2=80=94fields-, = =E2=80=94input-encoding-, and many more. If I actually added what = the could be, the listing would be too long to read. I like it to = just show the format of the option, just so you can see it in the = listing when you press tab, but not overwhelm the output. I can do the other things though. > 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