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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23285 invoked from network); 3 Mar 2021 20:02: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:02:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614801759; b=UCj+CPy+ndWDIh8qZ3qVLQouq6dBl8hq3lvdTPHATCmIvkT9juYTvyDe9P5SVpMbwV1OKfXSV/ SGA1YuAviD8jsUf5FKO3XKIt6XTBaOJZDfgIGT1G7Rc3rKpQLCpyLbbD6Wl8UorKQU29cXFyPp i3+u7N+sNw/Eb3qCpjso+hBm8c5RPo7F4nMBq6BidgcoRPYm7s2EPFx9jXbLkPbBjGRtWpXH/K BSRX0WjcWh4nEQkuYY16aA7SSH9RxICSQv+km/lcLPZkOc6sAvByR98SjZCqvOcyPX5CfZ5PJT 0FiOVntiO+qIMVnKTw6weIEORVTTrMP+7ArTqE3HcGphrA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1614801759; bh=pVwSK29j6pshvXK0FD2/WZue4i9B0HaZ1xSG8NSn4wg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=gAO1Grf/RDR1leAkp2h2GDxmwTW/bIR1PwrUKghHsSmfWjufnRtD3rO2wn0Iu1jv+c/mJZjtFb Z65xLIVDA7Tvlz4nTacQFFihaLyOrzG/eh//DTqgX0cDaaVdxTB2BlmDmNLLw72e5gzjKR6B8+ dYoiY6+4hGIXQ0YAHFbvukRU1zc2UluQAOWVeqU6DH6sTF/Dg40Gu0g2sjmgNbFjP3Z9EbomVG FuAPprWoJwEmU04OtMKMyvVRdwlshLZmmarWe2lOnpGRz2AHgrL5VTCIOUspFZHBdHqA8N6TOH KSBf47nnnh/G4ZweCZzw0GdfzUFXcukLC2OX4Q/U0HA3cw==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=zsWzda3x40KtM8PXMucM3AwEGJFvxUHRODCnUlLL5TU=; b=HSj2eUfL3ahDb0QfXBQB/qJKqp j7hrsK7ZWsYYp3w0foB84yY2M7r9Q9TgjnkdY84UoJsZGQKPfTqth4fYmltTmpYYfnpF18hG8dbqH SUmIWFSAq2citCJv4029yBc4tnhLScxrxPHdQ69ewTgcKT91LHnz691zixdh2eNVpIeZNMXo8tiVS drKFzGRLrpT5ruvIjGEViYNTQI3KwLpCpt6fRL26PjWzzH7W0etmNgeh0UNgtQ+rkTzbhrR8SlOkY VPn7LJZtaN7ZCEQG2lyiLoRXftKmXP88TqYJ91uJ58oGSbmrhRQz7TCy57D7hDWUN2dg09UF88xzy 7DI1+qBg==; Received: from authenticated user by zero.zsh.org with local id 1lHXhe-0007YC-FU; Wed, 03 Mar 2021 20:02:38 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:52625) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lHXhL-0007PP-HG; Wed, 03 Mar 2021 20:02:21 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 950F65C0067; Wed, 3 Mar 2021 15:02:17 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 03 Mar 2021 15:02:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm2; bh=zsWzda3x40KtM8PXMucM3AwEGJFvxUHRODCnUlLL 5TU=; b=ddgVcKV0VO0XXRpyXE5LGRpHEd/vXM9ArtnqGLtk4NI0TzSa7QzYd5hz hpIKC5LsqH2GUQxClba9z9e1vh33anrDRAjEhhTMtj/hV0tV+xG+bjoByyKjpghy J0vMIFMGb+/TXH62gmr+XQS98qLvk0DZV2dQw9ukQGwCe9FXSte1bzxoWOhKlCtI oqGXLJaDm6HXjsVb2jDzaAISTwAiO8y9/Xfr4fsSDwVyJD5ajB7wVcEbHu2sqqhw vL6c4HgLrzhKjIAvUgw0Vfc1rEG3a//M/jTtynKAhE8UmWarSpyD6xObzmZmGrsR XQ+38S/ZpkuXRp3PyDRnsWaNHWColQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=zsWzda3x40KtM8PXMucM3AwEGJFvxUHRODCnUlLL5 TU=; b=ew9vdX7Sp75Vl7z9XRc8qLpYRYYBbb/1feqxojuQaISk5kR8on2CB8MXg xY7FLcbn4R9+n+PCCDkCpoE4ICYzbkmF8SU1Vn45GvlriNSK9qA5Acl0TDBCQz7d asQfcSX+F0uMOQUfkZOM6slKBCYmoo9PTd85DYnMRuebRL3YPLfl7IFLgvWFUekU sFe70/+aRjTAH8JgL0GzJydRLCIRa3AEFkh/DisPHH2enFvRQU5owcKRW86T7UBY mcK4L9ys+orM+QrSYQWkb7uegS/GKfecpMRpJQ3AOqv4PmyeKkRiVkKZBHK1JV02 DrVpiJjVRt/vqg/sgV5U+4tSAJnTQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddtvddguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggugfgjfgesthektddttderjeenucfhrhhomhepffgr nhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg eqnecuggftrfgrthhtvghrnhepgfekgfefjefgvddvgfdutdelleekvdefteeitdduhfev veevudfhvdevfeefvdeunecukfhppeejledrudejledrheelrdduvddtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghl rdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-179-59-120.red.bezeqint.net [79.179.59.120]) by mail.messagingengine.com (Postfix) with ESMTPA id 176D6108005F; Wed, 3 Mar 2021 15:02:17 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4DrPzW214yztD; Wed, 3 Mar 2021 20:02:15 +0000 (UTC) Date: Wed, 3 Mar 2021 20:02:15 +0000 From: Daniel Shahaf To: Jacob Gelbman Cc: zsh-workers@zsh.org Subject: Re: Completion script for the ctags program Message-ID: <20210303200215.GA11821@tarpaulin.shahaf.local2> References: <31598-1614116362.902856@aI-l.maGv.3QD7> <20210224142437.GC9342@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210224142437.GC9342@tarpaulin.shahaf.local2> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48132 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: Jacob, ping? Is a followup patch in the offing? As already mentioned, I think some of the review points below are release blockers. Daniel 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 > > apt-file(1) on Debian stable shows a few more names: > > 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 > > I assume at least some of these should be added to the #compdef line. Would > you do the honours? > > > "--alias-=[add a pattern detecting a name, can be used as an alt name for lang]:pattern" > > 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. > > You can use _call_program with --list-languages to generate the right set of > option names dynamically. > > > elif [ "$_ctags_type" = "exuberant" ]; then > > arguments=( > > "-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" > > Is the argument to the -f option allowed to be pasted to it? If so, s/-f/-f+/. > > Also, s/:file:/:output file:/. That part of the string is a user-facing > message, so the extra detail is helpful. > > 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. > > > "-F[use forward searching patterns (/.../)]" > > "-h[specify list of file extensions to be treated as include files]:" > > Write something after the colon. > > > "-I[a list of tokens to be specifically handled is read from either the command line or the specified file]:" > > The thing in brackets doesn't describe the action of the option. Please edit. > > > "-L[a list of input file names is read from the specified file. - is stdin]:file:_files" > > Rephrase in the imperative. > > > "-R[equivalent to --recurse]" > > This is normally rendered as: > > '(-r --recurse)'{-R,--recurse}'[description]' > > > "--fields=[include selected extension fields (flags afmikKlnsStz)]:flags" > > 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., «compset» (for the leading plus > sign) followed by «_values -s ''». > > > "--file-scope=[should tags scoped only for a single file be included in output]:bool:(yes no)" > > "--filter=[behave as a filter, reading file names from stdin and writing tags to stdout]:bool:(yes no)" > > "--filter-terminator=[specify string to print to stdout following the tags for each file parsed when --filter is enabled]:string" > > "--format=[force output of specified tag file format]:level" > > "--help[help text]" > > "help text" is just a noun phrase. Please use complete decsriptions. > > Please use exclusions if needed («'(--foo)--bar[baz]'»). > > > "--language-force=[force all files to be interpreted using specified language]:language:->language" > > "--languages=[restrict files scanned to these comma-separated languages]:language:->languages" > > Can't say I'm a fan of having two states that differ by a single letter, > but so be it. > > > "--recurse=[recurse]:bool:(yes no)" > > Fix the bracketed description. > > > _arguments $arguments > > Pass any arguments to _arguments that may be needed (for > instance, -s). > > > if [[ "$state" = language* ]]; then > > local -a languages > > languages=(`ctags --list-languages | cut -d" " -f1`) > > Use _call_program and $service. > > > if [ "$state" = "language" ]; then > > _wanted languages expl language compadd $languages > > Don't pass unsanitized command output to a builtin. In this case, > «compadd -a languages» would do. > > > elif [ "$state" = "languages" ]; then > > _values -s , languages $languages > > Don't pass unsanitized command output to a builtin. I don't know the > fix off the top of my head. > > Thanks for the patch, and especially for adding exubertant and BSD ctags > support! > > Daniel > > > > > > > > > > > > > On Feb 23, 2021, at 10:45 PM, Jacob Gelbman wrote: > > > > > > Hey, thanks for looking at the script and adding it to the repo, although I think some of got pasted in wrong. There’s a lot to writing completion functions and I’m still not 100% sure how to do it right. > > > > > >> On Feb 23, 2021, at 3:39 PM, Oliver Kiddle wrote: > > >> > > >> Jacob Gelbman wrote: > > >>> I wrote a completion script for the ctags program. Someone might be able to use it: > > >> > > >> Which ctags!? > > > > > > I have Universal Ctags 5.9.0 > > > > > >> 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. > > >> > > > > > > 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’s etags that comes with emacs. I can probably add an if statement based on the output of ctags —version, and modify the function from that. If it’s etags, I’ll just: > > > > > > _comps[ctags]=“_etags”; _etags > > > > > > And exit. > > > > > >> 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. > > >> > > >>> #compdef ctags > > >>> > > >>> local state > > >> > > >> 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. > > > > > > The -C argument and the context/curcontext variables are confusing me, a lot. > > > > > >> > > >>> "--alias-=[add a pattern detecting a name, can be used as an alt name for lang]:pattern" \ > > >>> "--input-encoding-=[specify encoding of the input files]:encoding" \ > > >>> "--kinddef-=[define new kind for ]:kind" \ > > >>> "--kinds-=[enable/disable tag kinds for ]:kind" \ > > >> > > >> These would not complete especially helpfully. I suspect that there is > > >> supposed to be substituted. > > > > > > They’d show up in the menu when you press tab, but if I filled in the actual values, the list would be too long. > > > > > >> > > >>> if [ "$state" = "language" ]; then > > >>> compadd `ctags --list-languages | cut -d" " -f1` > > >> > > >> It would be nicer to use a description by calling for example, _wanted > > >> here. > > > > > > I can do that. > > > > > >> > > >>> elif [ "$state" = "languages" ]; then > > >>> _values -s , "languages" `ctags --list-languages | cut -d" " -f1` > > >>> fi > > >> > > >> 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. > > > > > > This too. > > > > > >> > > >> 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. > > >> > > >> Oliver > > > > > > > >