From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43492-ml=inbox.vuxu.org@zsh.org 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 ec006903 for ; Tue, 18 Sep 2018 19:33:08 +0000 (UTC) Received: (qmail 12473 invoked by alias); 18 Sep 2018 19:32:57 -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: 43492 Received: (qmail 1776 invoked by uid 1010); 18 Sep 2018 19:32:57 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 1.441494 secs); 18 Sep 2018 19:32:57 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=nz2zVk iHnIWj1XcOIeHbtZAZHKPB0VI1jkYGAjJvVmI=; b=cjNMufPtQy768L9d/T4fDA KR5NU5tuaQaN/k7h8C+94V6fuJYcBfV8nWBIWpopbEZmo7fsvPSPPEvBumUyHJv3 /GGqkLh2AdMvp5D9oZgnk0log2b3YpeI8BLcZ51NraR5MyJQ0de4qHRgqG4aLjNE TChtBFYMjOjvSlSyoVs5OZrLFbX1sWBJAMghAY4V8MD4J4My6TbEr+cF5FyHQv/5 IkmJj4vHLVNM5yjsxmwW5AJJw9TJxS8i/RVHJqrfjuq36yTMTS3DoV2hA0+qPRdh 8egasBOTzXI1qu354YLHSGl3iFpPH20kxMigePCwENWNoSM6OWF/Wz61IVaUj4jA == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=nz2zVk iHnIWj1XcOIeHbtZAZHKPB0VI1jkYGAjJvVmI=; b=rzBkWnBpQqWw3mtrJ+bxad k9ZG63LKBhXM9JY6XA738cxBhPY2cb3HiKoTL/c9kyWe/61wZ9RczzF+XMxd0Nt9 c34iw+AGZgfVvewVR9q/c7Aj6qu8uPci3XnEOkEiibh8Bbe3ilCdvVVNtdRMjnpN Bai/5casl0w1y/0S1p0JYpVp6cpoxkyWVz/DFDmqN3BK5yTfteWCPhTlHuei42Ll XpsMTRhBWPxCtSoSuI/pxY4IOXBa5w9w90l9UFO9clhO+LNOuW4d8jdcyTsOodt+ UoxJA7tizU6/p/9pCAPzkezjK5RZlx4Awjfze8+ldqbtOASpCcBK9wbQBNjm0pnQ == X-ME-Proxy: X-ME-Sender: Message-Id: <1537299172.1213094.1512566000.19322CCD@webmail.messagingengine.com> From: Daniel Shahaf To: Maximilian Bosch , zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-e556cd15 In-Reply-To: <20180918190516.2w3tyiugdmx6wzqw@hauptschuhle> References: <20180918124951.4nbyjhbuqnkioqrt@hauptschuhle> <1537287030.1158541.1512325000.0C43F9DE@webmail.messagingengine.com> <20180918190516.2w3tyiugdmx6wzqw@hauptschuhle> Subject: Re: PATCH: search XDG_DATA_DIRS in _setxkbmap completion Date: Tue, 18 Sep 2018 19:32:52 +0000 Maximilian Bosch wrote on Tue, 18 Sep 2018 21:05 +0200: > Thanks a lot for your feedback! > > I use ZSH as interactive shell quite excessively, but as you might've > noticed, I'm not that experienced with ZSH scripting, so thanks for > your patience :D > You're welcome. > I applied your suggestions and re-checked the patch. > > > How should empty array elements in XDG_DATA_DIRS be handled? E.g., > > XDG_DATA_DIRS=/foo:/bar::/baz ? > > Isn't this handled by `[ -d $fullname ]`? Depends on how empty elements should be handled. In some contexts an empty element means "look in the current working directory", and I wasn't sure how the XDG spec defines this case. It's not a blocker but it would be nice to get this right while we're here. > +++ b/Completion/X/Command/_setxkbmap > @@ -9,10 +9,12 @@ _setxkbmap() { > setopt extendedglob > > # xkb files may be in different places depending on system > - local dir sourcedir > - for dir in /usr/lib/X11/xkb /usr/share/X11/xkb; do > - if [ -d $dir ] ; then > - sourcedir=$dir > + local dir sourcedir fullname > + local searchdirs="${XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share}:${XDG_DATA_HOME:-~/.local/share}" Two tweaks here: 1. XDG_DATA_HOME should be listed before XDG_DATA_DIRS, according to the XDG spec. 2. I'd use an array, both because it's cleaner and in case $XDG_DATA_HOME contains colons (not likely, but there's no maintenance cost to supporting that). Thus: local -a searchdirs=( ${XDG_DATA_HOME:-...} ${(s.:.)XDG_DATA_DIRS:-...} ) for dir in $searchdirs; do > + for dir in ${(s.:.)searchdirs}; do > + fullname="$dir/X11/xkb" > + if [ -d $fullname ] ; then > + sourcedir=$fullname > break > fi > done Cheers, Daniel