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 17702 invoked from network); 24 Feb 2021 04:46:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Feb 2021 04:46:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1614141962; b=pPIeSpfDvOiAJyEMHcvh4HCfcYi/SAa/wZZYdFYszv++q+z4JaJeVXlO7R4QPWpJiigwVTEaqu +az01vmdoB/fx28XSbxT/A13wMQUy+6SsW1uZDcLqGf9RJnNVaR+yVG6tK4Vr89mqkVt/IxJRj NgErYGjZ27iYAU5Z4EvnOS4Ps5i4iLPYzdZ7wmDBydXUfQfM3CsU3CJr+dXTyRsonPWpN58P6A zlf7o005hy2K2rzbIzOBW9zFH5ZhiFK5sxlYFNa72RfTLVBpMEJrEj75OM2XNEt+5zfs0HD9UI b51x80ENZsdXLd4ts8gIdEGpVX2xicK5PSqBfunwAy1opw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f46.google.com) smtp.remote-ip=209.85.210.46; 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=1614141962; bh=957KmIVPN9nLZ4UkBfsikSbldl8YxgakGWReljSYnt0=; 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=02DYSqxBNSWuGPHGX0wQy73aqAq7mFcKthuc8Vl14prDnoKyAi7Z7R21yYTN74l3ibIswSm4lt HzdZFlH1OkC7LBwYtjTk1AuOmvMOHPByFB3c6YHtPwnsiSeEK9NgKgS6umGhVTZp1ehRzAfrEA iJAKfRKH8uUUKTCp259PR8JJ6uZ+u3lNrrZ+DY9+6zWQeILhs6bkvklAYAGqE+NEkonm1PSNsM jg27xMMKxwAu/pVAcqgpXSUH8U+ZesQGrINUk4IzknIO9obNuU9bC6pydRIWHfux6MrdkGiR4u PUcPmzixR24paPCx/ZAqAjT4xuGtIrsetfhJALZgzJmE1w==; 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=hlQGO7kfJ1Q53zAtNfr0qLrFLFM39QHUXfYaGn6YCqc=; b=lr9u3O/oJqDmHJiGbFhvVRxlQ3 v/IsLuxIgsAvAG0m1bJ1i3PQYkHv9meBRtfJrLNbi9NjollThU18GqmznNdJqrIdrGp0OkaHTLHSg 8+29gqNl0KtIEiL+nSOcR2fG+f3mDkk+TnwwSy3bPb4ntql5E160X3xQ3SG+djmEKFK/p/ce6X9uF Mb5hDRWmTkgI2v3qAUsPac7g1P0wHGFdGeSSP87HT//KOBYZnMJMoXUGEQ7llAZrEP7aUx0/3XjSr ulvrswGYYj1jPvXiWVhRVD7VTm+gVA3QfVJ7HlaCmuePcGEUpdiDmFIylRge34SbZq/hO8YPvmXL1 VyMmeqpg==; Received: from authenticated user by zero.zsh.org with local id 1lEm3j-000NvW-Gm; Wed, 24 Feb 2021 04:45:59 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f46.google.com) smtp.remote-ip=209.85.210.46; 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-f46.google.com ([209.85.210.46]:33683) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lEm3T-000NmK-S6; Wed, 24 Feb 2021 04:45:44 +0000 Received: by mail-ot1-f46.google.com with SMTP id c16so1033754otp.0; Tue, 23 Feb 2021 20:45:40 -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=hlQGO7kfJ1Q53zAtNfr0qLrFLFM39QHUXfYaGn6YCqc=; b=OpVJhqJco+ai5IDxbmozqHb08MtS5qg1G7TJZ80b7li0qKBNg6uINK/kla0cKjYCXr glL9qFn0hhgAY497XLvRDENnrV7uvQszRMdSKlJ7+xachGaBK1mt3h9sGFuzeRW1GBp/ 05XBy1tmEoAglZ6ZGPGrNYR6jiRtwzSW/cC7dji7UNdqJD4m6LqLXv4r41UNlaa5HIb5 isNlZe8abSa9ONvglPP/+iJO6RsSeDNUJv0PV+2lcoUzwCyNXD3mpE2FiC1QxndUPVMI 5cVNk6X9KtrBE1Cm00BKm2lMfc3ve2TrGz+RpeQGsH/bZ+ZCDPRvGvQeIVzfbS7XE0Ks QQVg== 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=hlQGO7kfJ1Q53zAtNfr0qLrFLFM39QHUXfYaGn6YCqc=; b=AYzX23pxXiX6Bthb3ugsCLFdLwAXXDPJ3fpbOmHFvc/0tkOczc1CL4Hq93RjE+t9ra TA3j9qHrrQ5Tbcj8ugpMIi/eQyAoKzJRgEta9Rn0WozJxggyfDoCktZbHw9nHDOITKu5 EuJEvJKIPxXZ5bCMGuPJDmKn15hehUeAwSf/pPi0abVOlUvOuTI7PANu7UPHIzdc378n p8F0WIBbtUvmmxPt3MBrefTh3T5ZiAD9oE/CydnUbEZ2PtwDTFgLUAqf5jU9dZbLYAoS H8LTcMZjn857G7QOBXEd1QGvOOM+7EPbdTlqRu6gCBuq9s3mXBsMy3ByyhzJo4jxpceN 9vqw== X-Gm-Message-State: AOAM532MQwXBwzp89vMIMySSfzb66/m1OZC+n6Y/tKj5IjlYSQFl7fwg C219eoidgtYuaT2dnToviAI6p/nKIXQ= X-Google-Smtp-Source: ABdhPJy20DhX4JJ3SYxDcZNFeUydkRXRftNOTRWZtiFcDlMAmBLidtcBNXmevguhMo/H0UKWxZi/dA== X-Received: by 2002:a9d:32f4:: with SMTP id u107mr22840407otb.308.1614141939067; Tue, 23 Feb 2021 20:45:39 -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 j5sm188111oij.48.2021.02.23.20.45.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Feb 2021 20:45:38 -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: <31598-1614116362.902856@aI-l.maGv.3QD7> Date: Tue, 23 Feb 2021 22:45:37 -0600 Cc: zsh-workers@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <31598-1614116362.902856@aI-l.maGv.3QD7> To: Oliver Kiddle X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Seq: 48104 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: 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. > 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!? 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. >=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: _comps[ctags]=3D=E2=80=9C_etags=E2=80=9D; _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. >=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. The -C argument and the context/curcontext variables are confusing me, a = lot. >=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. 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 >> 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. I can do that. >=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. This too. >=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