From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 2d8470e6 for ; Fri, 23 Aug 2019 04:41:32 +0000 (UTC) Received: (qmail 23747 invoked by alias); 23 Aug 2019 04:41:23 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44699 Received: (qmail 4361 invoked by uid 1010); 23 Aug 2019 04:41:23 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25545. spamassassin: 3.4.2. Clear:RC:0(66.111.4.26):SA:0(-2.6/5.0):. Processed in 4.885884 secs); 23 Aug 2019 04:41:23 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) 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=fm1; bh=9+TwtoKtx0fFuykgrr3fRLU1cQgyCEV/Vn2tQ1kD J8Y=; b=NNafR8rMhM+kZTj3vhkigbcAUFI+sUkUzI6KOWxWdy+5Fl0/vB8oVLpF Ne0lrZcyFEc8GCflQyJn6c8LBpAcMPnsHWyHREV1SZE3I6TIG0dGF9QG/EpXfzD7 O8WuIPGvxW80w/pnvm3y2vmrw0vT+vEkX0ROY6ZfJm9fL3F4v57iJm1MELeIJ5qw 7rjhH/Lss6HPKxP9hS+QIz4/z6EmceiqnFABBa/xDP0m7RDkh0cpEafOLw7gsoMk bD9pibwT7iOpskBzD1xu65bGcytaAXNVnZQT1pckq42NFa01mo6+drxiyIwaF+fr oS55PIIO6zSAeu3CZb2UAjIBUYzOFA== 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=fm3; bh=9+TwtoKtx0fFuykgrr3fRLU1cQgyCEV/Vn2tQ1kDJ 8Y=; b=wJCLy4CAyoJ1AOt0YBUROSd08kZLCP9YIP7uJHNIA7HIvh48TJ1YA+YBf ozyu+RxQIo7r82ghLmJCujNom4hDPPpo7PXqEP6UwrZ2y8s7Xne8g3Z8+5WtL7i/ ztz4X6Tlzpbl78eWcEVw6+F+4e/Mu30hMGg6gjmB4Pqo1Ppif3qMfBmatMwJkSTH TwRNQz0iH4OuqCSbxk5TOgF8NwYke92JajHu+3rT/xyA6T5cRuxEeBMrgBula9is 2phDDejVUAya/CQEhnmaISJQv/Bw3mE5YoXywWHmuDE1sD0E5e+tVNpQul0IWdX7 ROtbhJ9gNd1LEOFg3SjU+hm/Dh/Ug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudegjedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggugfgjfgesth ektddttderjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvgeqnecukfhppeejledrudejiedrkedurdefgeenuc frrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgr mhgvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Date: Fri, 23 Aug 2019 04:40:39 +0000 From: Daniel Shahaf To: Baptiste BEAUPLAT Cc: zsh-workers@zsh.org Subject: Re: [PATCH] Completion for sbuild Message-ID: <20190823044039.sk2uiatlvacpcifl@tarpaulin.shahaf.local2> References: <68254402-c6c6-2579-1675-df637ee1127a@cilg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <68254402-c6c6-2579-1675-df637ee1127a@cilg.org> User-Agent: NeoMutt/20170113 (1.7.2) Baptiste BEAUPLAT wrote on Thu, Aug 22, 2019 at 21:53:14 +0200: > I wrote a completion function for sbuild (a debian tool to build > packages). I think it would be nice to have it upstream. Thanks for the patch! > It covers all options described in the man (expect one, which is > depreciated). "deprecated", unless sbuild's financials are weirder than I thought. ☺ > Don't hesitate to give me feedback, I'd be glade to improve it. I've done a partial review and found some minor issues. I also have some suggested additions; those are nice to haves, not blockers, of course. > _deb_distributions() { There's already Completion/Debian/Type/_deb_codenames. Please use it (and improve it if needed). > _get_identity() { > [ -n "${DEBFULLNAME}" -a -n "${DEBEMAIL}" ] && \ > compadd "$@" "${DEBFULLNAME} <${DEBEMAIL}>" Please add an end-of-options guard: . compadd "$@" -- … . Please also fix the other instances of this issue in the patch. Please use «_wanted» to allow filtering by tags. I know it's annoying, but it's allowed to do: . unset DEBFULLNAME DEBEMAIL="J Random " . Could you support this? Please use «[[» instead of «[»: the former is a reserved word, the latter a builtin. (No effect in this case, but more for a consistent coding style.) > } > > _get_gpg_key() { > compadd "$@" $(gpg -K --with-colons 2> /dev/null | grep '^uid:u:' | > grep -o -e '<[^>]*>' | tr -d '<>') Example output: [[[ % GNUPGHOME=$PWD gpg -K --with-colons sec:u:3072:1:A1EA95DE874DB2D5:1566533599:1629605599::u:::scESC:::+:::: fpr:::::::::D1ADEF874C12D90BFB1062E0A1EA95DE874DB2D5: grp:::::::::835F9949A6E28D3B70696867F064CBFF5DEBF50B: uid:u::::1566533599::A06E327EA7388C18E4740E350ED4E60F2E04FC41::foobar: ssb:u:3072:1:7CF9BDFD879FC134:1566533599:1629605599:::::e:::+::: fpr:::::::::876684635455EB5CC21751587CF9BDFD879FC134: grp:::::::::CD7D8D5F91E21EE5ADA28CADF7A17233F028C1FC: ]]] A couple of issues here: - Please use _call_program, to make the path to gpg configurable by zstyle. - It would be nice to use builtins and parameter expansions instead of greps, for performance on Cygwin. (Yes, I know this completion is for sbuild, but someone might do «ssh foo sbuild ».) For example: local -a lines=( ${(f)"$(_call_program …)"} ) lines=( ${(M)lines:#(#s)uid:u:*} and then split each element by colons to get the right field. (You need to do that anyway for two reasons: (1) because the uid line needn't contain angle brackets; (2) for forwards compatibility with future versions of gpg.) By the way, consider using _describe. If you use the "Name (Comment)" as the completion, you can add the keyid as the description, and vice-versa. > } > > _sbuild() { > '--add-depends=[add dependencies to source package]:depends' \ The part after the colon should say something like "source package name" or "source package names, comma separated". It's actually displayed during completion if you have the «format» style set (e.g., «zstyle ':completion:*:(messages|descriptions)' format '> Completing %d»). I ran out of time here so haven't reviewed the rest of this function, sorry. > '*:dsc file:_files -g "*.dsc"' > } > > _sbuild "$@" Cheers! Daniel