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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17890 invoked from network); 22 Feb 2023 11:56:31 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Feb 2023 11:56:31 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1677066991; b=TGoZNEKIqDgi3FYWSOjb2l8gWLT1JcInjlYJrouwt76xAGlaM1CLs4QMaw4m2yAValtorZ73l6 ufFwPjsv2sZVkYfEjRacyTtmWe/BVeAx84/IeSNbXDxrngqyjcHDvAbsKg0ddKImVLuoHqWqLF HehfNDh3Y4U67fn88sqO2CE8Jaz6tdFoJvc87W1SbeKWJYqVckLqtJCUW4fntVNBqvHMw8gNQh gbUX2xWClZkl7dwNnjx1rY27HxEOkHZnAnKdYZwIKbAquYitsQCG/dDSF3Hmq+6cYdVLyjaS9O 3UhB1QsYwim2/jMDw8+n5cPwy5U0jBpv5MPZUndfoHx85w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f175.google.com) smtp.remote-ip=209.85.167.175; dkim=pass header.d=gmail.com header.s=20210112 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-20210803; t=1677066991; bh=HwhVr1C/PV5R2688EI7YhnD+qlmsrm7Euff9s4C17ZQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=rKIse612rDvo8yWduZ15DV2BBr+puIcsRv1BkQGDQnCPsJs2ojR3ThpVH35rjYdF4rP/L6C/74 8OH8YrvmpxR1y0N2g/A7M7zcuEwmF1I7WGxfqlkcDJyVuahzhP2JpdSobU4AhN3682bNIk3k42 Yq4s+N7hG+s69hUBDYzRoJh1ygpxDUR6/nN8F/9Y8Zp9uFsnXU369rYKyXFLq5L8QHq0CEaqD/ pH3dwTHcn4A825ml6NGyRdOh+XuW6taNIQBTzUBZ4vVLtshOI1qIBS7uH3iTNqA5Tc/GbzRiE1 V4z1r0gczSkp+lbg4Tvet9HEsWTDJALRBA75aXZyBcxb0Q==; 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:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=233ZWRLitqODKurizMpJaAWq7RyXhI4AQIhzXqNoYtI=; b=CKo3CXk5poTAwpu+65qyIlgzwb P/vHAwMt3F+SOyBNoJB/p36XketLl5b4+oc8heiaKfFtC++lRcqpYvNZE7ZIajlk+4QIPlYws/tJT NyDJ//7CJVhxBkS3cnPBDRjnQn4OAD3SJ5asRgUX/TCu8Y7n5I6or6xnvCrv4eqbflte7Fij83w46 x/3UAqrz0THBKKB9YiiLzG/I4+NgsA9teB2yC24/hgjd3HvqwZKThAk9W4APAbofcjkrzy1NjchuE Lzedv34zRovK+2R0j03tJvZ/rTG7Mr/gj5HdACEkla/SZwxrMEAeVwHSdcTUHwaIG4X2L310BE4ZL jvTOQq9g==; Received: by zero.zsh.org with local id 1pUnjY-000ETp-QQ; Wed, 22 Feb 2023 11:56:28 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f175.google.com) smtp.remote-ip=209.85.167.175; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oi1-f175.google.com ([209.85.167.175]:46808) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pUniy-000EAi-OB; Wed, 22 Feb 2023 11:55:55 +0000 Received: by mail-oi1-f175.google.com with SMTP id w7so7490835oik.13 for ; Wed, 22 Feb 2023 03:55:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=233ZWRLitqODKurizMpJaAWq7RyXhI4AQIhzXqNoYtI=; b=Scu5pyRnjiYKBi7DZGOTqZxCElnigs1cBhN5rH+h1p1LZ4lLOTWP/+BbNz9iadi8J+ U3Hhwa5wT7NhtpjkVnXL0hWXQ7eVP2hxzGwYX7zI1X9BP+ugZBxrbPEQ/UhkVe/3YK6C G3dVUJbteehJQqoGBYtro7DAwpJEHkhXAAk3S05Zbqbr+ZZZyq79AGXJg+2qPx1u8ko6 qh5k8ASwnj3gmesnRxHGsLktWprzmj2YIJVNnN4Hjvm45td2cjDLDpBkMi/Zm5gnbvWp EJwTrPuAs8AFUZxjw/3tdkQdb0bYXn/X8dVcX5OKZhQbGtnI68unNEM85apyGyBBKUAD 7x5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=233ZWRLitqODKurizMpJaAWq7RyXhI4AQIhzXqNoYtI=; b=3bwRzbHIUnoi5f6dqdAz5V/kMKWMR3o9F3SDkysPYx0bBxAWEtKnHIebvuCyG1H9OZ yqniP27JBUeuVpRD+/sfCY303Pkk6fFD8cgounRgI8EZlAnuRN5VG83VOpArJgmwA5ar srGiyKdQQqVzDsY1LgfSC5jwKaA/dcmOZKnhX4hx/RHyTUEwTUJfmrzRmPHFCvdnVEpp uC3I08VJuV5jx4+vzATIAcji3/iB77e9oJ4hk7TfYcqyq8lTf0AeaUccn3cmTJHX9Vbc hmhYQ/3u90pO5HMrU8RTS321nvxFMv3UVzCNBdQPgdU4Q8ZI2P9JXF50Lw3a+OTNixW1 NyoQ== X-Gm-Message-State: AO0yUKXyzzqq43UpZyLmqLQqHutpPXfIK2roL6y8lacCsniUV8wNFv4r aUsbYOIenADM/Igr5fUwUu4OAODU6Dntdf203RfEh/PZrt8= X-Google-Smtp-Source: AK7set9obsqWMTNGY2Ip17S6Jqcf6Tj8kWojI5vfbljEFKDV9OAmM3V7TiqXKsS4qB+zB2RpR+GKv0+277DQ/mceLsY= X-Received: by 2002:a05:6808:1395:b0:37b:8a21:1e42 with SMTP id c21-20020a056808139500b0037b8a211e42mr61440oiw.294.1677066951264; Wed, 22 Feb 2023 03:55:51 -0800 (PST) MIME-Version: 1.0 References: <1857440792.3267285.1611587238431@mail2.virginmedia.com> In-Reply-To: <1857440792.3267285.1611587238431@mail2.virginmedia.com> From: Marlon Richert Date: Wed, 22 Feb 2023 13:55:15 +0200 Message-ID: Subject: Re: Bug report: Completion for dynamically named dirs fails when $SUFFIX is not empty To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 51471 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: It's still not working correctly in Zsh 5.9. Now compstate[context] becomes `command` instead of `subscript` when $RBUFFER starts with a non-space character. On Mon, Jan 25, 2021 at 5:07 PM Peter Stephenson wrote: > > > On 21 January 2021 at 14:37 Marlon Richert wrote: > > % cd $(mktemp -d) > > % ZDOTDIR=$PWD HOME=$PWD zsh -f > > % autoload -Uz compinit > > % compinit > > % zsh_directory_name() { [[ $1 == c ]] && compadd -S ']' foo } > > > > Given the above setup, when > > > > 1. $LBUFFER is `cd ~[` or `cd ~[fo`, > > 2. $RBUFFER is empty, and > > 3. I press ^I, > > 4. then $LBUFFER becomes `cd ~[foo]`. > > > > 1. $LBUFFER is `cd ~[`, > > 2. $RBUFFER is `fo` or `]`, and > > 3. I press ^I, > > 4. then completion beeps and the buffer remains unchanged. > > > > `functions -t _complete` shows that the problem is caused by > > $compstate[context] becoming `tilde` instead of `subscript` as soon as > > $SUFFIX is non-empty, which causes _complete() to not call _subscript(), > > which is the only point of entry to _dynamic_directory_name(). > > The following is somewhere near, but this is quite complex and somewhat > at odds with completion in other contexts --- it's not clear to me > whether or not I should need that special diversion in _main_complete > but currently I do. (Your compadd -S ']' is going to add too many > ']'s in this case, I think, but that's a separate problem.) > > pws > > diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete > index 6b2cf2bcf..2bcbd2118 100644 > --- a/Completion/Base/Core/_main_complete > +++ b/Completion/Base/Core/_main_complete > @@ -94,8 +94,18 @@ if [[ -z "$compstate[quote]" ]]; then > if [[ -o equals ]] && compset -P 1 '='; then > compstate[context]=equal > elif [[ "$PREFIX" != */* && "$PREFIX[1]" = '~' ]]; then > - compset -p 1 > - compstate[context]=tilde > + if [[ "$PREFIX" = '~['[^\]]## ]]; then > + # Inside ~[...] should be treated as a subscript. > + compset -p 2 > + # To be consistent, we ignore all but the contents of the square > + # brackets. > + compset -S '\]*' > + compstate[context]=subscript > + [[ -n $_comps[-subscript-] ]] && $_comps[-subscript-] && return > + else > + compset -p 1 > + compstate[context]=tilde > + fi > fi > fi > > diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript > index 0c9a89ad5..0d9632864 100644 > --- a/Completion/Zsh/Context/_subscript > +++ b/Completion/Zsh/Context/_subscript > @@ -1,6 +1,8 @@ > #compdef -subscript- > > -local expl ind osuf=']' flags sep > +local expl ind osuf flags sep > + > +[[ $ISUFFIX = *\]* ]] || osuf=\] > > if [[ "$1" = -q ]]; then > compquote osuf > diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr > index cb72e4600..b653e7c38 100644 > --- a/Functions/Chpwd/zsh_directory_name_cdr > +++ b/Functions/Chpwd/zsh_directory_name_cdr > @@ -16,8 +16,10 @@ elif [[ $1 = c ]]; then > typeset -a keys values > values=(${${(f)"$(cdr -l)"}/ ##/:}) > keys=(${values%%:*}) > + local addsuffix > + [[ $ISUFFIX = *\]* ]] || addsuffix='-S]' > _describe -t dir-index 'recent directory index' \ > - values -V unsorted -S']' > + values -V unsorted $addsuffix > return > fi > fi > diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c > index 8c0534708..1622d8a6b 100644 > --- a/Src/Zle/zle_main.c > +++ b/Src/Zle/zle_main.c > @@ -1067,6 +1067,7 @@ redrawhook(void) > int old_incompfunc = incompfunc; > char *args[2]; > Thingy lbindk_save = lbindk, bindk_save = bindk; > + struct modifier zmod_save = zmod; > > refthingy(lbindk_save); > refthingy(bindk_save); > @@ -1094,6 +1095,7 @@ redrawhook(void) > * restore lastcmd manually so that we don't mess up the global state > */ > lastcmd = lastcmd_prev; > + zmod = zmod_save; > } > }