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 17710 invoked from network); 24 Feb 2021 18:58:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Feb 2021 18:58:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614193119; b=DIlS1jaGLBJmjr+uBIYedfT5qV9BzPygpJA0ajCAUVSI4ZBDPcPseye56TFO/misFQHA8QeiQZ FZrbbCHG+A4y/eNS93ruBP9f3f7cblB6W/YGpE2JTs/A+JzpvNtktMt9CA0c7T9GUMxPcR4bul zmCdud1nIHZrsv5oKsLzjD7UkOUIYc7RrCZV33ozg4fU30HOrLIpN+nauwfJ4mAgcIMgLmVyWO ZSIWkIOmbNjuU0xNkMwszgP82fPXi5GwIsAntvLzUJQdbA7h9GOh/QFS/avw4+49srHqk0r4v+ KVKMs0ZIti7UQ63KKcn5W3plL9+Eaj5UiBlYUJLTqwl9dg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f41.google.com) smtp.remote-ip=209.85.210.41; 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=1614193119; bh=JR9XBkhQ6sIGv76c732zH/P44/4R4mpAqaufws1j5u8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature: DKIM-Signature; b=J4b0sRzMtojDqxXGA/4Qlm6aPgZyW6g6wJkO9jBwrArJ1IfIcrRLlNQPeAebNV4LG4gVrBIiNG n5Sa3SdwsyAaftBOW6RLseUtkP0go6b4CWE72+C6xmVaWAw4q3+Bovc3S9dRF/7c3oTDzLCV7Z sErX2OnlB7F2OuGL2sxK2I83GipWKhLRvICtOALfoKA5Z9lLQ37V0MIAg0NtHga/yfB4x32oUJ JRqIEHk9+cumHpjxFF1uWW5MdnCF6QIyVxpP+25gmXIcHq+NcT26a9sP/flii26aZig29Sr1p5 DVLRRHb5aU/Izbvlc1EKH743764I5YHosaVX3ptVeunhMw==; 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:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=VpVF0nYZuC1o1/aCgFjUZ5PAKY8Voaeh49yMnVsDn0o=; b=d/nQ1/uTNwTSU2qyBUnsTfWyeD 3eikkih5z0eQjqWDxQZKiAXedoE2uT3TkW5IlF6xH8RQKIPSeWhLIeVWaP79w3Ia3n7MjUhLVlRr2 CpAoagX3pwS5g4TZac6m8C3j0fpgwZ9zfud7DDD7LrXLD+1G4DpGDuyiRs6YRAa48rSkV750mh7Mf hAUBsEYydxnss4Lfs91FCLwGMYep+VxAi0FApJ50msahsHDJSwO0Ar9AtiVQ9a14T+Acv0bcGbxx4 wPzaoNKEJ5Rdygwt19dV3rOd3PnMqmSdUu8RCkhHohQHUsMVhvbzgFUzVsjrmetjpBXjqfc7ylIFB 0Neou2LA==; Received: from authenticated user by zero.zsh.org with local id 1lEzMr-000EZz-43; Wed, 24 Feb 2021 18:58:37 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f41.google.com) smtp.remote-ip=209.85.210.41; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ot1-f41.google.com ([209.85.210.41]:43411) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lEzMX-000EQS-Bo; Wed, 24 Feb 2021 18:58:18 +0000 Received: by mail-ot1-f41.google.com with SMTP id v12so2065777ott.10 for ; Wed, 24 Feb 2021 10:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=VpVF0nYZuC1o1/aCgFjUZ5PAKY8Voaeh49yMnVsDn0o=; b=vewbe3l+Vw/3SkUT/DqvjYwNQKjEB73RcQP7C6Jn2m6BKiuEC8iwg/QYYQiU9AQ5ix 7+nJGzi/P9G9KzutVpLK4tnjLUHL8S7uuERBV80vxIgiuJLrjpnZooeEKgtK6pHXvgeu QIegYnvVL/GvqPSZ/avz+f3z/oiMkGQu6uS9lkFhglh4Eb2hbT5SP0wbv/cFc0TvrFbn tYTZyrt7nKeWwMispfLemXYdfVkVXPR9HcYJwyWREhAjoXJw0mhIHMcfnNtxvD4MQV0e VgtjcSmU1Yi3048L4nNH9pzmjV9jzeIJH9vj0NLcW7C7AE7o60mAzIKiq6MleWcWJHRj 6UzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=VpVF0nYZuC1o1/aCgFjUZ5PAKY8Voaeh49yMnVsDn0o=; b=f4HmSehHJXVY3tzRTmWUFyfeePgMXc/MURZp3XXKv5VvXl2FeWE5xmc2oiCJGJazkG sIhzO71dKbDYY1zL1LYbiTUbpBPKZTCEY3Oh8apIIdaeMU3rvGI+kVPKwiK79VFliq/c Bdq3+ygBCP+WnZPpJmFvfUeLkPESsD1WN3V9NP3v1nmOJ2BLTY8qc499zUeVnC4TSODt /7GLrLsQCk2UTscKDY3lxzh4x+Vp0uIj8ppqqfGdaqX1idHmdLpurieeavG9Cqqw1/j7 XmwdaxRAheFvY/huclqpa0MLZbmYhMg8bDTGQ4Gr6CUJeBA/3yihnsuFITkiAz/ESJBc BnlQ== X-Gm-Message-State: AOAM533sR6z1VSJh3Rl4MzndZ7F2nm9wA+YcSuw4kpY2aHNT90mfeuBo xvWpj+mcnG3MRlRNoSw/HMGyAbi1aq8= X-Google-Smtp-Source: ABdhPJyE4UJ6IWvxidqQWmvko/JYIxIuXDRsOKseGHbcCDfIv/eU9/3CBccFhfdeGNybgNgJlLN9Ag== X-Received: by 2002:a9d:ec7:: with SMTP id 65mr25418515otj.311.1614193095269; Wed, 24 Feb 2021 10:58:15 -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 i22sm513873oie.24.2021.02.24.10.58.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2021 10:58:14 -0800 (PST) From: Jacob Gelbman Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: Completion script for the ctags program Date: Wed, 24 Feb 2021 12:58:13 -0600 References: <31598-1614116362.902856@aI-l.maGv.3QD7> <20210224142437.GC9342@tarpaulin.shahaf.local2> To: zsh-workers@zsh.org In-Reply-To: <20210224142437.GC9342@tarpaulin.shahaf.local2> Message-Id: <0C896E5D-A157-48C7-8A51-D9A9DC4EA858@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Seq: 48111 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: This is my fault, I submitted it by pasting into the Mac Mail app, so = there is a ascii double quote that was changed to a unicode double = quote, in the file that was added to the repo. Also the line endings are = in dos, so that should probably be changed to unix line endings. = What=E2=80=99s the best way to submit these changes? Attach a .patch = file? > On Feb 24, 2021, at 8:24 AM, Daniel Shahaf = wrote: >=20 > 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