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 13588 invoked from network); 28 Mar 2021 23:30:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Mar 2021 23:30:06 -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=Cvp1Jv/GiuFk7iEM+wb0GNYZQmsjRNUoCEwcT8rQ9vE=; b=z9PYxlz66/X/dvcqcD9zcOSTh0 +oICHP4nn1LPG8aQpuTgyu9wihFw67kIHepj9r6AQ5wl0Ccl4DSp88na5qVG6AXzPjNVAJS/lHiXi q8yRvzWurOqwoECtdshIads60NuFY+EBXT2EgYby0paqh9Eka1ToW/k8Uj4lmiCTPSBJrwGHtnKrc vAteX4n2qHQ1it2T2MBOepg7TmmCbkEPn52sUsbLBtCXQyItr1neXuPT6LHbnCyWix7miqxR7FCVv tTewB0OEj9iNyRbzylQF/4yeqaMaZzKEACkf+IVlbH3Yp2zPZbGYTPoKTT0/bVokbh9X2BasRp095 JC5OYlRQ==; Received: from authenticated user by zero.zsh.org with local id 1lQer7-00019L-U8; Sun, 28 Mar 2021 23:30:06 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQeqq-0000zi-Bn; Sun, 28 Mar 2021 23:29:48 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1lQeqp-000L5I-8z; Mon, 29 Mar 2021 01:29:47 +0200 cc: zsh-workers@zsh.org In-reply-to: <742BD09C-6FE4-4B89-9B8F-824FB67EDEED@gmail.com> From: Oliver Kiddle References: <31598-1614116362.902856@aI-l.maGv.3QD7> <20210224142437.GC9342@tarpaulin.shahaf.local2> <3e0a754f-bbac-404d-92ba-b30f0c736f61@www.fastmail.com> <7f0a752e-2685-4c4b-8a31-b8db1728af1f@www.fastmail.com> <20210311161552.GA9181@tarpaulin.shahaf.local2> <742BD09C-6FE4-4B89-9B8F-824FB67EDEED@gmail.com> To: Jacob Gelbman Subject: Re: Completion script for the ctags program MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <81050.1616974187.1@hydra> Date: Mon, 29 Mar 2021 01:29:47 +0200 Message-ID: <81051-1616974187.275911@6nTa.K7Pn.vjul> X-Seq: 48296 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: On 11 Mar, Jacob Gelbman wrote: > Yes, here it is: Thanks for sending the update. I've committed it as-is to the repository because it is a definite improvement on the earlier file and that doesn't prevent us from further iterating on it. It is easier if you can send changes as patches. Use the diff -u, or git diff commands to create patches rather than posting full files. The previous files also had DOS line endings - if someone other than me pushes any updates, please ensure we only have Unix line endings. > #compdef ctags arduino-ctags ctags-exuberant ctags-universal exuberant is installed as exctags on my system so that name could be added. > local context state line expl > local -A opt_args > local -a arguments > > if [ -z "$_ctags_type" ]; then > local output=`ctags --version 2>&1` > if [[ "$output" = *Universal\ Ctags* ]]; then > _ctags_type="universal" > elif [[ "$output" = *Exuberant\ Ctags* ]]; then > _ctags_type="exuberant" > elif [[ "$output" = *usage:\ ctags* ]]; then > _ctags_type="bsd" > elif [[ "$output" = *Emacs* ]]; then > _ctags_type="etags" > else > _ctags_type="universal" > fi > fi As was mentioned in a previous review, use _pick_variant for this. It does exactly this in a generic manner and handles things like caching results. This code above will cache one result even if the user has both ctags and ctags-exuberant installed. > if [ "$_ctags_type" = "etags" ]; then > _etags > return $? > fi WE should perhaps pull the contents of _etags into this function and handle them all together. > if [[ "$PREFIX" = -* ]]; then If the prefix-needed style is set to false, that condition is not applicable. If generating the list of languages is fast enough, I would generate it unconditionally and store the result in an array so that it can be used from a variety of places. > local -a languages=(`_ctags_languages`) In general, I would recommend using $(...) instead of `...` because it is simple to nest. That doesn't matter here as such. > local -a languages2 That variable isn't used. > for language in $languages; do > arguments+=("--$language-kinds=-:kinds") The latter kinds should be singular - kind. You can actually avoid the need for a for loop by using --${^languages}"-kinds=-:kind" If you keep the for loop, language does need to be declared local. > if [ "$state" = "language" ]; then The [[ ... ]] condition form is usually preferable to [ ... ] because the parser handles it and avoids certain tricky issues. A case statement would work here though. Or even better, make _ctags_languages a proper completion function so that you can call it directly with options such as -S = or with _sequence for the comma-separated list. Thanks, Oliver