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 31634 invoked from network); 23 Feb 2021 21:39:47 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Feb 2021 21:39:47 -0000 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:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=DjqgWSSrb4tiTBqat5MHF+t4KyllTeHk/BwUbQuwvks=; b=LLR/XoPBCABWslQFIdyqlG880+ Q9RK/UNhcU/yDN4XmLX6p6qrNZr2uB6fhkmXv1q+zELlhIakDqacqWVnlsHGzHvTHxCdw+r4K2pmC VUJQy8SWMKGljzygbff3E76u4YG3Y+X8fyh3pS4fG7mz+E9NWOS553Xs0x/kdnfEPjIObG4+LyIw0 ABOn3cZi8wd5pZD8xRoqd3iGcK6vGExPEjcF+ACFo80mdiwm7Vvh/PDwO7vc5vaKZRPghIDAta4oK 0IDCLzQv91DMdGbLUzFEUAplSWCEQxZOB+FBsr0wAUQrGe4CR95nRu3rOyKYaW3DTEgWJdnNI2Vyg 264ksJEA==; Received: from authenticated user by zero.zsh.org with local id 1lEfPG-000BoZ-HE; Tue, 23 Feb 2021 21:39:46 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lEfOv-000Bf2-Ng; Tue, 23 Feb 2021 21:39:25 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1lEfOs-0008Df-V0; Tue, 23 Feb 2021 22:39:23 +0100 cc: zsh-workers@zsh.org In-reply-to: From: Oliver Kiddle References: To: Jacob Gelbman Subject: Re: Completion script for the ctags program MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31597.1614116362.1@hydra> Date: Tue, 23 Feb 2021 22:39:22 +0100 Message-ID: <31598-1614116362.902856@aI-l.maGv.3QD7> X-Seq: 48098 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 Gelbman wrote: > I wrote a completion script for the ctags program. Someone might be able to use it: Which ctags!? 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. 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. > "--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. > 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. > 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. 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