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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19856 invoked from network); 21 Feb 2023 22:13:29 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Feb 2023 22:13:29 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1677017609; b=Cv1s6HsW/sczVsKaaf1bvJJSvj0ATI7JekkmnQOsDkZKQk5OBPxLSQFqL9gpnj43b6YQ6rFOL0 BzRTTx1hPeAV/JvfjlyQVPlaxTXAu6U9KV3dZUsUHZvSy48x7dJq5kV8GyFpTg7iAD6Mrkqkcb r3x+bdVRuA3uXlZ7zfzHiWGaGtpTEKQzwp6Pl/VodtckeS88Ma+W0unYHu6KZHi6M/FFGJWavY rD5ihM8A3cHVbV6p5rAzl1mnxbV6GXWfDG37qdHL/iESsMJflsgxOEHH7R+yI/nvLsfDkd4EzL rqwqqCeCA+AwRUiEaTdg45uJzFYGUr4Km745LYjauK2rgg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mout-p-103.mailbox.org) smtp.remote-ip=80.241.56.161; dkim=pass header.d=mailbox.org header.s=mail20150812 header.a=rsa-sha256; dmarc=pass header.from=mailbox.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1677017609; bh=mJZZqNBK3abHwCATHac6n1v+FVdF/cu+FIS/to587s0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature:DKIM-Signature; b=V6N9amCnj3n1vt8mmygxgLCgcL4E9DAsx7Ylbi2NuKD3aMg6D6mZbUCGmRd9i6jZ4X0Iv30ZpU iP3eG/n0IYqr6+yhD6hN8ClGoApWjYIot+68aJlD8hP7wOBhOgAfVqkq/9RzLccxOaC1KMBz9T /vF5yu7j79bU3aRpjUWkW+ThhenpislJFuZQC8knlNjQRQ71HPVrINmo2NBgOs8v+2wn/p2MRP roTdRauwMLTed7p4dIWSUcOCawc6DpjeeUSO06e9J7CUV6tMboShWej1WYJUdIy5Nwf9gmfpjA fSYPk8+nyO8B59P2+9X8rsc8NjNh8BkiTcrt89kBNNJSeA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=M9ZQRgtJ2KPYvj1G77tHDpKS13IRQ/bQ9G3xfQyxK6c=; b=elz2UCUtE63zY3x/kFGRgaZpnM A5SIKxy42WSPwmNMVFMLLkySBQC12204r+snrzWGmmyuh4j7IpWAVvUtAh98Ne3WuGfsLNsRQKhCP t5g26/y4mZyXsuxx3UjOTfmo+01Umd13/dPxl+I+lDUFr2hn3lRy5ZN/n2DhpUWimlOspCv17Sx7w ESXF5OY3GCiksljx2Q6yTVdm1/DUwwcrMOFqhF+x9FTCM7EjrwOLkq2Dj2HNz7yF3PuFJ3DOtKOxs gbQdakXm4NkwsZTtwG01v98FuYgSJQzauUpbqaY/yP2eDg0M5Nkxsw4xhocpa28GxAN/O5SvaTMTH dW5mvZzA==; Received: by zero.zsh.org with local id 1pUat7-000HWy-7z; Tue, 21 Feb 2023 22:13:29 +0000 Authentication-Results: zsh.org; iprev=pass (mout-p-103.mailbox.org) smtp.remote-ip=80.241.56.161; dkim=pass header.d=mailbox.org header.s=mail20150812 header.a=rsa-sha256; dmarc=pass header.from=mailbox.org; arc=none Received: from mout-p-103.mailbox.org ([80.241.56.161]:43502) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pUasW-000H1F-Bj; Tue, 21 Feb 2023 22:12:53 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4PLtns4xlxz9sjf; Tue, 21 Feb 2023 23:12:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677017569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=M9ZQRgtJ2KPYvj1G77tHDpKS13IRQ/bQ9G3xfQyxK6c=; b=Q/8+zBzQmOVFKTm9CTlP3TjcMQhydqtlGpwAm+92wzMY955/FkWBQP2Y5QEpGGx7ld4Jpz 7ik/eRt5609RjmHAISCuovd4GNyeDxd/rD0o2t6dr3Gl/NVQ/CgEJObOPl1d+yosYzU3s9 ZzMkvmg4t+c4rim+kHocxNzrkzjjeAmfnYHyzbSEG591Lw9WhxYliU7MzvGgtyOlFHnP27 UsB+OmI6cYJCHuEz3SVybZWRATYqqIqGBrqQ4xaaj4jg1KvphpZ+RW2djaRP4ucCxW2NM2 RNLeHFnnblIIJCrbpBBT8tNkfVI2ZZYSfjz/hNb7yHBVWLxiC2SgyY18YCIrnQ== Date: Tue, 21 Feb 2023 23:12:47 +0100 From: Sebastian Stark To: Oliver Kiddle Cc: zsh-workers@zsh.org Subject: Re: Separate cdpath elements in path-directories completion Message-ID: <20230221221247.aacrywwb7fmnzmew@singold.localdomain> Mail-Followup-To: Oliver Kiddle , zsh-workers@zsh.org References: <20230218211046.vj3p4k7y6uraytpo@singold.localdomain> <20230219100217.f2mcniygwgbtxvwf@singold.localdomain> <80615-1676825482.916080@qR5n.Nmed.T67B> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <80615-1676825482.916080@qR5n.Nmed.T67B> X-MBO-RS-ID: 19ff1ed4d01f098c3b0 X-MBO-RS-META: o55ydqbmrxj3dxse9u5qih5oqndrq4m9 X-Seq: 51470 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: Am Sonntag, den 19. Februar 2023 um 18:32 schrieb Oliver Kiddle: >[ moving to -workers and cc: Sebastian ] > >Sebastian Stark wrote: >> Thanks for showing me the right direction. I ended up with the >> following, in case somebody wants that feature too. I can control the >> behaviour by adding >> >> "zstyle ':completion:*:directories' cdpath-sections true" >> >> to my config. > >I realise that you posted this "in case somebody wants that feature >too" rather than as an explicit contribution but if we include this in >the distributed _cd, it'd be rather easier to use. For that, there's a >couple of changes I would suggest: I wouldn't mind trying to get this in shape for an explicit contribution, if I can be of any help with it. >cd completion otherwise uses the tag "path-directories" for directories >from $CDPATH. It is always better if you can vary the context but reuse >an existing style name. In this case, the separate-sections style would >be appropriate. This would then need to be: > > zstyle ':completion:*:path-directories' separate-sections true This makes much more sense indeed. And helped me understand zstyle better. >Also, I would probably suggest expanding the description to "directory >in $elem" instead of just "$elem" as here: > >> + alt+=( "path-directories-$elem:$elem:_path_files -W $elem -/" ) >> + done >> + else >> + (( $#tmpcdpath )) && >> + alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' ) > >I'm also unsure about including $elem in the tag. It will probably work >fine but doesn't exactly conform with usual tag naming conventions. >Perhaps just an index for the position in the cdpath array. Does anyone >else have an opinion on that? I think a tag should be a) unique and b) easily addressable via zstyle. The index in $CDPATH would satisfy these requirements. Although if we had some normalized form of the directory here, e. g. by replacing all non-alphanumeric characters with '-', one could address an individual path by its name instead of its index, making my zstyling immune to the order in $CDPATH. For example for cdpath=(~/git /some/other/dir): zstyle ':completion:*:path-directories-1' format "Git Repositories:" as opposed to: zstyle ':completion:*:path-directories---git' format "Git Repositories:" The latter being slightly opaque syntax unfortunately. Updated patch using the index and the other suggestions added: --- /usr/share/zsh/functions/Completion/Zsh/_cd 2023-02-08 23:22:07.000000000 +0100 +++ .zfunc/_cd 2023-02-21 22:45:35.731260952 +0100 @@ -70,8 +70,15 @@ tmpcdpath=(${${(@)cdpath:#.}:#$PWD}) - (( $#tmpcdpath )) && - alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' ) + if zstyle -t ":completion:${curcontext}:path-directories" separate-sections; then + local elem + for elem in $tmpcdpath; do + alt+=( "path-directories-${tmpcdpath[(ie)$elem]}:directory in $elem:_path_files -W $elem -/" ) + done + else + (( $#tmpcdpath )) && + alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' ) + fi # With cdablevars, we can complete foo as if ~foo/ if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then Sebastian